~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/resolve_stack_dump.c

  • Committer: Patrick Galbraith
  • Date: 2008-07-24 16:57:40 UTC
  • mto: (202.2.4 rename-mysql-to-drizzle)
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: patg@ishvara-20080724165740-x58yw6zs6d9o17lf
Most everything working with client rename
mysqlslap test still fails... can't connect to the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
   versions into symbolic names. By Sasha Pachev <sasha@mysql.com>
18
18
 */
19
19
 
20
 
#include <drizzled/global.h>
21
 
#include <mystrings/m_ctype.h>
22
 
#include <mysys/my_sys.h>
23
 
#include <mystrings/m_string.h>
24
 
#include <drizzled/version.h>
 
20
#include <my_global.h>
 
21
#include <m_ctype.h>
 
22
#include <my_sys.h>
 
23
#include <m_string.h>
 
24
#include <drizzle_version.h>
25
25
#include <errno.h>
26
 
#include <mysys/my_getopt.h>
 
26
#include <my_getopt.h>
27
27
 
28
28
#define INIT_SYM_TABLE  4096
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
typedef ulong my_long_addr_t ; /* at some point, we need to fix configure
 
35
                                * to define this for us  
 
36
                                */
34
37
 
35
38
typedef struct sym_entry
36
39
{
37
40
  char symbol[MAX_SYM_SIZE];
38
 
  unsigned char* addr;
 
41
  uchar* addr;
39
42
} SYM_ENTRY;
40
43
 
41
44
 
60
63
 
61
64
static void verify_sort(void);
62
65
 
 
66
 
 
67
#include <help_start.h>
 
68
 
63
69
static void print_version(void)
64
70
{
65
71
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION,
66
 
         DRIZZLE_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
 
72
         MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
67
73
}
68
74
 
69
75
 
83
89
If the numeric-dump-file is not given, the stack trace is read from stdin.\n");
84
90
}
85
91
 
 
92
#include <help_end.h>
 
93
 
 
94
 
86
95
static void die(const char* fmt, ...)
87
96
{
88
97
  va_list args;
166
175
 
167
176
}
168
177
 
169
 
static unsigned char hex_val(char c)
 
178
static uchar hex_val(char c)
170
179
{
171
 
  unsigned char l;
172
 
  if (my_isdigit(&my_charset_utf8_general_ci,c))
 
180
  uchar l;
 
181
  if (my_isdigit(&my_charset_latin1,c))
173
182
    return c - '0';
174
 
  l = my_tolower(&my_charset_utf8_general_ci,c);
 
183
  l = my_tolower(&my_charset_latin1,c);
175
184
  if (l < 'a' || l > 'f')
176
185
    return HEX_INVALID; 
177
 
  return (unsigned char)10 + ((unsigned char)c - (unsigned char)'a');
 
186
  return (uchar)10 + ((uchar)c - (uchar)'a');
178
187
}
179
188
 
180
 
static unsigned long read_addr(char** buf)
 
189
static my_long_addr_t read_addr(char** buf)
181
190
{
182
 
  unsigned char c;
 
191
  uchar c;
183
192
  char* p = *buf;
184
 
  unsigned long addr = 0;
 
193
  my_long_addr_t addr = 0;
185
194
 
186
195
  while((c = hex_val(*p++)) != HEX_INVALID)
187
196
      addr = (addr << 4) + c;
193
202
static int init_sym_entry(SYM_ENTRY* se, char* buf)
194
203
{
195
204
  char* p, *p_end;
196
 
  se->addr = (unsigned char*)read_addr(&buf);
 
205
  se->addr = (uchar*)read_addr(&buf);
197
206
 
198
207
  if (!se->addr)
199
208
    return -1;
200
 
  while (my_isspace(&my_charset_utf8_general_ci,*buf++))
 
209
  while (my_isspace(&my_charset_latin1,*buf++))
201
210
    /* empty */;
202
211
 
203
 
  while (my_isspace(&my_charset_utf8_general_ci,*buf++))
 
212
  while (my_isspace(&my_charset_latin1,*buf++))
204
213
    /* empty - skip more space */;
205
214
  --buf;
206
215
  /* now we are on the symbol */
225
234
    SYM_ENTRY se;
226
235
    if (init_sym_entry(&se, buf))
227
236
      continue;
228
 
    if (insert_dynamic(&sym_table, (unsigned char*)&se))
 
237
    if (insert_dynamic(&sym_table, (uchar*)&se))
229
238
      die("insert_dynamic() failed - looks like we are out of memory");
230
239
  }
231
240
 
239
248
 
240
249
static void verify_sort()
241
250
{
242
 
  uint32_t i;
243
 
  unsigned char* last = 0;
 
251
  uint i;
 
252
  uchar* last = 0;
244
253
 
245
254
  for (i = 0; i < sym_table.elements; i++)
246
255
  {
247
256
    SYM_ENTRY se;
248
 
    get_dynamic(&sym_table, (unsigned char*)&se, i);
 
257
    get_dynamic(&sym_table, (uchar*)&se, i);
249
258
    if (se.addr < last)
250
259
      die("sym table does not appear to be sorted, did you forget \
251
260
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
254
263
}
255
264
 
256
265
 
257
 
static SYM_ENTRY* resolve_addr(unsigned char* addr, SYM_ENTRY* se)
 
266
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
258
267
{
259
 
  uint32_t i;
260
 
  get_dynamic(&sym_table, (unsigned char*)se, 0);
 
268
  uint i;
 
269
  get_dynamic(&sym_table, (uchar*)se, 0);
261
270
  if (addr < se->addr)
262
271
    return 0;
263
272
 
264
273
  for (i = 1; i < sym_table.elements; i++)
265
274
  {
266
 
    get_dynamic(&sym_table, (unsigned char*)se, i);
 
275
    get_dynamic(&sym_table, (uchar*)se, i);
267
276
    if (addr < se->addr)
268
277
    {
269
 
      get_dynamic(&sym_table, (unsigned char*)se, i - 1);
 
278
      get_dynamic(&sym_table, (uchar*)se, i - 1);
270
279
      return se;
271
280
    }
272
281
  }
282
291
  {
283
292
    p = buf;
284
293
    /* skip space */
285
 
    while (my_isspace(&my_charset_utf8_general_ci,*p))
 
294
    while (my_isspace(&my_charset_latin1,*p))
286
295
      ++p;
287
296
 
288
297
    if (*p++ == '0' && *p++ == 'x')
289
298
    {
290
299
      SYM_ENTRY se ;
291
 
      unsigned char* addr = (unsigned char*)read_addr(&p);
 
300
      uchar* addr = (uchar*)read_addr(&p);
292
301
      if (resolve_addr(addr, &se))
293
302
        fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
294
303
                (int) (addr - se.addr));