~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/resolve_stack_dump.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <mystrings/m_ctype.h>
22
22
#include <mysys/my_sys.h>
23
23
#include <mystrings/m_string.h>
 
24
#include <drizzled/version.h>
24
25
#include <errno.h>
25
26
#include <mysys/my_getopt.h>
26
27
 
28
29
#define INC_SYM_TABLE  4096
29
30
#define MAX_SYM_SIZE   128
30
31
#define DUMP_VERSION "1.4"
31
 
#define HEX_INVALID  (unsigned char)255
 
32
#define HEX_INVALID  (uchar)255
32
33
 
33
34
 
34
35
typedef struct sym_entry
35
36
{
36
37
  char symbol[MAX_SYM_SIZE];
37
 
  unsigned char* addr;
 
38
  uchar* addr;
38
39
} SYM_ENTRY;
39
40
 
40
41
 
62
63
static void print_version(void)
63
64
{
64
65
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION,
65
 
         VERSION,SYSTEM_TYPE,MACHINE_TYPE);
 
66
         DRIZZLE_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
66
67
}
67
68
 
68
69
 
165
166
 
166
167
}
167
168
 
168
 
static unsigned char hex_val(char c)
 
169
static uchar hex_val(char c)
169
170
{
170
 
  unsigned char l;
171
 
  if (my_isdigit(&my_charset_utf8_general_ci,c))
 
171
  uchar l;
 
172
  if (my_isdigit(&my_charset_latin1,c))
172
173
    return c - '0';
173
 
  l = my_tolower(&my_charset_utf8_general_ci,c);
 
174
  l = my_tolower(&my_charset_latin1,c);
174
175
  if (l < 'a' || l > 'f')
175
176
    return HEX_INVALID; 
176
 
  return (unsigned char)10 + ((unsigned char)c - (unsigned char)'a');
 
177
  return (uchar)10 + ((uchar)c - (uchar)'a');
177
178
}
178
179
 
179
180
static unsigned long read_addr(char** buf)
180
181
{
181
 
  unsigned char c;
 
182
  uchar c;
182
183
  char* p = *buf;
183
184
  unsigned long addr = 0;
184
185
 
192
193
static int init_sym_entry(SYM_ENTRY* se, char* buf)
193
194
{
194
195
  char* p, *p_end;
195
 
  se->addr = (unsigned char*)read_addr(&buf);
 
196
  se->addr = (uchar*)read_addr(&buf);
196
197
 
197
198
  if (!se->addr)
198
199
    return -1;
199
 
  while (my_isspace(&my_charset_utf8_general_ci,*buf++))
 
200
  while (my_isspace(&my_charset_latin1,*buf++))
200
201
    /* empty */;
201
202
 
202
 
  while (my_isspace(&my_charset_utf8_general_ci,*buf++))
 
203
  while (my_isspace(&my_charset_latin1,*buf++))
203
204
    /* empty - skip more space */;
204
205
  --buf;
205
206
  /* now we are on the symbol */
224
225
    SYM_ENTRY se;
225
226
    if (init_sym_entry(&se, buf))
226
227
      continue;
227
 
    if (insert_dynamic(&sym_table, (unsigned char*)&se))
 
228
    if (insert_dynamic(&sym_table, (uchar*)&se))
228
229
      die("insert_dynamic() failed - looks like we are out of memory");
229
230
  }
230
231
 
238
239
 
239
240
static void verify_sort()
240
241
{
241
 
  uint32_t i;
242
 
  unsigned char* last = 0;
 
242
  uint i;
 
243
  uchar* last = 0;
243
244
 
244
245
  for (i = 0; i < sym_table.elements; i++)
245
246
  {
246
247
    SYM_ENTRY se;
247
 
    get_dynamic(&sym_table, (unsigned char*)&se, i);
 
248
    get_dynamic(&sym_table, (uchar*)&se, i);
248
249
    if (se.addr < last)
249
250
      die("sym table does not appear to be sorted, did you forget \
250
251
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
253
254
}
254
255
 
255
256
 
256
 
static SYM_ENTRY* resolve_addr(unsigned char* addr, SYM_ENTRY* se)
 
257
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
257
258
{
258
 
  uint32_t i;
259
 
  get_dynamic(&sym_table, (unsigned char*)se, 0);
 
259
  uint i;
 
260
  get_dynamic(&sym_table, (uchar*)se, 0);
260
261
  if (addr < se->addr)
261
262
    return 0;
262
263
 
263
264
  for (i = 1; i < sym_table.elements; i++)
264
265
  {
265
 
    get_dynamic(&sym_table, (unsigned char*)se, i);
 
266
    get_dynamic(&sym_table, (uchar*)se, i);
266
267
    if (addr < se->addr)
267
268
    {
268
 
      get_dynamic(&sym_table, (unsigned char*)se, i - 1);
 
269
      get_dynamic(&sym_table, (uchar*)se, i - 1);
269
270
      return se;
270
271
    }
271
272
  }
281
282
  {
282
283
    p = buf;
283
284
    /* skip space */
284
 
    while (my_isspace(&my_charset_utf8_general_ci,*p))
 
285
    while (my_isspace(&my_charset_latin1,*p))
285
286
      ++p;
286
287
 
287
288
    if (*p++ == '0' && *p++ == 'x')
288
289
    {
289
290
      SYM_ENTRY se ;
290
 
      unsigned char* addr = (unsigned char*)read_addr(&p);
 
291
      uchar* addr = (uchar*)read_addr(&p);
291
292
      if (resolve_addr(addr, &se))
292
293
        fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
293
294
                (int) (addr - se.addr));