diff -Nur ksymoops-2.4.2/Changelog ksymoops-2.4.3/Changelog --- ksymoops-2.4.2/Changelog Wed Aug 29 16:27:43 2001 +++ ksymoops-2.4.3/Changelog Fri Sep 21 18:48:33 2001 @@ -1,3 +1,10 @@ +2001-09-21 Keith Owens + + ksymoops 2.4.3 + + * Add Pid:. + * Add -A "address list". Idea pinched from Randy Dunlap's ksysmap. + 2001-08-29 Keith Owens ksymoops 2.4.2 diff -Nur ksymoops-2.4.2/ksymoops.8 ksymoops-2.4.3/ksymoops.8 --- ksymoops-2.4.2/ksymoops.8 Wed Aug 29 16:29:50 2001 +++ ksymoops-2.4.3/ksymoops.8 Fri Sep 21 18:48:33 2001 @@ -1,4 +1,4 @@ -.TH KSYMOOPS 8 "August 2001" +.TH KSYMOOPS 8 "September 2001" .hy 0 .UC 4 .SH NAME @@ -67,6 +67,9 @@ [\ \fB-a\ \fIarchitecture\fR\ ] [\ \fB--architecture=\fIarchitecture\fR\ ] .br +[\ \fB-A\ \fI"address list"\fR\ ] +[\ \fB--addresses=\fI"address list"\fR\ ] +.br [\ \fIOops.file\ ...\fR\ ] .SH DESCRIPTION ksymoops extracts kernel Oops reports from the Oops.file and uses @@ -427,11 +430,20 @@ compiled for sparc and the Oops contains a TPC line then ksymoops automatically switches to -a\ sparcv:9a. .TP +\fB-A\ \fI"address list"\fR\ \fB--addresses=\fI"address list"\fR If you +have a few adhoc addresses to convert to symbols, you can specify them +explicitly using \fB-A\ \fI"address list"\fR. Any words in the list +that appear to be addresses are converted to symbols. Punctuation +characters and non-address words are silently ignored, leading 0x on +addresses is also ignored, so you can paste text including words and +only the addresses will be processed. +.TP \fBOops.file\ ...\fR ksymoops accepts zero or more input files and reads them all. If no -files are specified on the command line, ksymoops reads from standard -input. You can even type the Oops text directly at the terminal, -although that is not recommended. +files are specified on the command line and no addresses are supplied +via \fB-A\fR then ksymoops reads from standard input. You can even +type the Oops text directly at the terminal, although that is not +recommended. .SH INPUT .P ksymoops reads the input file(s), using regular expressions to select diff -Nur ksymoops-2.4.2/ksymoops.c ksymoops-2.4.3/ksymoops.c --- ksymoops-2.4.2/ksymoops.c Wed Aug 29 16:27:43 2001 +++ ksymoops-2.4.3/ksymoops.c Sat Sep 22 11:43:09 2001 @@ -9,7 +9,7 @@ Released under the GNU Public Licence, Version 2. */ -#define VERSION "2.4.2" +#define VERSION "2.4.3" #include "ksymoops.h" #include @@ -56,9 +56,8 @@ static void usage(void) { - printf("Version " VERSION "\n"); - printf("usage: %s\n", prefix); - printf("\t[-v vmlinux] [--vmlinux=vmlinux]\n\t\t\t\t\tWhere to read vmlinux\n" + static const char usage_text[] = + "\t[-v vmlinux] [--vmlinux=vmlinux]\n\t\t\t\t\tWhere to read vmlinux\n" "\t[-V] [--no-vmlinux]\t\tNo vmlinux is available\n" "\t[-k ksyms] [--ksyms=ksyms]\tWhere to read ksyms\n" "\t[-K] [--no-ksyms]\t\tNo ksyms is available\n" @@ -79,11 +78,12 @@ "\t[-h] [--help]\t\t\tPrint help text\n" "\t[-t target] [--target=target]\tTarget of oops log\n" "\t[-a architecture] [--architecture=architecture]\n\t\t\t\t\tArchitecture of oops log\n" + "\t[-A \"address list\"] [--addresses=\"address list\"]\n\t\t\t\t\tAdhoc addresses to decode\n" "\t< Oops.file\t\t\tOops report to decode\n" "\n" "\t\tAll flags can occur more than once. With the exception " - "of -o\n" - "\t\tand -d which are cumulative, the last occurrence of each " + "of -o,\n" + "\t\t-d and -A which are cumulative, the last occurrence of each " "flag is\n" "\t\tused. Note that \"-v my.vmlinux -V\" will be taken as " "\"No vmlinux\n" @@ -145,7 +145,10 @@ #endif "\n" "\n" - ); + ; + printf("Version " VERSION "\n"); + printf("usage: %s\n", prefix); + printf("%s", usage_text); } /* Check if possibly conflicting options were specified */ @@ -243,6 +246,46 @@ printf(" (default)\n"); } +/* Extract adhoc addresses from a string and save for later. + * An address is a string of at least 4 hex digits delimited by white space or + * punctuation marks, possibly prefixed by 0x or 0X. + */ +static void adhoc_addresses(struct options *options, const unsigned char *string) +{ + int count, start; + const unsigned char *p = string, *p1; + char *address; + while (*p) { + while (*p && !isxdigit(*p)) + ++p; + if (!*p) + continue; + start = p == string || isspace(*(p-1)) || ispunct(*(p-1)); + if (!start && p >= string+2 && *(p-2) == '0' && (*(p-1) == 'x' || *(p-1) == 'X')) { + start = p == string+2 || isspace(*(p-3)) || ispunct(*(p-3)); + } + if (!start) { + ++p; + continue; + } + p1 = p; + while (isxdigit(*++p)) {}; + if (p-p1 < 4) + continue; + address = malloc(p-p1+1); + if (!address) + malloc_error("adhoc_addresses"); + memcpy(address, p1, p-p1); + address[p-p1] = '\0'; + for (count = 0; options->adhoc_addresses && options->adhoc_addresses[count]; ++count) {}; + options->adhoc_addresses = realloc(options->adhoc_addresses, (count+2)*sizeof(options->adhoc_addresses)); + if (!options->adhoc_addresses) + malloc_error("adhoc_addresses"); + options->adhoc_addresses[count] = address; + options->adhoc_addresses[count+1] = NULL; + } +} + /* Parse the options. Verbose but what's new with getopt? */ static void parse(int argc, char **argv, struct options *options, int *spec_h) { @@ -277,13 +320,14 @@ {"help", 0, 0, 'h'}, {"target", 1, 0, 't'}, {"architecture", 1, 0, 'a'}, + {"addresses", 1, 0, 'A'}, {0, 0, 0, 0} }; int c, i, some_spec = 0; char *p, *before; - while ((c = getopt_long(argc, argv, "v:Vk:Kl:Lo:Om:Ms:e1xSiIT:hdt:a:", + while ((c = getopt_long(argc, argv, "v:Vk:Kl:Lo:Om:Ms:e1xSiIT:hdt:a:A:", long_opts, NULL)) != EOF) { if (c != 'd') DEBUG(1, "'%c' '%s'", c, optarg); @@ -393,6 +437,9 @@ case 'a': options->architecture = optarg; break; + case 'A': + adhoc_addresses(options, optarg); + break; case '?': if (c == 'c') printf("Option -c is obsolete, use -e toggle instead\n"); @@ -404,6 +451,13 @@ options->filecount = argc - optind; options->filename = argv + optind; + if (options->adhoc_addresses && !options->filecount) { + static char *null = "/dev/null"; + static char **null_list = { &null }; + options->filecount = 1; + options->filename = null_list; + } + /* Expand any requests for the current uname values */ convert_uname(&options->vmlinux); if (options->objects) { @@ -617,6 +671,7 @@ 0, /* truncate */ NULL, /* target */ NULL, /* architecture */ + NULL, /* addresses */ 0 /* address_bits */ }; static char const procname[] = "main"; diff -Nur ksymoops-2.4.2/ksymoops.h ksymoops-2.4.3/ksymoops.h --- ksymoops-2.4.2/ksymoops.h Wed Aug 29 16:27:43 2001 +++ ksymoops-2.4.3/ksymoops.h Fri Sep 21 18:48:33 2001 @@ -166,6 +166,7 @@ int truncate; const char *target; const char *architecture; + char **adhoc_addresses; int address_bits; /* not an option, derived from architecture */ }; diff -Nur ksymoops-2.4.2/ksymoops.spec ksymoops-2.4.3/ksymoops.spec --- ksymoops-2.4.2/ksymoops.spec Sat Mar 17 13:05:18 2001 +++ ksymoops-2.4.3/ksymoops.spec Sat Sep 22 11:45:20 2001 @@ -1,7 +1,7 @@ Summary: Kernel oops and error message decoder Name: ksymoops -Version: 2.4.2 -Release: 1 +Version: 2.4.3 +Release: 2 Copyright: GPL Group: Utilities/System Source: ksymoops-%{version}.tar.gz diff -Nur ksymoops-2.4.2/oops.c ksymoops-2.4.3/oops.c --- ksymoops-2.4.2/oops.c Wed Aug 29 16:27:43 2001 +++ ksymoops-2.4.3/oops.c Fri Sep 21 18:48:33 2001 @@ -1639,6 +1639,7 @@ /* various */ "|In swapper task" /* various */ "|kmem_free" /* various */ "|swapper" + /* various */ "|Pid:" /* i386 2.0 */ "|Corrupted stack page" /* i386 */ "|invalid operand: " @@ -2063,7 +2064,8 @@ if (f) fclose_local(f, procname); f = NULL; - if (regular_file(*(options->filename), procname)) + if (strcmp(*(options->filename), "/dev/null") == 0 || + regular_file(*(options->filename), procname)) f = fopen_local(*(options->filename), "r", procname); if (f) DEBUG(1, "reading Oops report from %s", *(options->filename)); @@ -2092,6 +2094,13 @@ ss_init(&ss_format, "Oops log data"); Oops_open_input_bfd(&me, &ibfd, options); + if (options->adhoc_addresses) { + char **adhoc; + for (adhoc = options->adhoc_addresses; *adhoc; ++adhoc) { + add_symbol(&ss_format, *adhoc, 'A', 1, "Adhoc"); + } + } + if (!options->filecount && isatty(0)) printf("Reading Oops report from the terminal\n"); @@ -2193,7 +2202,7 @@ strstr(options->target, "sparc") == 0 && sparc_regdump) ; /* sparc regdump comes *after* code, ignore :( */ - else + else if (!options->adhoc_addresses) WARNING("%s", "Code line not seen, dumping what data is available"); Oops_format(&ss_format, options); ss_free(&ss_format); diff -Nur ksymoops-2.4.2/re.c ksymoops-2.4.3/re.c --- ksymoops-2.4.2/re.c Sat Mar 17 12:18:28 2001 +++ ksymoops-2.4.3/re.c Fri Sep 21 18:48:33 2001 @@ -10,6 +10,7 @@ #include "ksymoops.h" #include +#include #include /* Compile a regular expression */