Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: <gdb-patches@sources.redhat.com>
Subject: [RFA] stack.c: move address printing into hook (fwd)
Date: Thu, 10 Jan 2002 16:03:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.33.0201101603280.29657-100000@makita.cygnus.com> (raw)



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

Hi,

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
behavior.

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...]

Keith

ChangeLog
2001-12-28  Keith Seitz  <keiths@redhat.com>

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

Patch
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
 				     fi->pc);
       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");
 #else
-	      print_address_numeric (fi->pc, 1, gdb_stdout);
-	      printf_filtered ("\t");
+		  print_address_numeric (fi->pc, 1, gdb_stdout);
+		  printf_filtered ("\t");
 #endif
+		}
+
+	      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);
     }



             reply	other threads:[~2002-01-11  0:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-10 16:03 Keith Seitz [this message]
2002-01-13  8:39 ` Andrew Cagney
2002-01-13 12:20   ` Keith Seitz
2002-01-13 12:40     ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.33.0201101603280.29657-100000@makita.cygnus.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox