mirror of
https://github.com/sstefani/mtrace.git
synced 2025-12-06 16:56:41 +08:00
fix interactive long dump mode
fix a sigfault in interacitve long dump mode
This commit is contained in:
parent
4ec3ff85fb
commit
f837c452e3
@ -125,7 +125,7 @@ static struct cmd_opt cmds[] = {
|
|||||||
1,
|
1,
|
||||||
do_dump,
|
do_dump,
|
||||||
"dump stack trees",
|
"dump stack trees",
|
||||||
"[sort-by] [<pid>] [-l] [>filename]",
|
"[sort-by] [-l] [<pid>] [>filename]",
|
||||||
dump_opts
|
dump_opts
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -563,46 +563,34 @@ static int do_dump(struct cmd_opt *cmd, int argc, const char *argv[])
|
|||||||
int arg = 1;
|
int arg = 1;
|
||||||
int lflag = 0;
|
int lflag = 0;
|
||||||
|
|
||||||
if (!argv[arg]) {
|
data = NULL;
|
||||||
process = client_first_process();
|
|
||||||
if (!process) {
|
if (argc > arg) {
|
||||||
fprintf(stderr, "no process available\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
data = process_dump_sort_allocations;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data = NULL;
|
|
||||||
len = strlen(argv[arg]);
|
len = strlen(argv[arg]);
|
||||||
|
|
||||||
for(i = 0; options[i].name; ++i) {
|
for(i = 0; options[i].name; ++i) {
|
||||||
if (options[i].match_len <= len && !strncmp(options[i].name, argv[1], len)) {
|
if (options[i].match_len <= len && !strncmp(options[i].name, argv[1], len)) {
|
||||||
data = options[i].data;
|
data = options[i].data;
|
||||||
arg++;
|
++arg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (argc > arg) {
|
||||||
process = client_find_process(atoi(argv[arg++]));
|
if (!strcmp(argv[arg], "-l")) {
|
||||||
if (!process) {
|
lflag = 1;
|
||||||
fprintf(stderr, "%s: unknown sort criteria\n", cmd->name);
|
++arg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
data = process_dump_sort_allocations;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
process = get_process(argv[arg++]);
|
|
||||||
if (!process)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < arg) {
|
|
||||||
if (!strcmp(argv[arg], "-l"))
|
|
||||||
lflag = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process = get_process(argc > arg ? argv[arg] : NULL);
|
||||||
|
if (!process)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
data = process_dump_sort_allocations;
|
||||||
|
|
||||||
dump_stacks(process, data, outfile, lflag);
|
dump_stacks(process, data, outfile, lflag);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user