diff options
author | Michael Snyder <msnyder@vmware.com> | 2002-09-19 01:34:51 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2002-09-19 01:34:51 +0000 |
commit | 3b4efeaa2da94f19becde56d8c8f9693367acafc (patch) | |
tree | 317d932941134a8b5cb49e89a4f86179519f429f /gdb/utils.c | |
parent | b9caf5053f5684f063a33357b6483cd2b62de0ec (diff) | |
download | gdb-3b4efeaa2da94f19becde56d8c8f9693367acafc.zip gdb-3b4efeaa2da94f19becde56d8c8f9693367acafc.tar.gz gdb-3b4efeaa2da94f19becde56d8c8f9693367acafc.tar.bz2 |
2002-09-18 Michael Snyder <msnyder@redhat.com>
Preliminary support for Objective-C:
* defs.h (language_objc): New enum value.
(puts_filtered_tabular): Declaration only, exported from utils.c.
(skip_quoted): Delete, declared in completer.h.
* c-exp.y: Include completer.h.
* p-exp.y: Ditto.
* jv-exp.y: Ditto.
* expression.h (OP_MSGCALL, OP_SELECTOR, OP_SELF, OP_NSSTRING):
New operator enum values.
* language.h (CAST_IS_CONVERSION): Test for language_objc.
* language.c (binop_result_type): Handle language_objc case.
(integral_type, character_type, string_type, boolean_type,
structured_type, binop_type_check): Ditto.
* symtab.h (SYMBOL_OBJC_DEMANGLED_NAME): Define.
(struct objc_specific): Add to general_symbol_info.
(SYMBOL_INIT_LANGUAGE_SPECIFIC): Add objc initialization.
(SYMBOL_DEMANGLED_NAME): Handle objc case.
* parser-defs.h (struct objc_class_str): New struct type.
(start_msglist, end_msglist, add_msglist): Declaration only,
exported from objc-lang.c.
* value.h (value_of_local, value_nsstring,
call_function_by_hand_expecting_type): Exported from valops.c.
* valops.c (find_function_addr): Export.
(call_function_by_hand_expecting_type): New function.
(value_of_local): New function.
* symfile.c (init_filename_language_table): Add ".m" extension
for Objective-C.
* utils.c (puts_filtered_tabular): New function.
(fprintf_symbol_filtered): Add objc demangling support (disabled).
(set/show demangle): Extend help-string to refer to ObjC.
* elfread.c (elf_symtab_read): Skip Objective-C special symbols.
* stabsread.c (symbol_reference_defined): Objective-C symbols
may contain colons: make allowances when scanning stabs strings
for colons.
(objc_find_colon): New function.
* printcmd.c (address_info): If language == objc then print
"self" instead of "this".
* parse.c (length_of_subexp): Handle new operators OP_MSGCALL,
OP_NSSTRING, and OP_SELF.
(prefixify_subexp): Ditto.
* source.c (print_source_lines): Mention objc in comment.
* breakpoint.c (parse_breakpoint_sals): Recognize Objective-C
method names.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 79 |
1 files changed, 66 insertions, 13 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 92c097a..0b15126 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -152,13 +152,13 @@ int quit_flag; int immediate_quit; -/* Nonzero means that encoded C++ names should be printed out in their - C++ form rather than raw. */ +/* Nonzero means that encoded C++/ObjC names should be printed out in their + C++/ObjC form rather than raw. */ int demangle = 1; -/* Nonzero means that encoded C++ names should be printed out in their - C++ form even in assembler language displays. If this is set, but +/* Nonzero means that encoded C++/ObjC names should be printed out in their + C++/ObjC form even in assembler language displays. If this is set, but DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls. */ int asm_demangle = 0; @@ -276,7 +276,7 @@ make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function, void *arg) { register struct cleanup *new - = (struct cleanup *) xmalloc (sizeof (struct cleanup)); + = (struct cleanup *) xmalloc (sizeof (struct cleanup)); register struct cleanup *old_chain = *pmy_chain; new->next = *pmy_chain; @@ -1776,6 +1776,51 @@ wrap_here (char *indent) } } +/* Print input string to gdb_stdout, filtered, with wrap, + arranging strings in columns of n chars. String can be + right or left justified in the column. Never prints + trailing spaces. String should never be longer than + width. FIXME: this could be useful for the EXAMINE + command, which currently doesn't tabulate very well. */ + +void +puts_filtered_tabular (char *string, int width, int right) +{ + int spaces = 0; + int stringlen; + char *spacebuf; + + gdb_assert (chars_per_line > 0); + if (chars_per_line == UINT_MAX) + { + fputs_filtered (string, gdb_stdout); + fputs_filtered ("\n", gdb_stdout); + return; + } + + if (((chars_printed - 1) / width + 2) * width >= chars_per_line) + fputs_filtered ("\n", gdb_stdout); + + if (width >= chars_per_line) + width = chars_per_line - 1; + + stringlen = strlen (string); + + if (chars_printed > 0) + spaces = width - (chars_printed - 1) % width - 1; + if (right) + spaces += width - stringlen; + + spacebuf = alloca (spaces + 1); + spacebuf[spaces] = '\0'; + while (spaces--) + spacebuf[spaces] = ' '; + + fputs_filtered (spacebuf, gdb_stdout); + fputs_filtered (string, gdb_stdout); +} + + /* Ensure that whatever gets printed next, using the filtered output commands, starts at the beginning of the line. I.E. if there is any pending output for the current line, flush it and start a new @@ -2203,15 +2248,18 @@ print_spaces_filtered (int n, struct ui_file *stream) fputs_filtered (n_spaces (n), stream); } -/* C++ demangler stuff. */ +/* C++/ObjC demangler stuff. */ -/* fprintf_symbol_filtered 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. */ +/* fprintf_symbol_filtered 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 -fprintf_symbol_filtered (struct ui_file *stream, char *name, enum language lang, +fprintf_symbol_filtered (struct ui_file *stream, + char *name, + enum language lang, int arg_mode) { char *demangled; @@ -2233,6 +2281,11 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name, enum language lang, case language_java: demangled = cplus_demangle (name, arg_mode | DMGL_JAVA); break; +#if 0 /* Enable once objective-c support is turned on. */ + case language_objc: + demangled = objc_demangle (name); + break; +#endif #if 0 /* OBSOLETE case language_chill: */ /* OBSOLETE demangled = chill_demangle (name); */ @@ -2352,7 +2405,7 @@ initialize_utils (void) add_show_from_set (add_set_cmd ("demangle", class_support, var_boolean, (char *) &demangle, - "Set demangling of encoded C++ names when displaying symbols.", + "Set demangling of encoded C++/ObjC names when displaying symbols.", &setprintlist), &showprintlist); @@ -2380,7 +2433,7 @@ initialize_utils (void) add_show_from_set (add_set_cmd ("asm-demangle", class_support, var_boolean, (char *) &asm_demangle, - "Set demangling of C++ names in disassembly listings.", + "Set demangling of C++/ObjC names in disassembly listings.", &setprintlist), &showprintlist); } |