Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] stack.c: move address printing into hook (fwd)
@ 2002-01-10 16:03 Keith Seitz
  2002-01-13  8:39 ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Seitz @ 2002-01-10 16:03 UTC (permalink / raw)
  To: gdb-patches



---------- 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);
     }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] stack.c: move address printing into hook (fwd)
  2002-01-10 16:03 [RFA] stack.c: move address printing into hook (fwd) Keith Seitz
@ 2002-01-13  8:39 ` Andrew Cagney
  2002-01-13 12:20   ` Keith Seitz
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-01-13  8:39 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches

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


Yes ok.

(This continues to work around the more fundamental problem of Insight 
not being able to ask GDB ``where are you'' and instead must still reap 
that info from the stop messages).

Andrew




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] stack.c: move address printing into hook (fwd)
  2002-01-13  8:39 ` Andrew Cagney
@ 2002-01-13 12:20   ` Keith Seitz
  2002-01-13 12:40     ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Seitz @ 2002-01-13 12:20 UTC (permalink / raw)
  To: gdb-patches

On Sun, 13 Jan 2002, Andrew Cagney wrote:

> Yes ok.

Committed. Thanks.

> (This continues to work around the more fundamental problem of Insight
> not being able to ask GDB ``where are you'' and instead must still reap
> that info from the stop messages).

Yup. Still needing that patch for handle_inferior_event...

Of course, if you just mention to me how you'd like it to be solved, I
would be more than happy to try to implement something to your liking...
;-)

Keith



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] stack.c: move address printing into hook (fwd)
  2002-01-13 12:20   ` Keith Seitz
@ 2002-01-13 12:40     ` Andrew Cagney
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-01-13 12:40 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches

> Of course, if you just mention to me how you'd like it to be solved, I
> would be more than happy to try to implement something to your liking...
> ;-)


The theory is simple.

The code building the stop message should be separate to the code 
determining why the target stopped.  That way the CLI and the MI/Insight 
can each separatly query for the stop reason.

This in turn means that, for Insight, your logic can read:

	when (target stopped event)
	  get stop reason
	  process stop reason

I think I've now attempted this three times and three times it has 
beaten me :-(  The way GDB constructs its stop info is totally screwed up.

Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-01-13 20:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-10 16:03 [RFA] stack.c: move address printing into hook (fwd) Keith Seitz
2002-01-13  8:39 ` Andrew Cagney
2002-01-13 12:20   ` Keith Seitz
2002-01-13 12:40     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox