Skip to content

Commit

Permalink
Remove usdt_argtype_t, and let consumers specify any type.
Browse files Browse the repository at this point in the history
There's no real need to limit the types that can be specified here;
that's really the job of the library consumer.
  • Loading branch information
chrisa committed Dec 21, 2012
1 parent ac9e412 commit 0b92ee7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
12 changes: 6 additions & 6 deletions usdt.c
Expand Up @@ -24,6 +24,8 @@ char *usdt_errors[] = {
static void
free_probedef(usdt_probedef_t *pd)
{
int i;

switch (pd->refcnt) {
case 1:
free((char *)pd->function);
Expand All @@ -32,6 +34,8 @@ free_probedef(usdt_probedef_t *pd)
free(pd->probe->isenabled_addr);
free(pd->probe);
}
for (i = 0; i < pd->argc; i++)
free(pd->types[i]);
free(pd);
break;
case 2:
Expand Down Expand Up @@ -76,12 +80,8 @@ usdt_create_probe(const char *func, const char *name, size_t argc, const char **
p->argc = argc;
p->probe = NULL;

for (i = 0; i < argc; i++) {
if (strncmp("char *", types[i], 6) == 0)
p->types[i] = USDT_ARGTYPE_STRING;
if (strncmp("int", types[i], 3) == 0)
p->types[i] = USDT_ARGTYPE_INTEGER;
}
for (i = 0; i < argc; i++)
p->types[i] = strdup(types[i]);

return (p);
}
Expand Down
7 changes: 1 addition & 6 deletions usdt.h
Expand Up @@ -5,11 +5,6 @@
#include <stdint.h>
#include <unistd.h>

typedef uint8_t usdt_argtype_t;
#define USDT_ARGTYPE_NONE 0
#define USDT_ARGTYPE_STRING 1
#define USDT_ARGTYPE_INTEGER 2

#define USDT_ARG_MAX 32

typedef enum usdt_error {
Expand All @@ -35,7 +30,7 @@ typedef struct usdt_probedef {
const char *name;
const char *function;
size_t argc;
usdt_argtype_t types[USDT_ARG_MAX];
char *types[USDT_ARG_MAX];
struct usdt_probe *probe;
struct usdt_probedef *next;
int refcnt;
Expand Down
12 changes: 1 addition & 11 deletions usdt_dof_sections.c
Expand Up @@ -23,17 +23,7 @@ usdt_dof_probes_sect(usdt_dof_section_t *probes,
type = 0;

for (i = 0; i < pd->argc; i++) {
switch(pd->types[i]) {
case USDT_ARGTYPE_INTEGER:
type = usdt_strtab_add(strtab, "int");
break;
case USDT_ARGTYPE_STRING:
type = usdt_strtab_add(strtab, "char *");
break;
default:
break;
}

type = usdt_strtab_add(strtab, pd->types[i]);
argc++;
if (argv == 0)
argv = type;
Expand Down

0 comments on commit 0b92ee7

Please sign in to comment.