dwarves: Introduce cus__fprintf_load_files_err()
Out of code in pdwtags and pahole, will be used in the other tools. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
0e64636350
commit
10515a7c4d
|
@ -1495,6 +1495,13 @@ int cus__load_files(struct cus *cus, struct conf_load *conf,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cus__fprintf_load_files_err(struct cus *cus, const char *tool, char *argv[], int err, FILE *output)
|
||||
{
|
||||
/* errno is not properly preserved in some cases, sigh */
|
||||
return fprintf(output, "%s: %s: %s\n", tool, argv[-err - 1],
|
||||
errno ? strerror(errno) : "No debugging information found");
|
||||
}
|
||||
|
||||
struct cus *cus__new(void)
|
||||
{
|
||||
struct cus *cus = malloc(sizeof(*cus));
|
||||
|
|
|
@ -84,6 +84,8 @@ int cus__load_file(struct cus *cus, struct conf_load *conf,
|
|||
const char *filename);
|
||||
int cus__load_files(struct cus *cus, struct conf_load *conf,
|
||||
char *filenames[]);
|
||||
int cus__fprintf_load_files_err(struct cus *cus, const char *tool,
|
||||
char *argv[], int err, FILE *output);
|
||||
int cus__load_dir(struct cus *cus, struct conf_load *conf,
|
||||
const char *dirname, const char *filename_mask,
|
||||
const int recursive);
|
||||
|
|
4
pahole.c
4
pahole.c
|
@ -1249,9 +1249,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
err = cus__load_files(cus, &conf_load, argv + remaining);
|
||||
if (err != 0) {
|
||||
/* errno is not properly preserved in some cases, sigh */
|
||||
fprintf(stderr, "pahole: %s: %s\n", argv[remaining + -err - 1],
|
||||
errno ? strerror(errno) : "No debugging information found");
|
||||
cus__fprintf_load_files_err(cus, "pahole", argv + remaining, err, stderr);
|
||||
goto out_cus_delete;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue