From 7970712f70757f47931f0b1a851ed96dfaf6cfcf Mon Sep 17 00:00:00 2001 From: Stefani Seibold Date: Wed, 18 Apr 2018 08:43:17 +0200 Subject: [PATCH] minor fixes --- options.c | 11 ++++++----- options.h | 4 ++-- task.c | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/options.c b/options.c index a9cf5ee..95d6937 100644 --- a/options.c +++ b/options.c @@ -122,11 +122,12 @@ static void usage_debug(void) fprintf(stdout, "%s debugging option, --debug= or -D:\n", progname); fprintf(stdout, "\n" - " number ref. in source description\n" - " 1 general Generally helpful progress information\n" - " 10 event Shows every event received by a traced process\n" - " 20 process Shows actions carried upon a traced processes\n" - " 40 function Shows every entry to internal functions\n" + " number description\n" + " 1 ptrace events\n" + " 2 dwarf issues\n" + " 4 Shows every event received by a traced process\n" + " 8 Shows actions carried upon a traced processes\n" + " 16 Shows every entry to internal functions\n" "\n" "Debugging options are mixed using bitwise-or.\n" "Note that the meanings and values are subject to change.\n" diff --git a/options.h b/options.h index b363208..992a19a 100644 --- a/options.h +++ b/options.h @@ -40,8 +40,6 @@ #define OPT_SORT_MISMATCHED 8 #define OPT_SORT_BADFREE 9 -struct options_t options; - struct opt_p_t { pid_t pid; struct opt_p_t *next; @@ -92,6 +90,8 @@ struct options_t { int lflag; /* long dump */ }; +struct options_t options; + char **process_options(int argc, char **argv); #endif diff --git a/task.c b/task.c index e35ecc7..421812e 100644 --- a/task.c +++ b/task.c @@ -112,18 +112,29 @@ static inline void insert_pid(struct task *task) { unsigned int pidhash = PID_HASH(task->pid); struct pid_hash *entry = pid_hash[pidhash]; + unsigned long int size; if (!entry) { - entry = malloc(sizeof(*entry) + 8 * sizeof(entry->tasks[0])); + size = 8; + + entry = malloc(sizeof(*entry) + size * sizeof(entry->tasks[0])); + if (!entry) + abort(); + entry->num = 0; - entry->size = 8; + entry->size = size; pid_hash[pidhash] = entry; } else if (entry->size == entry->num) { - entry->size += 8; - entry = realloc(entry, sizeof(*entry) + entry->size * sizeof(entry->tasks[0])); + size = entry->size + 8; + + entry = realloc(entry, sizeof(*entry) + size * sizeof(entry->tasks[0])); + if (!entry) + abort(); + + entry->size = size; pid_hash[pidhash] = entry; }