debuggers.hg

changeset 22754:7926538a6332

xenctx: misc adjustments

- fix off-by-one errors during symbol insertion and lookup
- don't store the symbol type, as it wasn't needed at all so far and
is only needed now at parsing time
- don't insert certain kinds of symbols

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir@xen.org>
date Tue Jan 11 11:41:39 2011 +0000 (2011-01-11)
parents 2ff199e2842b
children ae51abc964ee
files tools/xentrace/xenctx.c
line diff
     1.1 --- a/tools/xentrace/xenctx.c	Tue Jan 11 11:40:50 2011 +0000
     1.2 +++ b/tools/xentrace/xenctx.c	Tue Jan 11 11:41:39 2011 +0000
     1.3 @@ -19,6 +19,7 @@
     1.4  #include <unistd.h>
     1.5  #include <errno.h>
     1.6  #include <signal.h>
     1.7 +#include <ctype.h>
     1.8  #include <string.h>
     1.9  #include <inttypes.h>
    1.10  #include <getopt.h>
    1.11 @@ -58,7 +59,6 @@ int disp_tlb;
    1.12  
    1.13  struct symbol {
    1.14      guest_word_t address;
    1.15 -    char type;
    1.16      char *name;
    1.17      struct symbol *next;
    1.18  } *symbol_table = NULL;
    1.19 @@ -112,12 +112,12 @@ static void insert_symbol(struct symbol 
    1.20  
    1.21      /* The System.map is usually already sorted... */
    1.22      if (prev
    1.23 -        && prev->address < symbol->address
    1.24 +        && prev->address <= symbol->address
    1.25          && (!prev->next || prev->next->address > symbol->address)) {
    1.26          s = prev;
    1.27      } else {
    1.28          /* ... otherwise do crappy/slow search for the correct place */
    1.29 -        while(s && s->next && s->next->address < symbol->address)
    1.30 +        while (s->next && s->next->address <= symbol->address)
    1.31              s = s->next;
    1.32      }
    1.33  
    1.34 @@ -130,13 +130,13 @@ static struct symbol *lookup_symbol(gues
    1.35  {
    1.36      struct symbol *s = symbol_table;
    1.37  
    1.38 -    while(s && s->next && s->next->address < address)
    1.39 +    if (!s)
    1.40 +        return NULL;
    1.41 +
    1.42 +    while (s->next && s->next->address < address)
    1.43          s = s->next;
    1.44  
    1.45 -    if (s && s->address < address)
    1.46 -        return s;
    1.47 -
    1.48 -    return NULL;
    1.49 +    return s->next && s->next->address <= address ? s->next : s;
    1.50  }
    1.51  
    1.52  static void print_symbol(guest_word_t addr)
    1.53 @@ -159,7 +159,7 @@ static void print_symbol(guest_word_t ad
    1.54  
    1.55  static void read_symbol_table(const char *symtab)
    1.56  {
    1.57 -    char line[256];
    1.58 +    char type, line[256];
    1.59      char *p;
    1.60      struct symbol *symbol;
    1.61      FILE *f;
    1.62 @@ -178,9 +178,13 @@ static void read_symbol_table(const char
    1.63  
    1.64          /* need more checks for syntax here... */
    1.65          symbol->address = strtoull(line, &p, 16);
    1.66 -        p++;
    1.67 -        symbol->type = *p++;
    1.68 -        p++;
    1.69 +        if (!isspace(*p++))
    1.70 +            continue;
    1.71 +        type = *p++;
    1.72 +        if (!isalpha(type) && type != '?')
    1.73 +            continue;
    1.74 +        if (!isspace(*p++))
    1.75 +            continue;
    1.76  
    1.77          /* in the future we should handle the module name
    1.78           * being appended here, this would allow us to use
    1.79 @@ -190,7 +194,18 @@ static void read_symbol_table(const char
    1.80              p[strlen(p)-1] = '\0';
    1.81          symbol->name = strdup(p);
    1.82  
    1.83 -        insert_symbol(symbol);
    1.84 +        switch (type) {
    1.85 +        case 'A': /* global absolute */
    1.86 +        case 'a': /* local absolute */
    1.87 +            break;
    1.88 +        case 'U': /* undefined */
    1.89 +        case 'v': /* undefined weak object */
    1.90 +        case 'w': /* undefined weak function */
    1.91 +            continue;
    1.92 +        default:
    1.93 +            insert_symbol(symbol);
    1.94 +            break;
    1.95 +        }
    1.96  
    1.97          if (strcmp(symbol->name, "_stext") == 0)
    1.98              kernel_stext = symbol->address;