diff options
author | unknown <jani@hynda.(none)> | 2002-05-22 23:54:24 +0300 |
---|---|---|
committer | unknown <jani@hynda.(none)> | 2002-05-22 23:54:24 +0300 |
commit | 2276e8aeb845f5186f48925ae4e6c1e80ff529a8 (patch) | |
tree | c01334461ba2741cbb5763ef8029cae9ea298d25 /extra/resolve_stack_dump.c | |
parent | 4d6819171d7e8f2ed8a5bea7acc45669f5953b7e (diff) | |
download | mariadb-git-2276e8aeb845f5186f48925ae4e6c1e80ff529a8.tar.gz |
moved my_getopt.h under client_priv.h
Changed my_print_defaults, mysql_install, perror, resolve_stack_dump,
resolveip and pack_isam to use my_getopt.
client/client_priv.h:
getopt -> my_getopt
client/mysql.cc:
moved my_getopt.h under client_priv.h
client/mysqladmin.c:
moved my_getopt.h under client_priv.h
client/mysqlbinlog.cc:
moved my_getopt.h under client_priv.h
client/mysqlcheck.c:
moved my_getopt.h under client_priv.h
client/mysqldump.c:
moved my_getopt.h under client_priv.h
client/mysqlimport.c:
moved my_getopt.h under client_priv.h
client/mysqlshow.c:
moved my_getopt.h under client_priv.h
extra/my_print_defaults.c:
Changed from getopt to use my_getopt
extra/mysql_install.c:
Changed from getopt to use my_getopt
extra/perror.c:
Changed from getopt to use my_getopt
extra/resolve_stack_dump.c:
Changed from getopt to use my_getopt
extra/resolveip.c:
Changed from getopt to use my_getopt
fs/mysqlcorbafs.c:
Left reminder about my_getopt when this program is ready.
Currently it's not being compiled.
isam/pack_isam.c:
Changed from getopt to use my_getopt
Diffstat (limited to 'extra/resolve_stack_dump.c')
-rw-r--r-- | extra/resolve_stack_dump.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 7c33bd51dbe..23f22e276a6 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -25,12 +25,12 @@ #include <m_string.h> #include <mysql_version.h> #include <errno.h> -#include <getopt.h> +#include <my_getopt.h> #define INIT_SYM_TABLE 4096 #define INC_SYM_TABLE 4096 #define MAX_SYM_SIZE 128 -#define DUMP_VERSION "1.2" +#define DUMP_VERSION "1.3" #define HEX_INVALID (uchar)255 typedef ulong my_long_addr_t ; /* at some point, we need to fix configure @@ -48,15 +48,21 @@ static char* dump_fname = 0, *sym_fname = 0; static DYNAMIC_ARRAY sym_table; /* how do you like this , static DYNAMIC ? */ static FILE* fp_dump, *fp_sym = 0, *fp_out; -struct option long_options[] = +static struct my_option my_long_options[] = { - {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'V'}, - {"symbols-file", required_argument, 0, 's'}, - {"numeric-dump-file", required_argument, 0, 'n'}, - {0, 0,0,0} + {"help", 'h', "Display this help and exit.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"version", 'V', "Output version information and exit.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"symbols-file", 's', "Use specified symbols file.", (gptr*) &sym_fname, + (gptr*) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"numeric-dump-file", 'n', "Read the dump from specified file.", + (gptr*) &dump_fname, (gptr*) &dump_fname, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; + static void verify_sort(); static void print_version(void) @@ -72,11 +78,8 @@ static void usage() 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("\n\ - -?, --help Display this help and exit.\n\ - -s, --symbols-file=... Use specified symbols file.\n\ - -n, --numeric-dump-file=... Read the dump from specified file.\n\ - -V, --version Output version information and exit.\n"); + my_print_help(my_long_options); + my_print_variables(my_long_options); printf("\n\ The symbols-file should include the output from: 'nm --numeric-sort mysqld'.\n\ The numeric-dump-file should contain a numeric stack trace from mysqld.\n\ @@ -97,40 +100,36 @@ static void die(const char* fmt, ...) } -static int parse_args(int argc, char **argv) +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument __attribute__((unused))) { - int c, option_index = 0; + switch(optid) { + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} - while((c = getopt_long(argc, argv, "?Vn:s:", - long_options, &option_index)) != EOF) - { - switch(c) - { - case 'n': - dump_fname = optarg; - break; - case 's': - sym_fname = optarg; - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - default: - usage(); - exit(1); - } - } - argc-=optind; - argv+=optind; +static int parse_args(int argc, char **argv) +{ + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + { + printf("%s: handle_options() failed with error %d\n", my_progname, + ho_error); + exit(1); + } /* The following code is to make the command compatible with the old version that required one to use the -n and -s options - */ + */ if (argc == 2) { |