diff --git a/defs.h b/defs.h index 94346b0..1d70c6e 100644 --- a/defs.h +++ b/defs.h @@ -4441,6 +4441,7 @@ int console_verbatim(char *); int whitespace(int); int ascii(int); int ascii_string(char *); +int printable_string(char *); char *clean_line(char *); char *strip_line_end(char *); char *strip_linefeeds(char *); diff --git a/kernel.c b/kernel.c index d3dc291..dbba05a 100644 --- a/kernel.c +++ b/kernel.c @@ -204,7 +204,9 @@ kernel_init() MEMBER_OFFSET_INIT(timekeeper_xtime, "timekeeper", "xtime"); MEMBER_OFFSET_INIT(timekeeper_xtime_sec, "timekeeper", "xtime_sec"); get_xtime(&kt->date); - + if (CRASHDEBUG(1)) + fprintf(fp, "xtime timespec.tv_sec: %lx: %s\n", + kt->date.tv_sec, strip_linefeeds(ctime(&kt->date.tv_sec))); if (kt->flags2 & GET_TIMESTAMP) { fprintf(fp, "%s\n\n", strip_linefeeds(ctime(&kt->date.tv_sec))); @@ -222,6 +224,22 @@ kernel_init() else error(INFO, "cannot access utsname information\n\n"); + if (CRASHDEBUG(1)) { + fprintf(fp, "utsname:\n"); + fprintf(fp, " sysname: %s\n", printable_string(kt->utsname.sysname) ? + kt->utsname.sysname : "(not printable)"); + fprintf(fp, " nodename: %s\n", printable_string(kt->utsname.nodename) ? + kt->utsname.nodename : "(not printable)"); + fprintf(fp, " release: %s\n", printable_string(kt->utsname.release) ? + kt->utsname.release : "(not printable)"); + fprintf(fp, " version: %s\n", printable_string(kt->utsname.version) ? + kt->utsname.version : "(not printable)"); + fprintf(fp, " machine: %s\n", printable_string(kt->utsname.machine) ? + kt->utsname.machine : "(not printable)"); + fprintf(fp, " domainname: %s\n", printable_string(kt->utsname.domainname) ? + kt->utsname.domainname : "(not printable)"); + } + strncpy(buf, kt->utsname.release, MIN(strlen(kt->utsname.release), 65)); if (ascii_string(kt->utsname.release)) { char separator; @@ -864,13 +882,16 @@ cpu_maps_init(void) } if (CRASHDEBUG(1)) { - fprintf(fp, "cpu_%s_%s: ", mapinfo[m].name, - cpu_map_type(mapinfo[m].name)); - for (i = 0; i < NR_CPUS; i++) { - if (kt->cpu_flags[i] & mapinfo[m].cpu_flag) + fprintf(fp, "%scpu_%s_%s: cpus: ", + space(strlen("possible")-strlen(mapinfo[m].name)), + mapinfo[m].name, cpu_map_type(mapinfo[m].name)); + for (i = c = 0; i < NR_CPUS; i++) { + if (kt->cpu_flags[i] & mapinfo[m].cpu_flag) { fprintf(fp, "%d ", i); + c++; + } } - fprintf(fp, "\n"); + fprintf(fp, "%s\n", c ? "" : "(none)"); } } @@ -5468,7 +5489,7 @@ get_NR_syscalls(int *confirmed) void dump_kernel_table(int verbose) { - int i, j, more, nr_cpus; + int i, c, j, more, nr_cpus; struct new_utsname *uts; int others; @@ -5690,42 +5711,50 @@ dump_kernel_table(int verbose) } } fprintf(fp, "\n"); - fprintf(fp, " cpu_possible_map: "); + fprintf(fp, " possible cpus: "); if (cpu_map_addr("possible")) { - for (i = 0; i < nr_cpus; i++) { - if (kt->cpu_flags[i] & POSSIBLE_MAP) + for (i = c = 0; i < nr_cpus; i++) { + if (kt->cpu_flags[i] & POSSIBLE_MAP) { fprintf(fp, "%d ", i); + c++; + } } - fprintf(fp, "\n"); + fprintf(fp, "%s\n", c ? "" : "(none)"); } else - fprintf(fp, "(does not exist)\n"); - fprintf(fp, " cpu_present_map: "); + fprintf(fp, "(nonexistent)\n"); + fprintf(fp, " present cpus: "); if (cpu_map_addr("present")) { - for (i = 0; i < nr_cpus; i++) { - if (kt->cpu_flags[i] & PRESENT_MAP) + for (i = c = 0; i < nr_cpus; i++) { + if (kt->cpu_flags[i] & PRESENT_MAP) { fprintf(fp, "%d ", i); + c++; + } } - fprintf(fp, "\n"); + fprintf(fp, "%s\n", c ? "" : "(none)"); } else - fprintf(fp, "(does not exist)\n"); - fprintf(fp, " cpu_online_map: "); + fprintf(fp, "(nonexistent)\n"); + fprintf(fp, " online cpus: "); if (cpu_map_addr("online")) { - for (i = 0; i < nr_cpus; i++) { - if (kt->cpu_flags[i] & ONLINE_MAP) + for (i = c = 0; i < nr_cpus; i++) { + if (kt->cpu_flags[i] & ONLINE_MAP) { fprintf(fp, "%d ", i); + c++; + } } - fprintf(fp, "\n"); + fprintf(fp, "%s\n", c ? "" : "(none)"); } else - fprintf(fp, "(does not exist)\n"); - fprintf(fp, " cpu_active_map: "); + fprintf(fp, "(nonexistent)\n"); + fprintf(fp, " active cpus: "); if (cpu_map_addr("active")) { - for (i = 0; i < nr_cpus; i++) { - if (kt->cpu_flags[i] & ACTIVE_MAP) + for (i = c = 0; i < nr_cpus; i++) { + if (kt->cpu_flags[i] & ACTIVE_MAP) { fprintf(fp, "%d ", i); + c++; + } } - fprintf(fp, "\n"); + fprintf(fp, "%s\n", c ? "" : "(none)"); } else - fprintf(fp, "(does not exist)\n"); + fprintf(fp, "(nonexistent)\n"); no_cpu_flags: fprintf(fp, " vmcoreinfo: \n"); diff --git a/tools.c b/tools.c index 8fcdc90..61fa276 100644 --- a/tools.c +++ b/tools.c @@ -1103,7 +1103,7 @@ extract_hex(char *s, ulong *result, char stripchar, ulong first_instance) /* - * Determine whether a string contains only printable ASCII characters. + * Determine whether a string contains only ASCII characters. */ int ascii_string(char *s) @@ -1118,6 +1118,22 @@ ascii_string(char *s) return TRUE; } +/* + * Check whether a string contains only printable ASCII characters. + */ +int +printable_string(char *s) +{ + char *p; + + for (p = &s[0]; *p; p++) { + if (!isprint(*p)) + return FALSE; + } + + return TRUE; +} + /* * Determine whether a string contains only hexadecimal characters.