/[gxemul]/trunk/src/symbol.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/symbol.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 39 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 40 by dpavlin, Mon Oct 8 16:22:11 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: symbol.c,v 1.37 2006/12/30 13:30:52 debug Exp $   *  $Id: symbol.c,v 1.38 2007/04/22 14:32:01 debug Exp $
29   *   *
30   *  Address to symbol translation routines.   *  Address to symbol translation routines.
31   *   *
# Line 113  char *get_symbol_name_and_n_args(struct Line 113  char *get_symbol_name_and_n_args(struct
113          uint64_t *offset, int *n_argsp)          uint64_t *offset, int *n_argsp)
114  {  {
115          struct symbol *s;          struct symbol *s;
         int stepsize, ofs;  
116    
117          if (sc->n_symbols == 0)          if (sc->n_symbols == 0)
118                  return NULL;                  return NULL;
# Line 136  char *get_symbol_name_and_n_args(struct Line 135  char *get_symbol_name_and_n_args(struct
135                                              "%s", s->name);                                              "%s", s->name);
136                                  else                                  else
137                                          snprintf(symbol_buf, SYMBOLBUF_MAX,                                          snprintf(symbol_buf, SYMBOLBUF_MAX,
138                                              "%s+0x%lx", s->name, (long)                                              "%s+0x%"PRIx64, s->name, (uint64_t)
139                                              (addr - s->addr));                                              (addr - s->addr));
140                                  if (offset != NULL)                                  if (offset != NULL)
141                                          *offset = addr - s->addr;                                          *offset = addr - s->addr;
# Line 148  char *get_symbol_name_and_n_args(struct Line 147  char *get_symbol_name_and_n_args(struct
147                  }                  }
148          } else {          } else {
149                  /*  Faster, O(log n) search:  */                  /*  Faster, O(log n) search:  */
150                  stepsize = sc->n_symbols / 2;                  int lowest = 0, highest = sc->n_symbols - 1;
151                  ofs = stepsize;                  while (lowest <= highest) {
152                  while (stepsize > 0 || (stepsize == 0 && ofs == 0)) {                          int ofs = (lowest + highest) / 2;
153                          s = sc->first_symbol + ofs;                          s = sc->first_symbol + ofs;
154    
155                          /*  Found a match?  */                          /*  Found a match?  */
# Line 160  char *get_symbol_name_and_n_args(struct Line 159  char *get_symbol_name_and_n_args(struct
159                                              "%s", s->name);                                              "%s", s->name);
160                                  else                                  else
161                                          snprintf(symbol_buf, SYMBOLBUF_MAX,                                          snprintf(symbol_buf, SYMBOLBUF_MAX,
162                                              "%s+0x%lx", s->name, (long)                                              "%s+0x%"PRIx64, s->name, (uint64_t)
163                                              (addr - s->addr));                                              (addr - s->addr));
164    
165                                  if (offset != NULL)                                  if (offset != NULL)
166                                          *offset = addr - s->addr;                                          *offset = addr - s->addr;
167                                  if (n_argsp != NULL)                                  if (n_argsp != NULL)
168                                          *n_argsp = s->n_args;                                          *n_argsp = s->n_args;
169    
170                                  return symbol_buf;                                  return symbol_buf;
171                          }                          }
172    
173                          if (ofs == 0)                          if (addr < s->addr)
174                                  break;                                  highest = ofs - 1;
175                            else
176                          stepsize >>= 1;                                  lowest = ofs + 1;
   
                         /*  Special case for offset 0 (end of search in  
                             the Left direction  */  
                         if (stepsize == 0)  
                                 ofs = 0;  
                         else {  
                                 if (addr < s->addr)  
                                         ofs -= stepsize;  
                                 else  
                                         ofs += stepsize;  
                         }  
177                  }                  }
178          }          }
179    
# Line 418  void symbol_recalc_sizes(struct symbol_c Line 408  void symbol_recalc_sizes(struct symbol_c
408                                      - tmp_array[i].addr;                                      - tmp_array[i].addr;
409                          else                          else
410                                  len = 1;                                  len = 1;
411    
412                          tmp_array[i].len = len;                          tmp_array[i].len = len;
413                  }                  }
414    

Legend:
Removed from v.39  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26