From 3a16d640660712183f9b130a38fdba768076cce2 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Sat, 4 Jul 1992 12:21:01 +0000 Subject: [PATCH] * main.c (main): Read the $HOME/.gdbinit file before processing the argv arguments (e.g. reading symbol files or core files). This allows global parameters to be set, which will apply during the symbol reading. The ./.gdbinit is still read after argv processing. * symtab.c (list_symbols): `i variables' shouldn't show enum values. --- gdb/main.c | 87 +++++++++++++++++++++++++++------------------------- gdb/symtab.c | 6 ++-- 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index 544199f10c1..5efb478e8d8 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -412,6 +412,9 @@ main (argc, argv) /* Number of elements used. */ int ndir; + struct stat homebuf, cwdbuf; + char *homedir, *homeinit; + register int i; /* This needs to happen before the first use of malloc. */ @@ -653,6 +656,40 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); /* We may get more than one warning, don't double space all of them... */ warning_pre_print = "\nwarning: "; + /* Read and execute $HOME/.gdbinit file, if it exists. This is done + *before* all the command line arguments are processed; it sets + global parameters, which are independent of what file you are + debugging or what directory you are in. */ + homedir = getenv ("HOME"); + if (homedir) + { + homeinit = (char *) alloca (strlen (getenv ("HOME")) + + strlen (gdbinit) + 10); + strcpy (homeinit, getenv ("HOME")); + strcat (homeinit, "/"); + strcat (homeinit, gdbinit); + if (!inhibit_gdbinit && access (homeinit, R_OK) == 0) + { + /* The official language of expressions in $HOME/.gdbinit is C. */ + set_language (language_c); + if (!setjmp (to_top_level)) + source_command (homeinit, 0); + } + do_cleanups (ALL_CLEANUPS); + + /* Do stats; no need to do them elsewhere since we'll only + need them if homedir is set. Make sure that they are + zero in case one of them fails (this guarantees that they + won't match if either exists). */ + + memset (&homebuf, 0, sizeof (struct stat)); + memset (&cwdbuf, 0, sizeof (struct stat)); + + stat (homeinit, &homebuf); + stat (gdbinit, &cwdbuf); /* We'll only need this if + homedir was set. */ + } + /* Now perform all the actions indicated by the arguments. */ if (cdarg != NULL) { @@ -740,47 +777,15 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); error_pre_print = 0; warning_pre_print = "warning: "; - { - struct stat homebuf, cwdbuf; - char *homedir, *homeinit; - - /* Read init file, if it exists in home directory */ - homedir = getenv ("HOME"); - if (homedir) - { - homeinit = (char *) alloca (strlen (getenv ("HOME")) + - strlen (gdbinit) + 10); - strcpy (homeinit, getenv ("HOME")); - strcat (homeinit, "/"); - strcat (homeinit, gdbinit); - if (!inhibit_gdbinit && access (homeinit, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (homeinit, 0); - do_cleanups (ALL_CLEANUPS); - - /* Do stats; no need to do them elsewhere since we'll only - need them if homedir is set. Make sure that they are - zero in case one of them fails (this guarantees that they - won't match if either exists). */ - - memset (&homebuf, 0, sizeof (struct stat)); - memset (&cwdbuf, 0, sizeof (struct stat)); - - stat (homeinit, &homebuf); - stat (gdbinit, &cwdbuf); /* We'll only need this if - homedir was set. */ - } - - /* Read the input file in the current directory, *if* it isn't - the same file (it should exist, also). */ - - if (!homedir - || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat))) - if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (gdbinit, 0); - do_cleanups (ALL_CLEANUPS); - } + /* Read the .gdbinit file in the current directory, *if* it isn't + the same as the $HOME/.gdbinit file (it should exist, also). */ + + if (!homedir + || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat))) + if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0) + if (!setjmp (to_top_level)) + source_command (gdbinit, 0); + do_cleanups (ALL_CLEANUPS); for (i = 0; i < ncmd; i++) if (!setjmp (to_top_level)) diff --git a/gdb/symtab.c b/gdb/symtab.c index e4678b86b47..0097d1b489d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2043,7 +2043,8 @@ name_match (name) #define NAME_MATCH(NAME) name_match(NAME) /* List all symbols (if REGEXP is 0) or all symbols matching REGEXP. - If CLASS is zero, list all symbols except functions and type names. + If CLASS is zero, list all symbols except functions, type names, and + constants (enums). If CLASS is 1, list only functions. If CLASS is 2, list only type names. If CLASS is 3, list only method names. @@ -2221,7 +2222,8 @@ list_symbols (regexp, class, bpt) sym = BLOCK_SYM (b, j); if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (sym))) && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF - && SYMBOL_CLASS (sym) != LOC_BLOCK) + && SYMBOL_CLASS (sym) != LOC_BLOCK + && SYMBOL_CLASS (sym) != LOC_CONST) || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK) || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF) || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK))) -- 2.30.2