summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-06-11 11:20:31 +0300
committerunknown <monty@mashka.mysql.fi>2002-06-11 11:20:31 +0300
commit70aa7424c41c45a8fb171bbdd9e24d74b70a7765 (patch)
tree8fcaabe013fff43cf466235067f2c47f0cd66531 /extra
parent30d5eb22877d0546fb4bd93ead7e8602285d449b (diff)
downloadmariadb-git-70aa7424c41c45a8fb171bbdd9e24d74b70a7765.tar.gz
Big code cleanup/review before 4.0.2 release.
(All commit emails since 4.0.1 checked) This had to be done now, before the 4.1 tree changes to much, to make it easy to propagate bug fixes to the 4.1 tree. BUILD/SETUP.sh: Added -DPEDANTIC_SAFEMALLOC as standard debug option Docs/manual.texi: Changes for new version. client/mysql.cc: Fixed default value for rehash cleanup client/mysqladmin.c: Cleanup client/mysqlbinlog.cc: cleanup client/mysqldump.c: Cleanup client/mysqlmanager-pwgen.c: Cleanup client/mysqlmanagerc.c: Cleanup client/mysqltest.c: Cleanup dbug/dbug.c: Cleanup extra/resolve_stack_dump.c: Cleanup & Simple optimizations include/ft_global.h: Cleanup include/my_alloc.h: Cleanup include/my_global.h: Cleanup include/my_sys.h: Cleanup include/myisam.h: Cleanup libmysql/libmysql.c: Cleanup libmysql/manager.c: Cleanup myisam/ft_boolean_search.c: Cleanup myisam/ft_dump.c: Change strcpy -> strmov myisam/ft_eval.c: Cleanup myisam/ft_nlq_search.c: Cleanup myisam/ft_test1.c: strncpy -> strnmov myisam/ft_update.c: Cleanup myisam/mi_static.c: Cleanup myisam/mi_test2.c: Cleanup myisam/mi_write.c: Cleanup mysys/mf_fn_ext.c: Cleanup mysys/mf_iocache.c: Cleanup mysys/mf_iocache2.c: Cleanup mysys/my_getopt.c: Cleanup mysys/my_read.c: Cleanup mysys/my_thr_init.c: Cleanup mysys/queues.c: Cleanup mysys/safemalloc.c: Cleanup sql/field.cc: Indentation cleanups sql/ha_berkeley.cc: Indentation cleanups sql/ha_myisam.cc: Cleanup sql/item.h: Indentation cleanups sql/item_cmpfunc.cc: Indentation cleanups sql/item_create.cc: cleanup sql/item_func.cc: Cleanup sql/item_func.h: Indentation cleanups sql/item_strfunc.cc: Indentation cleanups sql/item_sum.cc: Indentation cleanups sql/item_timefunc.cc: Indentation cleanups sql/lock.cc: Indentation cleanups sql/log.cc: Cleanup strnmov -> strmake sql/log_event.cc: Cleanup + optimizations Fixed memory leak Added missing pthread_mutex_unlock() (On error condition) sql/log_event.h: Indentation and comment cleanup Merged #ifdef's into common blocks for better readability sql/mini_client.cc: Indentation cleanup sql/mysql_priv.h: Cleanup Changed int function to bool sql/mysqld.cc: Indentation and comment cleanup sql/net_pkg.cc: Indentation cleanup sql/net_serv.cc: Changed int function -> bool sql/nt_servc.cc: Cleanup sql/opt_range.cc: Indentation cleanup sql/repl_failsafe.cc: Cleanup + simple optimization strnmov -> strmake sql/slave.cc: strnmov -> strmake Cleanups sql/slave.h: Cleanup sql/sql_acl.cc: Indentation and DBUG_PRINT cleanup Changed WITH MAX... to not use = sql/sql_base.cc: Indentation cleanup sql/sql_cache.cc: Indentation cleanup sql/sql_class.cc: Indentation cleanup sql/sql_class.h: Renamed some struct slots sql/sql_delete.cc: Indentation cleanup sql/sql_handler.cc: Indentation cleanup sql/sql_insert.cc: Use new slot names. sql/sql_lex.cc: Indentation cleanup sql/sql_lex.h: Indentation cleanup sql/sql_load.cc: Indentation cleanup sql/sql_parse.cc: Indentation cleanup Removed not used check from LOCK TABLES sql/sql_repl.cc: strnmov -> strmake sql/sql_repl.h: Removed test if file is included (We want to know if it's included twice to avoid this) sql/sql_select.cc: Indentation cleanup sql/sql_show.cc: Indentation cleanup sql/sql_string.cc: Indentation cleanup sql/sql_table.cc: Indentation cleanup sql/sql_union.cc: Use renamed struct slot sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Removed = after GRANT ... MAX_ to make the syntax uniform sql/table.cc: Indentation cleanup sql/table.h: Indentation cleanup sql/time.cc: Indentation cleanup sql/udf_example.cc: Indentation cleanup sql/unireg.cc: strnmov -> strmake tests/grant.pl: Added test for LOCK TABLES tools/mysqlmanager.c: Cleanup fopen() -> my_fopen() vio/viosocket.c: DBUG_PRINT cleanups vio/viosslfactories.c: Indentation cleanup Checking of results from malloc() Fixed possible memory leak BitKeeper/etc/ignore: Added scripts/mysql_secure_installation to the ignore list BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'extra')
-rw-r--r--extra/resolve_stack_dump.c130
1 files changed, 63 insertions, 67 deletions
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index 8379da97795..c54f17a186e 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -77,7 +77,8 @@ static void usage()
printf("MySQL AB, by Sasha Pachev\n");
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Resolve numeric stack strace dump into symbols.\n\n");
- printf("Usage: %s [OPTIONS] symbols-file [numeric-dump-file]\n", my_progname);
+ printf("Usage: %s [OPTIONS] symbols-file [numeric-dump-file]\n",
+ my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
printf("\n\
@@ -159,14 +160,14 @@ static void open_files()
fp_out = stdout;
fp_dump = stdin;
- if(dump_fname && !(fp_dump = my_fopen(dump_fname, O_RDONLY, MYF(MY_WME))))
+ if (dump_fname && !(fp_dump = my_fopen(dump_fname, O_RDONLY, MYF(MY_WME))))
die("Could not open %s", dump_fname);
/* if name not given, assume stdin*/
- if(!sym_fname)
+ if (!sym_fname)
die("Please run nm --numeric-sort on mysqld binary that produced stack \
trace dump and specify the path to it with -s or --symbols-file");
- if(!(fp_sym = my_fopen(sym_fname, O_RDONLY, MYF(MY_WME))))
+ if (!(fp_sym = my_fopen(sym_fname, O_RDONLY, MYF(MY_WME))))
die("Could not open %s", sym_fname);
}
@@ -174,10 +175,10 @@ trace dump and specify the path to it with -s or --symbols-file");
static uchar hex_val(char c)
{
uchar l;
- if(isdigit(c))
+ if (isdigit(c))
return c - '0';
l = tolower(c);
- if(l < 'a' || l > 'f')
+ if (l < 'a' || l > 'f')
return HEX_INVALID;
return (uchar)10 + ((uchar)c - (uchar)'a');
}
@@ -200,25 +201,18 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
char* p, *p_end;
se->addr = (uchar*)read_addr(&buf);
- if(!se->addr)
+ if (!se->addr)
return -1;
- while(isspace(*buf++))
- /* empty */;
+ while (isspace(*buf++)) ;
- while(isspace(*buf++))
- /* empty - skip more space */;
+ while (isspace(*buf++)) ; /* skip more space */
--buf;
/* now we are on the symbol */
- for(p = se->symbol, p_end = se->symbol + sizeof(se->symbol) - 1;
- *buf != '\n' && *buf; ++buf,++p )
- {
- if(p < p_end)
- *p = *buf;
- else
- break;
- }
+ for (p = se->symbol, p_end = se->symbol + sizeof(se->symbol) - 1;
+ *buf != '\n' && *buf && p < p_end; ++buf,++p)
+ *p = *buf;
*p = 0;
- if(!strcmp(se->symbol, "gcc2_compiled."))
+ if (!strcmp(se->symbol, "gcc2_compiled."))
return -1;
return 0;
}
@@ -226,18 +220,18 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
static void init_sym_table()
{
char buf[512];
- if(my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
- INC_SYM_TABLE))
+ if (my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
+ INC_SYM_TABLE))
die("Failed in my_init_dynamic_array() -- looks like out of memory problem");
- while(fgets(buf, sizeof(buf), fp_sym))
- {
- SYM_ENTRY se;
- if(init_sym_entry(&se, buf))
- continue;
- if(insert_dynamic(&sym_table, (gptr)&se))
- die("insert_dynamic() failed - looks like we are out of memory");
- }
+ while (fgets(buf, sizeof(buf), fp_sym))
+ {
+ SYM_ENTRY se;
+ if (init_sym_entry(&se, buf))
+ continue;
+ if (insert_dynamic(&sym_table, (gptr)&se))
+ die("insert_dynamic() failed - looks like we are out of memory");
+ }
verify_sort();
}
@@ -252,66 +246,68 @@ static void verify_sort()
uint i;
uchar* last = 0;
- for(i = 0; i < sym_table.elements; i++)
- {
- SYM_ENTRY se;
- get_dynamic(&sym_table, (gptr)&se, i);
- if(se.addr < last)
- die("sym table does not appear to be sorted, did you forget \
+ for (i = 0; i < sym_table.elements; i++)
+ {
+ SYM_ENTRY se;
+ get_dynamic(&sym_table, (gptr)&se, i);
+ if (se.addr < last)
+ die("sym table does not appear to be sorted, did you forget \
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
- last = se.addr;
- }
+ last = se.addr;
+ }
}
+
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
{
uint i;
get_dynamic(&sym_table, (gptr)se, 0);
- if(addr < se->addr)
+ if (addr < se->addr)
return 0;
- for(i = 1; i < sym_table.elements; i++)
+ for (i = 1; i < sym_table.elements; i++)
+ {
+ get_dynamic(&sym_table, (gptr)se, i);
+ if (addr < se->addr)
{
- get_dynamic(&sym_table, (gptr)se, i);
- if(addr < se->addr)
- {
- get_dynamic(&sym_table, (gptr)se, i - 1);
- return se;
- }
+ get_dynamic(&sym_table, (gptr)se, i - 1);
+ return se;
}
+ }
return se;
}
+
static void do_resolve()
{
char buf[1024], *p;
- while(fgets(buf, sizeof(buf), fp_dump))
+ while (fgets(buf, sizeof(buf), fp_dump))
+ {
+ p = buf;
+ while(isspace(*p))
+ ++p;
+
+ if (*p++ == '0' && *p++ == 'x')
{
- p = buf;
- while(isspace(*p))
- ++p;
- /* skip space */;
-
- if(*p++ == '0' && *p++ == 'x')
- {
- SYM_ENTRY se ;
- uchar* addr = (uchar*)read_addr(&p);
- if(resolve_addr(addr, &se))
- fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
- (int) (addr - se.addr));
- else
- fprintf(fp_out, "%p (?)\n", addr);
-
- }
+ SYM_ENTRY se ;
+ uchar* addr = (uchar*)read_addr(&p);
+ if (resolve_addr(addr, &se))
+ fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
+ (int) (addr - se.addr));
else
- {
- fputs(buf, fp_out);
- continue;
- }
+ fprintf(fp_out, "%p (?)\n", addr);
+
}
+ else
+ {
+ fputs(buf, fp_out);
+ continue;
+ }
+ }
}
+
int main(int argc, char** argv)
{
MY_INIT(argv[0]);