diff --git a/dwarves.c b/dwarves.c index b59f09a..59e303c 100644 --- a/dwarves.c +++ b/dwarves.c @@ -2670,19 +2670,37 @@ static debugging_format_loader_t debugging_formats__loader(const char *name) int cus__load(struct cus *self, struct conf_load *conf, char *filename) { - int i = 0; + int i = 0, err = 0; debugging_format_loader_t loader; if (conf && conf->format_path != NULL) { - while (conf->format_path[i] != NULL) { - loader = debugging_formats__loader(conf->format_path[i]); + char *fpath = strdup(conf->format_path); + if (fpath == NULL) + return -ENOMEM; + char *fp = fpath; + while (1) { + char *sep = strchr(fp, ','); + + if (sep != NULL) + *sep = '\0'; + + err = -ENOTSUP; + loader = debugging_formats__loader(fp); if (loader == NULL) - return -ENOTSUP; + break; + + err = 0; if (loader(self, conf, filename) == 0) - return 0; - ++i; + break; + + err = -EINVAL; + if (sep == NULL) + break; + + fp = sep + 1; } - return -EINVAL; + free(fpath); + return err; } while (debugging_formats__table[i].name != NULL) { diff --git a/dwarves.h b/dwarves.h index 4997aa8..627bc69 100644 --- a/dwarves.h +++ b/dwarves.h @@ -38,7 +38,7 @@ struct conf_load { enum load_steal_kind (*steal)(struct cu *self, struct conf_load *conf); void *cookie; - char **format_path; + char *format_path; }; struct conf_fprintf { diff --git a/man-pages/pahole.1 b/man-pages/pahole.1 index b2c1f00..7e6c36c 100644 --- a/man-pages/pahole.1 +++ b/man-pages/pahole.1 @@ -49,6 +49,12 @@ Set cacheline size to SIZE bytes. Expand class members. Useful to find in what member of inner structs where an offset from the beginning of a struct is. +.TP +.B \-F, \-\-format_path +Allows specifying a list of debugging formats to try, in order. Right now this +includes "ctf" and "dwarf". The default format path used is equivalent to +"-F dwarf,ctf". + .TP .B \-r, \-\-rel_offset Show relative offsets of members in inner structs. diff --git a/pahole.c b/pahole.c index a63b9ff..8710f0d 100644 --- a/pahole.c +++ b/pahole.c @@ -728,6 +728,12 @@ static const struct argp_option pahole__options[] = { .arg = "CLASS_NAME", .doc = "Find pointers to CLASS_NAME" }, + { + .name = "format_path", + .key = 'F', + .arg = "FORMAT_LIST", + .doc = "List of debugging formats to try" + }, { .name = "contains", .key = 'i', @@ -919,6 +925,7 @@ static error_t pahole__options_parser(int key, char *arg, case 'E': conf.expand_types = 1; break; case 'f': find_pointers_in_structs = 1; class_name = arg; break; + case 'F': conf_load.format_path = arg; break; case 'H': nr_holes = atoi(arg); break; case 'I': conf.show_decl_info = 1; conf_load.extra_dbg_info = 1; break;