From 41270571562fe1b32a38ba7a49dac8a9e416d1c8 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Sat, 8 Apr 1995 09:59:02 +0000 Subject: [PATCH] * mdebugread.c (parse_symbol): Use new variable nodebug_var_symbol_type as type of variables which don't have any ecoff debug info associated with them. (parse_symbol, parse_procedure): Use heuristics to determine if functions were compiled without debugging info and change their type to nodebug_function_symbol_type. (_initialize_mdebugread): Initialize nodebug_*_symbol_type. * source.c (line_info): Clear sal.pc for `info line' without arguments. --- gdb/ChangeLog | 13 +++++++++ gdb/mdebugread.c | 48 ++++++++++++++++++++++++++++-- gdb/source.c | 76 ++++++++++++++++++++++-------------------------- 3 files changed, 92 insertions(+), 45 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 221546b809c..e7360a474fb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Sat Apr 8 02:47:45 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * mdebugread.c (parse_symbol): Use new variable + nodebug_var_symbol_type as type of variables which don't have any + ecoff debug info associated with them. + (parse_symbol, parse_procedure): Use heuristics to determine if + functions were compiled without debugging info and change their + type to nodebug_function_symbol_type. + (_initialize_mdebugread): Initialize nodebug_*_symbol_type. + + * source.c (line_info): Clear sal.pc for `info line' without + arguments. + Fri Apr 7 17:43:01 1995 Stu Grossman (grossman@andros.cygnus.com) * monitor.c: make_xmodem_packet and print_xmodem_packet go away. diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 5cabe8db6d9..7bf8e4f8197 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -278,6 +278,15 @@ static struct type *mdebug_type_fixed_dec; static struct type *mdebug_type_float_dec; static struct type *mdebug_type_string; +/* Types for symbols from files compiled without debugging info. */ + +static struct type *nodebug_func_symbol_type; +static struct type *nodebug_var_symbol_type; + +/* Nonzero if we have seen ecoff debugging info for a file. */ + +static int found_ecoff_debugging_info; + /* Forward declarations */ static int @@ -744,9 +753,9 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) SYMBOL_CLASS (s) = class; add_symbol (s, b); - /* Type could be missing in a number of cases */ - if (sh->sc == scUndefined || sh->sc == scNil) - SYMBOL_TYPE (s) = builtin_type_int; /* undefined? */ + /* Type could be missing if file is compiled without debugging info. */ + if (sh->sc == scUndefined || sh->sc == scNil || sh->index == indexNil) + SYMBOL_TYPE (s) = nodebug_var_symbol_type; else SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name); /* Value of a data symbol is its memory address */ @@ -754,6 +763,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) case stParam: /* arg to procedure, goes into current block */ max_gdbinfo++; + found_ecoff_debugging_info = 1; top_stack->numargs++; /* Special GNU C++ name. */ @@ -879,6 +889,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) unknown-type blocks of info about structured data. `type_code' has been set to the proper TYPE_CODE, if we know it. */ structured_common: + found_ecoff_debugging_info = 1; push_parse_stack (); top_stack->blocktype = stBlock; @@ -1101,6 +1112,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) } case_stBlock_code: + found_ecoff_debugging_info = 1; /* beginnning of (code) block. Value of symbol is the displacement from procedure start */ push_parse_stack (); @@ -1247,6 +1259,8 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) break; case stTypedef: /* type definition */ + found_ecoff_debugging_info = 1; + /* Typedefs for forward declarations and opaque structs from alpha cc are handled by cross_ref, skip them. */ if (sh->iss == 0) @@ -1886,6 +1900,26 @@ parse_procedure (pr, search_symtab, first_off, pst) e->pdr.regoffset = -4; } } + + /* It would be reasonable that functions that have been compiled + without debugging info have a btNil type for their return value, + and functions that are void and are compiled with debugging info + have btVoid. + gcc and DEC f77 put out btNil types for both cases, so btNil is mapped + to TYPE_CODE_VOID in parse_type to get the `compiled with debugging info' + case right. + The glevel field in cur_fdr could be used to determine the presence + of debugging info, but GCC doesn't always pass the -g switch settings + to the assembler and GAS doesn't set the glevel field from the -g switch + settings. + To work around these problems, the return value type of a TYPE_CODE_VOID + function is adjusted accordingly if no debugging info was found in the + compilation unit. */ + + if (processing_gcc_compilation == 0 + && found_ecoff_debugging_info == 0 + && TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID) + SYMBOL_TYPE (s) = nodebug_func_symbol_type; } /* Relocate the extra function info pointed to by the symbol table. */ @@ -3226,6 +3260,7 @@ psymtab_to_symtab_1 (pst, filename) top_stack->cur_type = 0; top_stack->procadr = 0; top_stack->numargs = 0; + found_ecoff_debugging_info = 0; if (fh) { @@ -4102,4 +4137,11 @@ _initialize_mdebugread () TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0, "floating decimal", (struct objfile *) NULL); + + nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0, + "", NULL); + TYPE_TARGET_TYPE (nodebug_func_symbol_type) = builtin_type_int; + nodebug_var_symbol_type = + init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0, + "", NULL); } diff --git a/gdb/source.c b/gdb/source.c index a300f5df80c..59f8de0ad0a 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1,5 +1,5 @@ /* List lines of source files for GDB, the GNU debugger. - Copyright 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994 + Copyright 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. This file is part of GDB. @@ -36,6 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symfile.h" #include "objfiles.h" #include "annotate.h" +#include "gdbtypes.h" #ifndef DIRNAME_SEPARATOR #define DIRNAME_SEPARATOR ':' @@ -560,12 +561,19 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened) } /* start-sanitize-mpw */ #ifdef MPW - if (1) { - printf("openp on %s, path %s mode %d prot %d\n returned %d", - string, path, mode, prot, fd); - if (*filename_opened) - printf(" (filename is %s)", *filename_opened); - printf("\n"); + /* This is a debugging hack that can go away when all combinations + of Mac and Unix names are handled reasonably. */ + { + extern int debug_openp; + + if (debug_openp) + { + printf("openp on %s, path %s mode %d prot %d\n returned %d", + string, path, mode, prot, fd); + if (*filename_opened) + printf(" (filename is %s)", *filename_opened); + printf("\n"); + } } #endif /* end-sanitize-mpw */ @@ -641,7 +649,7 @@ open_source_file (s) if (p != s->filename) result = openp (path, 0, p, O_RDONLY, 0, &s->fullname); } -#endif +#endif /* MPW */ /* end-sanitize-mpw */ if (result >= 0) { @@ -1158,6 +1166,7 @@ line_info (arg, from_tty) { sal.symtab = current_source_symtab; sal.line = last_line_listed; + sal.pc = 0; sals.nelts = 1; sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); @@ -1313,6 +1322,9 @@ forward_search_command (regex, from_tty) /* Match! */ fclose (stream); print_source_lines (current_source_symtab, line, line+1, 0); + set_internalvar (lookup_internalvar ("_"), + value_from_longest (builtin_type_int, + (LONGEST) line)); current_source_line = max (line - lines_to_list / 2, 1); return; } @@ -1386,6 +1398,9 @@ reverse_search_command (regex, from_tty) fclose (stream); print_source_lines (current_source_symtab, line, line+1, 0); + set_internalvar (lookup_internalvar ("_"), + value_from_longest (builtin_type_int, + (LONGEST) line)); current_source_line = max (line - lines_to_list / 2, 1); return; } @@ -1433,66 +1448,43 @@ $cdir in the path means the compilation directory of the source file.", add_info ("source", source_info, "Information about the current source file."); -/* start-sanitize-mpw */ -#ifndef MPW_C -/* end-sanitize-mpw */ add_info ("line", line_info, - "Core addresses of the code for a source line.\n\ + concat ("Core addresses of the code for a source line.\n\ Line can be specified as\n\ LINENUM, to list around that line in current file,\n\ FILE:LINENUM, to list around that line in that file,\n\ FUNCTION, to list around beginning of that function,\n\ FILE:FUNCTION, to distinguish among like-named static functions.\n\ +", "\ Default is to describe the last source line that was listed.\n\n\ This sets the default address for \"x\" to the line's first instruction\n\ so that \"x/i\" suffices to start examining the machine code.\n\ -The address is also stored as the value of \"$_\"."); -/* start-sanitize-mpw */ -#else - add_info ("line", line_info, - "Core addresses of the code for a source line. \n\ -Line can be specified as \n\ - LINENUM, to list around that line in current file, \n\ - FILE:LINENUM, to list around that line in that file, \n\ -Default is to describe the last source line that was listed. \n\n\ -The address is also stored as the value of \"$_\". "); -#endif -/* end-sanitize-mpw */ +The address is also stored as the value of \"$_\".", NULL)); add_com ("forward-search", class_files, forward_search_command, - "Search for regular expression (see regex(3)) from last line listed."); + "Search for regular expression (see regex(3)) from last line listed.\n\ +The matching line number is also stored as the value of \"$_\"."); add_com_alias ("search", "forward-search", class_files, 0); add_com ("reverse-search", class_files, reverse_search_command, - "Search backward for regular expression (see regex(3)) from last line listed."); + "Search backward for regular expression (see regex(3)) from last line listed.\n\ +The matching line number is also stored as the value of \"$_\"."); -/* start-sanitize-mpw */ -#ifndef MPW_C -/* end-sanitize-mpw */ add_com ("list", class_files, list_command, - "List specified function or line.\n\ + concat ("List specified function or line.\n\ With no argument, lists ten more lines after or around previous listing.\n\ \"list -\" lists the ten lines before a previous ten-line listing.\n\ One argument specifies a line, and ten lines are listed around that line.\n\ Two arguments with comma between specify starting and ending lines to list.\n\ +", "\ Lines can be specified in these ways:\n\ LINENUM, to list around that line in current file,\n\ FILE:LINENUM, to list around that line in that file,\n\ FUNCTION, to list around beginning of that function,\n\ FILE:FUNCTION, to distinguish among like-named static functions.\n\ *ADDRESS, to list around the line containing that address.\n\ -With two args if one is empty it stands for ten lines away from the other arg."); -/* start-sanitize-mpw */ -#else /* MPW_C */ - add_com ("list", class_files, list_command, - "List specified function or line.\n\ -With no argument, lists ten more lines after or around previous listing. \n\ -One argument specifies a line, and ten lines are listed around that line. \n\ -Two arguments with comma between specify starting and ending lines to list. \n\ -Lines can be specified in these ways:\n\ -With two args if one is empty it stands for ten lines away from the other arg. "); -#endif /* MPW_C */ -/* end-sanitize-mpw */ +With two args if one is empty it stands for ten lines away from the other arg.", NULL)); + add_com_alias ("l", "list", class_files, 1); add_show_from_set -- 2.30.2