improve cli scan command

This commit is contained in:
Stefani Seibold 2015-05-15 09:35:22 +02:00
parent 046b2003dc
commit 44e172dee9
2 changed files with 25 additions and 19 deletions

View File

@ -358,12 +358,6 @@ static void stack_resolv(struct process *process, struct stack *stack)
for(i = 0; i < stack->entries; ++i) { for(i = 0; i < stack->entries; ++i) {
unsigned long addr = process->get_ulong(addrs); unsigned long addr = process->get_ulong(addrs);
if (!addr) {
stack->syms[i] = NULL;
continue;
}
stack->syms[i] = resolv_address(process, addr); stack->syms[i] = resolv_address(process, addr);
addrs += process->ptr_size; addrs += process->ptr_size;

View File

@ -161,7 +161,7 @@ static struct cmd_opt cmds[] = {
2, 2,
do_scan, do_scan,
"scan new memory leaks", "scan new memory leaks",
"[<pid>]", "[mode] [<pid>]",
scan_opts scan_opts
}, },
{ {
@ -689,17 +689,14 @@ static int do_scan(struct cmd_opt *cmd, int argc, const char *argv[])
if (!client_connected()) if (!client_connected())
return -1; return -1;
process = get_process(argv[1]); if (!argv[1]) {
if (!process) process = client_first_process();
return -1; if (!process) {
fprintf(stderr, "no process available\n");
if (!process->tracing) { return -1;
fprintf(stderr, "scan can only performed in tracing state!\n"); }
return -1;
}
if (argc == 1)
mode = SCAN_ALL; mode = SCAN_ALL;
}
else { else {
mode = -1; mode = -1;
@ -713,12 +710,27 @@ static int do_scan(struct cmd_opt *cmd, int argc, const char *argv[])
} }
if (mode < 0) { if (mode < 0) {
fprintf(stderr, "%s: unknown scan mode\n", cmd->name); process = client_find_process(atoi(argv[1]));
return -1; if (!process) {
fprintf(stderr, "%s: unknown scan mode\n", cmd->name);
return -1;
}
mode = SCAN_ALL;
}
else {
process = get_process(argv[2]);
if (!process)
return -1;
} }
} }
if (!process->tracing) {
fprintf(stderr, "scan can only performed in tracing state!\n");
return -1;
}
leaks_scan(process, mode); leaks_scan(process, mode);
return 0; return 0;
} }