diff options
-rw-r--r-- | display_args.c | 16 | ||||
-rw-r--r-- | options.c | 18 | ||||
-rw-r--r-- | options.h | 4 | ||||
-rw-r--r-- | output.c | 4 | ||||
-rw-r--r-- | process_event.c | 2 |
5 files changed, 21 insertions, 23 deletions
diff --git a/display_args.c b/display_args.c index aade610..700e8f6 100644 --- a/display_args.c +++ b/display_args.c @@ -293,13 +293,13 @@ display_string(enum tof type, struct process *proc, void *addr, return fprintf(options.output, "NULL"); } - str1 = malloc(MIN(opt_s, maxlength) + 3); + str1 = malloc(MIN(options.strlen, maxlength) + 3); if (!str1) { return fprintf(options.output, "???"); } - umovestr(proc, addr, MIN(opt_s, maxlength) + 1, str1); + umovestr(proc, addr, MIN(options.strlen, maxlength) + 1, str1); len = fprintf(options.output, "\""); - for (i = 0; i < MIN(opt_s, maxlength); i++) { + for (i = 0; i < MIN(options.strlen, maxlength); i++) { if (str1[i]) { len += display_char(str1[i]); } else { @@ -307,7 +307,7 @@ display_string(enum tof type, struct process *proc, void *addr, } } len += fprintf(options.output, "\""); - if (str1[i] && (opt_s <= maxlength)) { + if (str1[i] && (options.strlen <= maxlength)) { len += fprintf(options.output, "..."); } free(str1); @@ -342,13 +342,13 @@ display_format(enum tof type, struct process *proc, int arg_num) { return fprintf(options.output, "NULL"); } - str1 = malloc(MIN(opt_s, string_maxlength) + 3); + str1 = malloc(MIN(options.strlen, string_maxlength) + 3); if (!str1) { return fprintf(options.output, "???"); } - umovestr(proc, addr, MIN(opt_s, string_maxlength) + 1, str1); + umovestr(proc, addr, MIN(options.strlen, string_maxlength) + 1, str1); len = fprintf(options.output, "\""); - for (i = 0; len < MIN(opt_s, string_maxlength) + 1; i++) { + for (i = 0; len < MIN(options.strlen, string_maxlength) + 1; i++) { if (str1[i]) { len += display_char(str1[i]); } else { @@ -356,7 +356,7 @@ display_format(enum tof type, struct process *proc, int arg_num) { } } len += fprintf(options.output, "\""); - if (str1[i] && (opt_s <= string_maxlength)) { + if (str1[i] && (options.strlen <= string_maxlength)) { len += fprintf(options.output, "..."); } for (i = 0; str1[i]; i++) { @@ -35,9 +35,11 @@ struct options_t options = { #endif .indent = 0, /* indent output according to program flow */ .output = NULL, /* output to a specific file */ - .summary = 0; /* Report a summary on program exit */ - .debug = 0; /* debug */ - .arraylen = DEFAULT_ARRAYLEN; /* maximum # array elements to print */ + .summary = 0, /* Report a summary on program exit */ + .debug = 0, /* debug */ + .arraylen = DEFAULT_ARRAYLEN, /* maximum # array elements to print */ + .strlen = DEFAULT_STRLEN, /* maximum # of bytes printed in strings */ + .follow = 0, /* trace child processes */ }; #define MAX_LIBRARY 30 @@ -45,8 +47,6 @@ char *library[MAX_LIBRARY]; int library_num = 0; static char *progname; /* Program name (`ltrace') */ int opt_i = 0; /* instruction pointer */ -int opt_s = DEFAULT_STRLEN; /* maximum # of bytes printed in strings */ -int opt_f = 0; /* trace child processes as they are created */ int opt_r = 0; /* print relative timestamp */ int opt_t = 0; /* print absolute timestamp */ int opt_T = 0; /* show the time spent inside each call */ @@ -100,9 +100,9 @@ usage(void) { " -e expr modify which events to trace.\n" " -f follow forks.\n" # if HAVE_GETOPT_LONG - " -F, --config=FILE load alternate configuration file (can be repeated).\n" + " -F, --config=FILE load alternate configuration file (may be repeated).\n" # else - " -F FILE load alternate configuration file (can be repeated).\n" + " -F FILE load alternate configuration file (may be repeated).\n" # endif # if HAVE_GETOPT_LONG " -h, --help display this help and exit.\n" @@ -294,7 +294,7 @@ process_options(int argc, char **argv) { break; } case 'f': - opt_f = 1; + options.follow = 1; break; case 'F': { @@ -356,7 +356,7 @@ process_options(int argc, char **argv) { opt_r++; break; case 's': - opt_s = atoi(optarg); + options.strlen = atoi(optarg); break; case 'S': options.syscalls = 1; @@ -16,12 +16,12 @@ struct options_t { int summary; /* count time, calls, and report a summary on program exit */ int debug; /* debug */ int arraylen; /* default maximum # of array elements printed */ + int strlen; /* default maximum # of bytes printed in strings */ + int follow; /* trace child processes */ }; extern struct options_t options; extern int opt_i; /* instruction pointer */ -extern int opt_s; /* default maximum # of bytes printed in strings */ -extern int opt_f; /* trace child processes */ extern int opt_r; /* print relative timestamp */ extern int opt_t; /* print absolute timestamp */ extern int opt_T; /* show the time spent inside each call */ @@ -40,9 +40,7 @@ begin_of_line(enum tof type, struct process *proc) { if (!proc) { return; } - if ((options.output != stderr) && (opt_p || opt_f)) { - current_column += fprintf(options.output, "%u ", proc->pid); - } else if (list_of_processes->next) { + if (list_of_processes->next) { current_column += fprintf(options.output, "[pid %u] ", proc->pid); } if (opt_r) { diff --git a/process_event.c b/process_event.c index db5d3bd..acb1c2c 100644 --- a/process_event.c +++ b/process_event.c @@ -267,7 +267,7 @@ process_sysret(struct event *event) { calc_time_spent(event->proc); } if (fork_p(event->proc, event->e_un.sysnum)) { - if (opt_f) { + if (options.follow) { arg_type_info info; info.type = ARGTYPE_LONG; pid_t child = |