|
@@ -1427,7 +1427,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
|
|
{
|
|
{
|
|
struct map *map = args->map;
|
|
struct map *map = args->map;
|
|
struct dso *dso = map->dso;
|
|
struct dso *dso = map->dso;
|
|
- char command[PATH_MAX * 2];
|
|
|
|
|
|
+ char *command;
|
|
FILE *file;
|
|
FILE *file;
|
|
char symfs_filename[PATH_MAX];
|
|
char symfs_filename[PATH_MAX];
|
|
struct kcore_extract kce;
|
|
struct kcore_extract kce;
|
|
@@ -1468,7 +1468,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
|
|
strcpy(symfs_filename, tmp);
|
|
strcpy(symfs_filename, tmp);
|
|
}
|
|
}
|
|
|
|
|
|
- snprintf(command, sizeof(command),
|
|
|
|
|
|
+ err = asprintf(&command,
|
|
"%s %s%s --start-address=0x%016" PRIx64
|
|
"%s %s%s --start-address=0x%016" PRIx64
|
|
" --stop-address=0x%016" PRIx64
|
|
" --stop-address=0x%016" PRIx64
|
|
" -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
|
|
" -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
|
|
@@ -1481,12 +1481,17 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
|
|
symbol_conf.annotate_src ? "-S" : "",
|
|
symbol_conf.annotate_src ? "-S" : "",
|
|
symfs_filename, symfs_filename);
|
|
symfs_filename, symfs_filename);
|
|
|
|
|
|
|
|
+ if (err < 0) {
|
|
|
|
+ pr_err("Failure allocating memory for the command to run\n");
|
|
|
|
+ goto out_remove_tmp;
|
|
|
|
+ }
|
|
|
|
+
|
|
pr_debug("Executing: %s\n", command);
|
|
pr_debug("Executing: %s\n", command);
|
|
|
|
|
|
err = -1;
|
|
err = -1;
|
|
if (pipe(stdout_fd) < 0) {
|
|
if (pipe(stdout_fd) < 0) {
|
|
pr_err("Failure creating the pipe to run %s\n", command);
|
|
pr_err("Failure creating the pipe to run %s\n", command);
|
|
- goto out_remove_tmp;
|
|
|
|
|
|
+ goto out_free_command;
|
|
}
|
|
}
|
|
|
|
|
|
pid = fork();
|
|
pid = fork();
|
|
@@ -1513,7 +1518,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
|
|
* If we were using debug info should retry with
|
|
* If we were using debug info should retry with
|
|
* original binary.
|
|
* original binary.
|
|
*/
|
|
*/
|
|
- goto out_remove_tmp;
|
|
|
|
|
|
+ goto out_free_command;
|
|
}
|
|
}
|
|
|
|
|
|
nline = 0;
|
|
nline = 0;
|
|
@@ -1541,6 +1546,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
|
|
|
|
|
|
fclose(file);
|
|
fclose(file);
|
|
err = 0;
|
|
err = 0;
|
|
|
|
+out_free_command:
|
|
|
|
+ free(command);
|
|
out_remove_tmp:
|
|
out_remove_tmp:
|
|
close(stdout_fd[0]);
|
|
close(stdout_fd[0]);
|
|
|
|
|
|
@@ -1554,7 +1561,7 @@ out:
|
|
|
|
|
|
out_close_stdout:
|
|
out_close_stdout:
|
|
close(stdout_fd[1]);
|
|
close(stdout_fd[1]);
|
|
- goto out_remove_tmp;
|
|
|
|
|
|
+ goto out_free_command;
|
|
}
|
|
}
|
|
|
|
|
|
static void calc_percent(struct sym_hist *hist,
|
|
static void calc_percent(struct sym_hist *hist,
|