~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/resolve_stack_dump.c

  • Committer: Monty Taylor
  • Date: 2008-10-05 01:41:06 UTC
  • Revision ID: monty@inaugust.com-20081005014106-bulqe4kp7i6ipts1
Moved qsort declarations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#define INC_SYM_TABLE  4096
30
30
#define MAX_SYM_SIZE   128
31
31
#define DUMP_VERSION "1.4"
32
 
#define HEX_INVALID  (unsigned char)255
 
32
#define HEX_INVALID  (uchar)255
33
33
 
34
34
 
35
35
typedef struct sym_entry
36
36
{
37
37
  char symbol[MAX_SYM_SIZE];
38
 
  unsigned char* addr;
 
38
  uchar* addr;
39
39
} SYM_ENTRY;
40
40
 
41
41
 
166
166
 
167
167
}
168
168
 
169
 
static unsigned char hex_val(char c)
 
169
static uchar hex_val(char c)
170
170
{
171
 
  unsigned char l;
 
171
  uchar l;
172
172
  if (my_isdigit(&my_charset_utf8_general_ci,c))
173
173
    return c - '0';
174
174
  l = my_tolower(&my_charset_utf8_general_ci,c);
175
175
  if (l < 'a' || l > 'f')
176
176
    return HEX_INVALID; 
177
 
  return (unsigned char)10 + ((unsigned char)c - (unsigned char)'a');
 
177
  return (uchar)10 + ((uchar)c - (uchar)'a');
178
178
}
179
179
 
180
180
static unsigned long read_addr(char** buf)
181
181
{
182
 
  unsigned char c;
 
182
  uchar c;
183
183
  char* p = *buf;
184
184
  unsigned long addr = 0;
185
185
 
193
193
static int init_sym_entry(SYM_ENTRY* se, char* buf)
194
194
{
195
195
  char* p, *p_end;
196
 
  se->addr = (unsigned char*)read_addr(&buf);
 
196
  se->addr = (uchar*)read_addr(&buf);
197
197
 
198
198
  if (!se->addr)
199
199
    return -1;
225
225
    SYM_ENTRY se;
226
226
    if (init_sym_entry(&se, buf))
227
227
      continue;
228
 
    if (insert_dynamic(&sym_table, (unsigned char*)&se))
 
228
    if (insert_dynamic(&sym_table, (uchar*)&se))
229
229
      die("insert_dynamic() failed - looks like we are out of memory");
230
230
  }
231
231
 
239
239
 
240
240
static void verify_sort()
241
241
{
242
 
  uint32_t i;
243
 
  unsigned char* last = 0;
 
242
  uint i;
 
243
  uchar* last = 0;
244
244
 
245
245
  for (i = 0; i < sym_table.elements; i++)
246
246
  {
247
247
    SYM_ENTRY se;
248
 
    get_dynamic(&sym_table, (unsigned char*)&se, i);
 
248
    get_dynamic(&sym_table, (uchar*)&se, i);
249
249
    if (se.addr < last)
250
250
      die("sym table does not appear to be sorted, did you forget \
251
251
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
254
254
}
255
255
 
256
256
 
257
 
static SYM_ENTRY* resolve_addr(unsigned char* addr, SYM_ENTRY* se)
 
257
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
258
258
{
259
 
  uint32_t i;
260
 
  get_dynamic(&sym_table, (unsigned char*)se, 0);
 
259
  uint i;
 
260
  get_dynamic(&sym_table, (uchar*)se, 0);
261
261
  if (addr < se->addr)
262
262
    return 0;
263
263
 
264
264
  for (i = 1; i < sym_table.elements; i++)
265
265
  {
266
 
    get_dynamic(&sym_table, (unsigned char*)se, i);
 
266
    get_dynamic(&sym_table, (uchar*)se, i);
267
267
    if (addr < se->addr)
268
268
    {
269
 
      get_dynamic(&sym_table, (unsigned char*)se, i - 1);
 
269
      get_dynamic(&sym_table, (uchar*)se, i - 1);
270
270
      return se;
271
271
    }
272
272
  }
288
288
    if (*p++ == '0' && *p++ == 'x')
289
289
    {
290
290
      SYM_ENTRY se ;
291
 
      unsigned char* addr = (unsigned char*)read_addr(&p);
 
291
      uchar* addr = (uchar*)read_addr(&p);
292
292
      if (resolve_addr(addr, &se))
293
293
        fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
294
294
                (int) (addr - se.addr));