This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] stack.c: move address printing into hook (fwd)

---------- Forwarded message ----------
Date: Fri, 28 Dec 2001 07:47:18 -0800 (PST)
From: Keith Seitz <>
Subject: [RFA] stack.c: move address printing into hook


print_frame_info_base in stack.c is responsible for a great many things.
It is used when doing backtraces, navigating the stack view, and when the
inferior stops.

When the inferior stops in mid-statement (after a stepi/nexti),
print_frame_info_base is called to print out the current frame's PC and
then it calls print_frame_info_listing_hook (or print_source_lines) to
print out the contents of the source line.

This is all fine and dandy for the command line, but for those user
interfaces (like Insight) which define a print_frame_info_listing_hook to
override this behavior, this address printing is an annoyance. It should
be part of the if-else clause when the hook overrides the default

The following patch folds this address printing into the hook, where it
will not interfere with other UIs. This patch is obviously a no-op for the
CLI, which does not define a print_frame_info_listing_hook.

[Of course, the thought occurs to me that we could extract this bit of
CLI-ness from "generic"/"core" gdb by moving all the logic into a this
hook for the cli...]


2001-12-28  Keith Seitz  <>

	* stack.c (print_frame_info_base): Print the frame's pc
	only if when print_frame_info_listing_hook is not defined.

Index: stack.c
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.26
diff -u -p -r1.26 stack.c
--- stack.c	2001/11/10 21:34:56	1.26
+++ stack.c	2001/12/28 15:43:05
@@ -399,20 +399,31 @@ print_frame_info_base (struct frame_info
       if (!done)
-	  if (addressprint && mid_statement)
+	  if (print_frame_info_listing_hook)
+	    print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0);
+	  else
+	      /* We used to do this earlier, but that is clearly
+		 wrong. This function is used by many different
+		 parts of gdb, including normal_stop in infrun.c,
+		 which uses this to print out the current PC
+		 when we stepi/nexti into the middle of a source
+		 line. Only the command line really wants this
+		 behavior. Other UIs probably would like the
+		 ability to decide for themselves if it is desired. */
+	      if (addressprint && mid_statement)
+		{
 #ifdef UI_OUT
-	      ui_out_field_core_addr (uiout, "addr", fi->pc);
-	      ui_out_text (uiout, "\t");
+		  ui_out_field_core_addr (uiout, "addr", fi->pc);
+		  ui_out_text (uiout, "\t");
-	      print_address_numeric (fi->pc, 1, gdb_stdout);
-	      printf_filtered ("\t");
+		  print_address_numeric (fi->pc, 1, gdb_stdout);
+		  printf_filtered ("\t");
+		}
+	      print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
-	  if (print_frame_info_listing_hook)
-	    print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0);
-	  else
-	    print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
       current_source_line = max (sal.line - lines_to_list / 2, 1);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]