diff options
author | Fred Fish <fnf@specifix.com> | 1993-03-11 17:44:39 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1993-03-11 17:44:39 +0000 |
commit | bd5d07d94c9a05601299885ae906ec2d6f000ba9 (patch) | |
tree | 2f6f4768ac5c148645c516212720566bec9602ba /gdb/utils.c | |
parent | 0b96ed0655e98bdbca122e06b420ac35181215ca (diff) | |
download | gdb-bd5d07d94c9a05601299885ae906ec2d6f000ba9.zip gdb-bd5d07d94c9a05601299885ae906ec2d6f000ba9.tar.gz gdb-bd5d07d94c9a05601299885ae906ec2d6f000ba9.tar.bz2 |
* utils.c (fputs_demangled): Complete rewrite to clean up and
add a language parameter that is used to select the demangling
algorithm.
* defs.h (enum language): Move further up in file so enum can
be used in prototypes.
* defs.h (fputs_demangled): Update prototype to add lang arg.
* c-typeprint.c (cp_type_print_method_args): Add language arg
to fputs_demangled calls, remove DMGL_PARAMS flag.
* stack.c (print_frame_info): Remove obsolete code so we don't
have to update fputs_demangled usage in it.
* stack.c (print_frame_info, frame_info): Add language variable
to pass to fputs_demangled and initialize it from the symbol's
language. Call fputs_demangled with language arg.
* symtab.c (find_methods): Add language arg to fputs_demangled
call.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 166 |
1 files changed, 86 insertions, 80 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index a941454..895a62a 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -33,6 +33,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "target.h" #include "demangle.h" +#include "expression.h" +#include "language.h" /* Prototypes for local functions */ @@ -411,9 +413,33 @@ quit () #else error ("Quit (expect signal %d when inferior is resumed)", SIGINT); #endif /* TIOCGPGRP */ +#else + error ("Quit"); #endif } + +#ifdef __GO32__ + +/* In the absence of signals, poll keyboard for a quit. + Called from #define QUIT pollquit() in xm-go32.h. */ + +void +pollquit() +{ + if (kbhit ()) + { + int k = getkey (); + if (k == 1) + quit_flag = 1; + else if (k == 2) + immediate_quit = 1; + quit (); + } +} + +#endif + /* Control C comes here */ void @@ -1110,71 +1136,50 @@ fputs_filtered (linebuffer, stream) } -/* fputs_demangled is a variant of fputs_filtered that - demangles g++ names.*/ +/* fputs_demangled attempts to demangle NAME, a symbol in language LANG, using + demangling args ARG_MODE, and print it filtered to STREAM. If the name is + not mangled, or the language for the name is unknown, or demangling is off, + the name is printed in its "raw" form. */ void -fputs_demangled (linebuffer, stream, arg_mode) - char *linebuffer; +fputs_demangled (name, stream, arg_mode, lang) + char *name; FILE *stream; int arg_mode; + enum language lang; { -#define SYMBOL_MAX 1024 - -#define SYMBOL_CHAR(c) (isascii(c) \ - && (isalnum(c) || (c) == '_' || (c) == CPLUS_MARKER)) - - char buf[SYMBOL_MAX+1]; -# define DMSLOP 5 /* How much room to leave in buf */ - char *p; - - if (linebuffer == NULL) - return; - - /* If user wants to see raw output, no problem. */ - if (!demangle) { - fputs_filtered (linebuffer, stream); - return; - } - - p = linebuffer; - - while ( *p != (char) 0 ) { - int i = 0; - - /* collect non-interesting characters into buf */ - while (*p != (char) 0 && !SYMBOL_CHAR(*p) && i < (int)sizeof(buf)-DMSLOP ) { - buf[i++] = *p; - p++; - } - if (i > 0) { - /* output the non-interesting characters without demangling */ - buf[i] = (char) 0; - fputs_filtered(buf, stream); - i = 0; /* reset buf */ - } + char *demangled; - /* and now the interesting characters */ - while (i < SYMBOL_MAX - && *p != (char) 0 - && SYMBOL_CHAR(*p) - && i < (int)sizeof(buf) - DMSLOP) { - buf[i++] = *p; - p++; - } - buf[i] = (char) 0; - if (i > 0) { - char * result; - - if ( (result = cplus_demangle(buf, arg_mode)) != NULL ) { - fputs_filtered(result, stream); - free(result); - } - else { - fputs_filtered(buf, stream); - } + if (name != NULL) + { + /* If user wants to see raw output, no problem. */ + if (!demangle) + { + fputs_filtered (name, stream); + } + else + { + switch (lang) + { + case language_cplus: + demangled = cplus_demangle (name, arg_mode); + break; + /* start-sanitize-chill */ + case language_chill: + demangled = chill_demangle (name); + break; + /* end-sanitize-chill */ + default: + demangled = NULL; + break; + } + fputs_filtered (demangled ? demangled : name, stream); + if (demangled != NULL) + { + free (demangled); + } + } } - } } /* Print a variable number of ARGS using format FORMAT. If this @@ -1361,34 +1366,34 @@ print_spaces_filtered (n, stream) /* C++ demangler stuff. */ -/* Make a copy of a symbol, applying C++ demangling if demangling is enabled - and a demangled version exists. Note that the value returned from - cplus_demangle is already allocated in malloc'd memory. */ - -char * -strdup_demangled (name) - const char *name; -{ - char *demangled = NULL; - - if (demangle) - { - demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI); - } - return ((demangled != NULL) ? demangled : strdup (name)); -} - - /* Print NAME on STREAM, demangling if necessary. */ void fprint_symbol (stream, name) FILE *stream; char *name; { - char *demangled; - if ((!demangle) - || NULL == (demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI))) - fputs_filtered (name, stream); + char *demangled = NULL; + + if (demangle) + { + /* Lacking a better method of knowing what demangler to use, pick + one appropriate for whatever the current language is. (FIXME) */ + switch (current_language -> la_language) + { + case language_cplus: + demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI); + break; + /* start-sanitize-chill */ + case language_chill: + demangled = chill_demangle (name); + break; + /* end-sanitize-chill */ + } + } + if (demangled == NULL) + { + fputs_filtered (name, stream); + } else { fputs_filtered (demangled, stream); @@ -1534,3 +1539,4 @@ _initialize_utils () #ifdef SIGWINCH_HANDLER_BODY SIGWINCH_HANDLER_BODY #endif + |