diff options
author | John Gilmore <gnu@cygnus> | 1991-09-11 01:49:50 +0000 |
---|---|---|
committer | John Gilmore <gnu@cygnus> | 1991-09-11 01:49:50 +0000 |
commit | cadbb07a69baa48a153c0c4c148d24342ce4474f (patch) | |
tree | 7e2762cc1ddd1619c453c8b658dc961383b63531 | |
parent | b1815762f9f0a4579e4da7b7b1b5427be3c35c93 (diff) | |
download | gdb-cadbb07a69baa48a153c0c4c148d24342ce4474f.zip gdb-cadbb07a69baa48a153c0c4c148d24342ce4474f.tar.gz gdb-cadbb07a69baa48a153c0c4c148d24342ce4474f.tar.bz2 |
* core.c (core_file_command): Print frame at coredump with
its level number, by calling print_stack_frame.
* frame.h: Add selected_frame_level, print_stack_frame.
* frame.h, stack.c: Remove print_sel_frame, print_selected_frame.
* convex-tdep.c, convex-xdep.c, infcmd.c, inflow.c, infrun.c:
Change print_sel_frame and print_selected_frame callers to
print_stack_frame.
* dbxread.c (read_ofile_symtab): Avoid empty else clause.
* symfile.c (free_named_symtabs): Ditto.
* main.c (main): wrap_here needs an arg.
* solib.c (find_solib): Avoid memory access if _DYNAMIC is zero.
(solib_add): Avoid noise.
(solib_create_inferior_hook): Lint.
(sharedlibrary_command): Move dont_repeat to here.
* utils.c (error): Call wrap_here to force buffered output.
Small patches from Peter Schauer:
* coffread.c (start_symtab): Free any existing line_vector before
malloc-ing new one.
(read_coff_symtab): Ditto for type_vector.
* source.c (lines_to_list): New variable, replacing function.
(all uses): Use as variable.
(_initialize_source): Add 'set listsize' and 'show listsize'.
* utils.c (lines_to_list): Remove function.
* stack.c (print_frame_info): Use as variable.
* defs.h (lines_to_list): Remove declaration.
-rw-r--r-- | gdb/ChangeLog | 32 | ||||
-rw-r--r-- | gdb/coffread.c | 8 | ||||
-rw-r--r-- | gdb/convex-tdep.c | 2 | ||||
-rw-r--r-- | gdb/convex-xdep.c | 2 | ||||
-rw-r--r-- | gdb/core.c | 7 | ||||
-rw-r--r-- | gdb/inflow.c | 4 | ||||
-rw-r--r-- | gdb/stack.c | 84 |
7 files changed, 87 insertions, 52 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 701b8e3..397f235 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,35 @@ +Tue Sep 10 09:19:29 1991 John Gilmore (gnu at cygint.cygnus.com) + + * core.c (core_file_command): Print frame at coredump with + its level number, by calling print_stack_frame. + * frame.h: Add selected_frame_level, print_stack_frame. + * frame.h, stack.c: Remove print_sel_frame, print_selected_frame. + * convex-tdep.c, convex-xdep.c, infcmd.c, inflow.c, infrun.c: + Change print_sel_frame and print_selected_frame callers to + print_stack_frame. + + * dbxread.c (read_ofile_symtab): Avoid empty else clause. + * symfile.c (free_named_symtabs): Ditto. + * main.c (main): wrap_here needs an arg. + * solib.c (find_solib): Avoid memory access if _DYNAMIC is zero. + (solib_add): Avoid noise. + (solib_create_inferior_hook): Lint. + (sharedlibrary_command): Move dont_repeat to here. + * utils.c (error): Call wrap_here to force buffered output. + + Small patches from Peter Schauer: + + * coffread.c (start_symtab): Free any existing line_vector before + malloc-ing new one. + (read_coff_symtab): Ditto for type_vector. + + * source.c (lines_to_list): New variable, replacing function. + (all uses): Use as variable. + (_initialize_source): Add 'set listsize' and 'show listsize'. + * utils.c (lines_to_list): Remove function. + * stack.c (print_frame_info): Use as variable. + * defs.h (lines_to_list): Remove declaration. + Mon Sep 9 13:45:57 1991 John Gilmore (gnu at cygint.cygnus.com) * breakpoint.c (insert_breakpoints): Restore warning about diff --git a/gdb/coffread.c b/gdb/coffread.c index c695056..33e014d 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -439,8 +439,10 @@ start_symtab () #endif #endif - /* Initialize the source file information for this file. */ + /* Initialize the source file line number information for this file. */ + if (line_vector) /* Unlikely, but maybe possible? */ + free (line_vector); line_vector_index = 0; line_vector_length = 1000; prev_line_number = -2; /* Force first line number to be explicit */ @@ -831,6 +833,8 @@ read_coff_symtab (desc, nsyms) last_source_file = 0; bzero (opaque_type_chain, sizeof opaque_type_chain); + if (type_vector) /* Get rid of previous one */ + free (type_vector); type_vector_length = 160; type_vector = (struct typevector *) xmalloc (sizeof (struct typevector) @@ -1697,7 +1701,7 @@ decode_type (cs, c_type, aux) /* Reference to existing type */ if (cs->c_nsyms > 1 && aux->x_sym.x_tagndx.l != 0) { - type = coff_alloc_type (aux->x_sym.x_tagndx); + type = coff_alloc_type (aux->x_sym.x_tagndx.l); return type; } diff --git a/gdb/convex-tdep.c b/gdb/convex-tdep.c index d77c25c..03da95d 100644 --- a/gdb/convex-tdep.c +++ b/gdb/convex-tdep.c @@ -723,7 +723,7 @@ set_thread_command (arg) set_current_frame (create_new_frame (read_register (FP_REGNUM), read_pc ())); select_frame (get_current_frame (), 0); - print_sel_frame (1); + print_stack_frame (selected_frame, selected_frame_level, -1); } /* Here on CONT command; gdb's dispatch address is changed to come here. diff --git a/gdb/convex-xdep.c b/gdb/convex-xdep.c index d39872b..57646ab 100644 --- a/gdb/convex-xdep.c +++ b/gdb/convex-xdep.c @@ -976,7 +976,7 @@ core_file_command (filename, from_tty) select_frame (get_current_frame (), 0); validate_files (); - print_sel_frame (1); + print_stack_frame (selected_frame, selected_frame_level, -1); } else if (from_tty) printf_filtered ("No core file now.\n"); @@ -170,11 +170,12 @@ core_open (filename, from_tty) #ifdef SOLIB_ADD (void) catch_errors (solib_add_stub, (char *)from_tty, (char *)0); #endif + /* Now, set up the frame cache, and print the top of stack */ - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); + set_current_frame (create_new_frame (read_register (FP_REGNUM), + read_pc ())); select_frame (get_current_frame (), 0); - print_sel_frame (0); /* Print the top frame and source line */ + print_stack_frame (selected_frame, selected_frame_level, 1); } else { printf ( "Warning: you won't be able to access this core file until you terminate\n\ diff --git a/gdb/inflow.c b/gdb/inflow.c index d267ffc..fd8f0b8 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -381,7 +381,7 @@ kill_command (arg, from_tty) if (selected_frame == NULL) fputs_filtered ("No selected stack frame.\n", stdout); else - print_sel_frame (0); + print_stack_frame (selected_frame, selected_frame_level, 1); } } @@ -478,7 +478,7 @@ Report which ones can be written."); inferior_pid = 0; ioctl (0, TIOCGETP, &sg_ours); - fcntl (0, F_GETFL, tflags_ours); + tflags_ours = fcntl (0, F_GETFL, 0); #if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) ioctl (0, TIOCGETC, &tc_ours); diff --git a/gdb/stack.c b/gdb/stack.c index 09a7f49..6eb0864 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3,19 +3,19 @@ This file is part of GDB. -GDB is free software; you can redistribute it and/or modify +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 1, or (at your option) -any later version. +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -GDB is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> @@ -31,6 +31,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int addressprint; /* Print addresses, or stay symbolic only? */ extern int info_verbose; /* Verbosity of symbol reading msgs */ +extern unsigned lines_to_list; /* # of lines "list" command shows by default */ extern char *reg_names[]; /* Names of registers */ /* Thie "selected" stack frame is used by default for local and arg access. @@ -61,7 +62,7 @@ void print_frame_info (); If SOURCE is 1, print the source line as well. If SOURCE is -1, print ONLY the source line. */ -static void +void print_stack_frame (frame, level, source) FRAME frame; int level; @@ -187,7 +188,7 @@ print_frame_info (fi, level, source, args) printf_filtered ("0x%x\t", fi->pc); print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); } - current_source_line = max (sal.line - lines_to_list () / 2, 1); + current_source_line = max (sal.line - lines_to_list/2, 1); } if (source != 0) set_default_breakpoint (1, fi->pc, sal.symtab, sal.line); @@ -195,24 +196,6 @@ print_frame_info (fi, level, source, args) fflush (stdout); } -/* Call here to print info on selected frame, after a trap. */ - -void -print_sel_frame (just_source) - int just_source; -{ - print_stack_frame (selected_frame, -1, just_source ? -1 : 1); -} - -/* Print info on the selected frame, including level number - but not source. */ - -void -print_selected_frame () -{ - print_stack_frame (selected_frame, selected_frame_level, 0); -} - void flush_cached_frames (); #ifdef FRAME_SPECIFICATION_DYADIC @@ -592,13 +575,11 @@ print_block_frame_locals (b, frame, stream) return values_printed; } -/* Same, but print labels. - FIXME, this does not even reference FRAME... --gnu */ +/* Same, but print labels. */ static int -print_block_frame_labels (b, frame, have_default, stream) +print_block_frame_labels (b, have_default, stream) struct block *b; - register FRAME frame; int *have_default; register FILE *stream; { @@ -728,7 +709,7 @@ print_frame_label_vars (frame, this_level_only, stream) { if (blocks_printed[index] == 0) { - if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), frame, &have_default, stream)) + if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream)) values_printed = 1; blocks_printed[index] = 1; } @@ -762,18 +743,16 @@ locals_info (args, from_tty) char *args; int from_tty; { - if (!target_has_stack) - error ("No stack."); - + if (!selected_frame) + error ("No frame selected."); print_frame_local_vars (selected_frame, stdout); } static void catch_info () { - if (!target_has_stack) - error ("No stack."); - + if (!selected_frame) + error ("No frame selected."); print_frame_label_vars (selected_frame, 0, stdout); } @@ -834,8 +813,8 @@ print_frame_arg_vars (frame, stream) static void args_info () { - if (!target_has_stack) - error ("No stack."); + if (!selected_frame) + error ("No frame selected."); print_frame_arg_vars (selected_frame, stdout); } @@ -913,6 +892,11 @@ find_relative_frame (frame, level_offset_ptr) The following algorithm is linear. */ if (*level_offset_ptr < 0) { +#if 0 +/* This is ancient and unnecessary? -- gnu@cygnus.com + It also loops forever if frame #0 is not current_frame (e.g. when we have + used the "frame" command after the stack was invalid). */ + /* First put frame1 at innermost frame and frame2 N levels up from there. */ frame1 = get_current_frame (); @@ -931,6 +915,15 @@ find_relative_frame (frame, level_offset_ptr) frame2 = get_prev_frame (frame2); } return frame1; +#else + while (*level_offset_ptr < 0) { + frame1 = get_next_frame (frame); + if (!frame1) + break; + frame = frame1; + (*level_offset_ptr)++; + } +#endif } return frame; } @@ -954,10 +947,15 @@ frame_command (level_exp, from_tty) frame = parse_frame_specification (level_exp); - for (frame1 = get_prev_frame (0); - frame1 && frame1 != frame; - frame1 = get_prev_frame (frame1)) - level++; + /* Try to figure out what level this frame is. But if there is + no current stack, don't error out -- let the user set one. */ + frame1 = 0; + if (get_current_frame()) { + for (frame1 = get_prev_frame (0); + frame1 && frame1 != frame; + frame1 = get_prev_frame (frame1)) + level++; + } if (!frame1) level = 0; |