Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] catchpoints bring output in-line with breakpoints output
@ 2008-05-27 20:01 Aleksandar Ristovski
  2008-05-27 21:32 ` Aleksandar Ristovski
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2008-05-27 20:01 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

Hello,

This patch brings catchpoint output in line with breakpoints output:

CLI: 'Temporary catchpoint' when a catchpoint is temporary (vs. 'Catchpoint' when not).
MI: Added fields: "reason", "disp", "bkptno"

Thanks,


Aleksandar Ristovski
QNX Software Systems


	* breakpoint.c (print_exception_catchpoint): In CLI add 'Temporary' for
	temporary catchpoints.  In MI add missing fields 'reason', 'disp', 
	'bkptno'.

[-- Attachment #2: catchpointsMI20080527.diff --]
[-- Type: text/plain, Size: 1587 bytes --]

Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.321
diff -u -p -r1.321 breakpoint.c
--- gdb/breakpoint.c	4 May 2008 19:38:59 -0000	1.321
+++ gdb/breakpoint.c	27 May 2008 18:00:37 -0000
@@ -6495,14 +6495,34 @@ catch_unload_command_1 (char *arg, int t
 static enum print_stop_action
 print_exception_catchpoint (struct breakpoint *b)
 {
+  int bp_temp;
+  char msg[160];
+  const char * msgspec;
+  const char msgfmt[] = "\n%s %d (exception %s)\n";
+
   annotate_catchpoint (b->number);
 
   if (strstr (b->addr_string, "throw") != NULL)
-    printf_filtered (_("\nCatchpoint %d (exception thrown)\n"),
-		     b->number);
+    msgspec = "thrown";
   else
-    printf_filtered (_("\nCatchpoint %d (exception caught)\n"),
-		     b->number);
+    msgspec = "caught";
+  if (b->loc->address != b->loc->requested_address)
+    breakpoint_adjustment_warning (b->loc->requested_address,
+	                           b->loc->address,
+				   b->number, 1);
+  bp_temp = b->loc->owner->disposition == disp_del;
+  sprintf (msg, msgfmt, 
+	   bp_temp ? "Temporary catchpoint" : "Catchpoint", 
+	   b->number, msgspec);
+  ui_out_text (uiout, msg);
+  if (ui_out_is_mi_like_p (uiout))
+    {
+      ui_out_field_string (uiout, "reason", 
+			   async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
+      ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
+    }
+  ui_out_field_int (uiout, "bkptno", b->number);
+  ui_out_text (uiout, ", ");
 
   return PRINT_SRC_AND_LOC;
 }

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

* Re: [patch] catchpoints bring output in-line with breakpoints output
  2008-05-27 20:01 [patch] catchpoints bring output in-line with breakpoints output Aleksandar Ristovski
@ 2008-05-27 21:32 ` Aleksandar Ristovski
  2008-05-27 23:25   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2008-05-27 21:32 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]

Aleksandar Ristovski wrote:
> Hello,
> 
> This patch brings catchpoint output in line with breakpoints output:

The previous patch was not complete... mention was not changed (sorry). Now the complete diff is attached.

And I just noticed a bug I introduced with the pending catchpoints, tempflag was ignored (thus always creating permanent catchpoints)... oops on my behalf...



New ChangeLog:

2008-05-27  Aleksandar Ristovski  <aristovski@qnx.com>

	* breakpoint.c (print_exception_catchpoint): In CLI add 'Temporary' for
	temporary catchpoints.  In MI add missing fields 'reason', 'disp', 
	'bkptno'.
	(print_mention_exception_catchpoint): Add 'Temporary' for temporary
	catchpoints.
	(handle_gnu_v3_exceptions): Use tempflag.

[-- Attachment #2: catchpointsMI20080527.diff --]
[-- Type: text/plain, Size: 2582 bytes --]

Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.321
diff -u -p -r1.321 breakpoint.c
--- gdb/breakpoint.c	4 May 2008 19:38:59 -0000	1.321
+++ gdb/breakpoint.c	27 May 2008 18:38:00 -0000
@@ -6495,14 +6495,34 @@ catch_unload_command_1 (char *arg, int t
 static enum print_stop_action
 print_exception_catchpoint (struct breakpoint *b)
 {
+  int bp_temp;
+  char msg[160];
+  const char * msgspec;
+  const char msgfmt[] = "\n%s %d (exception %s)\n";
+
   annotate_catchpoint (b->number);
 
   if (strstr (b->addr_string, "throw") != NULL)
-    printf_filtered (_("\nCatchpoint %d (exception thrown)\n"),
-		     b->number);
+    msgspec = "thrown";
   else
-    printf_filtered (_("\nCatchpoint %d (exception caught)\n"),
-		     b->number);
+    msgspec = "caught";
+  if (b->loc->address != b->loc->requested_address)
+    breakpoint_adjustment_warning (b->loc->requested_address,
+	                           b->loc->address,
+				   b->number, 1);
+  bp_temp = b->loc->owner->disposition == disp_del;
+  sprintf (msg, msgfmt, 
+	   bp_temp ? "Temporary catchpoint" : "Catchpoint", 
+	   b->number, msgspec);
+  ui_out_text (uiout, msg);
+  if (ui_out_is_mi_like_p (uiout))
+    {
+      ui_out_field_string (uiout, "reason", 
+			   async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
+      ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
+    }
+  ui_out_field_int (uiout, "bkptno", b->number);
+  ui_out_text (uiout, ", ");
 
   return PRINT_SRC_AND_LOC;
 }
@@ -6530,10 +6550,15 @@ print_one_exception_catchpoint (struct b
 static void
 print_mention_exception_catchpoint (struct breakpoint *b)
 {
+  int bp_temp;
+
+  bp_temp = b->loc->owner->disposition == disp_del;
   if (strstr (b->addr_string, "throw") != NULL)
-    printf_filtered (_("Catchpoint %d (throw)"), b->number);
+    printf_filtered (bp_temp ? _("Temporary catchpoint %d (throw)")
+			     : _("Catchpoint %d (throw)"), b->number);
   else
-    printf_filtered (_("Catchpoint %d (catch)"), b->number);
+    printf_filtered (bp_temp ? _("Temporary catchpoint %d (catch)")
+			     : _("Catchpoint %d (catch)"), b->number);
 }
 
 static struct breakpoint_ops gnu_v3_exception_catchpoint_ops = {
@@ -6555,7 +6580,7 @@ handle_gnu_v3_exceptions (int tempflag, 
 
   break_command_really (trigger_func_name, cond_string, -1,
 			0 /* condition and thread are valid.  */,
-			0, 0,
+			tempflag, 0,
 			0,
 			AUTO_BOOLEAN_TRUE /* pending */,
 			&gnu_v3_exception_catchpoint_ops, from_tty);

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

* Re: [patch] catchpoints bring output in-line with breakpoints output
  2008-05-27 21:32 ` Aleksandar Ristovski
@ 2008-05-27 23:25   ` Eli Zaretskii
  2008-05-28 15:20     ` Aleksandar Ristovski
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2008-05-27 23:25 UTC (permalink / raw)
  To: Aleksandar Ristovski; +Cc: gdb-patches

> From:  Aleksandar Ristovski <aristovski@qnx.com>
> Date:  Tue, 27 May 2008 14:43:10 -0400
> 
> > This patch brings catchpoint output in line with breakpoints output:

Thanks!  I have one comment on your changes:

>  static enum print_stop_action
>  print_exception_catchpoint (struct breakpoint *b)
>  {
> +  int bp_temp;
> +  char msg[160];
> +  const char * msgspec;
> +  const char msgfmt[] = "\n%s %d (exception %s)\n";

This is not a good idea, because it defeats translation.  For
starters, this format string will not be caught by xgettext and won't
be in the message catalog.  Moreover, ...

> +  sprintf (msg, msgfmt, 
> +	   bp_temp ? "Temporary catchpoint" : "Catchpoint", 
> +	   b->number, msgspec);

... this kind of assembly of a sentence on the flight is bad, because
it doesn't leave the translators an opportunity to see a complete
phrase, and thus the concatenation of 2 fragments translated
independently might well produce a sentence that is invalid in the
target language.

Please instead use the technique you used in another portion of the patch:

> +    printf_filtered (bp_temp ? _("Temporary catchpoint %d (throw)")
> +			     : _("Catchpoint %d (throw)"), b->number);
>    else
> -    printf_filtered (_("Catchpoint %d (catch)"), b->number);
> +    printf_filtered (bp_temp ? _("Temporary catchpoint %d (catch)")
> +			     : _("Catchpoint %d (catch)"), b->number);

Here, the complete phrases are used, and the small waste of space for
repeating the common part is well worth the gain.


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

* Re: [patch] catchpoints bring output in-line with breakpoints output
  2008-05-27 23:25   ` Eli Zaretskii
@ 2008-05-28 15:20     ` Aleksandar Ristovski
  2008-05-28 16:25       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2008-05-28 15:20 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 4109 bytes --]

Eli Zaretskii wrote:
>> From:  Aleksandar Ristovski <aristovski@qnx.com>
>> Date:  Tue, 27 May 2008 14:43:10 -0400
>>
>>> This patch brings catchpoint output in line with breakpoints output:
> 
> Thanks!  I have one comment on your changes:
> 
>>  static enum print_stop_action
>>  print_exception_catchpoint (struct breakpoint *b)
>>  {
>> +  int bp_temp;
>> +  char msg[160];
>> +  const char * msgspec;
>> +  const char msgfmt[] = "\n%s %d (exception %s)\n";
> 
> This is not a good idea, because it defeats translation.  For
> starters, this format string will not be caught by xgettext and won't
> be in the message catalog.  Moreover, ...

Changed accordingly. I also adjusted MI output to better fit into breakpoint pattern. New diff attached.

Now as you will see, there is an issue with the MI output (scroll down): there is no difference between a normal breakpoint and a catchpoint hit. For now, I would leave it for future and view it as a separate issue (if it is an issue at all).


Thanks!

2008-05-27  Aleksandar Ristovski  <aristovski@qnx.com>

	* breakpoint.c (print_exception_catchpoint): In CLI add 'Temporary' for
	temporary catchpoints.  In MI add missing fields 'reason', 'disp', 
	'bkptno'.
	(print_mention_exception_catchpoint): Add 'Temporary' for temporary
	catchpoints.
	(handle_gnu_v3_exceptions): Use tempflag.


Sample output - CLI:

(gdb) tcatch catch
Temporary catchpoint 1 (catch)
(gdb) tcatch throw
Temporary catchpoint 2 (throw)
(gdb) catch catch
Note: breakpoint 1 also set at pc 0x8048764.
Catchpoint 3 (catch)
(gdb) catch throw
Note: breakpoint 2 also set at pc 0x8048724.
Catchpoint 4 (throw)
(gdb) info b
Num     Type           Disp Enb Address    What
1       breakpoint     del  y   0x08048764 exception catch
2       breakpoint     del  y   0x08048724 exception throw
3       breakpoint     keep y   0x08048764 exception catch
4       breakpoint     keep y   0x08048724 exception throw
(gdb) r
Starting program: /home/src/gdbcvs2/srcrw/src/build/gdb/main
Temporary catchpoint 2 (thrown), 0xb7eec455 in __cxa_throw ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
(gdb) c
Continuing.
Temporary catchpoint 1 (caught), 0xb7eeb896 in __cxa_begin_catch ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
(gdb) c
Program exited normally.
(gdb) r
Starting program: /home/src/gdbcvs2/srcrw/src/build/gdb/main
Catchpoint 4 (thrown), 0xb7f8a455 in __cxa_throw ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
(gdb) c
Continuing.
Catchpoint 3 (caught), 0xb7f89896 in __cxa_begin_catch ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6




Sample output - MI:
(gdb)
catch catch
&"catch catch\n"
~"Catchpoint 1 (catch)\n"
^done
(gdb)
catch throw
&"catch throw\n"
~"Catchpoint 2 (throw)\n"
^done
(gdb)
tcatch catch
&"tcatch catch\n"
~"Note: breakpoint 1 also set at pc 0x8048764.\n"
~"Temporary catchpoint 3 (catch)\n"
^done
(gdb)
tcatch throw
&"tcatch throw\n"
~"Note: breakpoint 2 also set at pc 0x8048724.\n"
~"Temporary catchpoint 4 (throw)\n"
^done
(gdb)
-exec-run
^running
(gdb)
=thread-created,id="1"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",thread-id="1",frame={addr="0xb7ee6455",func="__cxa_throw",args=[],from="/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6"}
(gdb)
-exec-continue
^running
(gdb)
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="1",frame={addr="0xb7ee5896",func="__cxa_begin_catch",args=[],from="/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6"}
(gdb)
-exec-continue
^running
(gdb)
*stopped,reason="exited-normally"
(gdb)
(gdb)
-exec-run
^running
(gdb)
=thread-created,id="1"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",thread-id="1",frame={addr="0xb7efb455",func="__cxa_throw",args=[],from="/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6"}
(gdb)
-exec-continue
^running
(gdb)
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="1",frame={addr="0xb7efa896",func="__cxa_begin_catch",args=[],from="/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6"}
(gdb)
-exec-continue
^running
(gdb)
*stopped,reason="exited-normally"
(gdb)

[-- Attachment #2: catchpointsMI200805271548.diff --]
[-- Type: text/plain, Size: 2697 bytes --]

Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.321
diff -u -p -r1.321 breakpoint.c
--- gdb/breakpoint.c	4 May 2008 19:38:59 -0000	1.321
+++ gdb/breakpoint.c	27 May 2008 19:48:34 -0000
@@ -6495,15 +6495,31 @@ catch_unload_command_1 (char *arg, int t
 static enum print_stop_action
 print_exception_catchpoint (struct breakpoint *b)
 {
-  annotate_catchpoint (b->number);
+  int bp_temp, bp_throw;
 
-  if (strstr (b->addr_string, "throw") != NULL)
-    printf_filtered (_("\nCatchpoint %d (exception thrown)\n"),
-		     b->number);
-  else
-    printf_filtered (_("\nCatchpoint %d (exception caught)\n"),
-		     b->number);
+  annotate_catchpoint (b->number);
 
+  bp_throw = strstr (b->addr_string, "throw") != NULL;
+  if (b->loc->address != b->loc->requested_address)
+    breakpoint_adjustment_warning (b->loc->requested_address,
+	                           b->loc->address,
+				   b->number, 1);
+  bp_temp = b->loc->owner->disposition == disp_del;
+  ui_out_text (uiout, 
+	       bp_temp ? "Temporary catchpoint "
+		       : "Catchpoint ");
+  if (!ui_out_is_mi_like_p (uiout))
+    ui_out_field_int (uiout, "bkptno", b->number);
+  ui_out_text (uiout,
+	       bp_throw ? " (thrown), "
+		        : " (caught), ");
+  if (ui_out_is_mi_like_p (uiout))
+    {
+      ui_out_field_string (uiout, "reason", 
+			   async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
+      ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
+      ui_out_field_int (uiout, "bkptno", b->number);
+    }
   return PRINT_SRC_AND_LOC;
 }
 
@@ -6530,10 +6546,16 @@ print_one_exception_catchpoint (struct b
 static void
 print_mention_exception_catchpoint (struct breakpoint *b)
 {
-  if (strstr (b->addr_string, "throw") != NULL)
-    printf_filtered (_("Catchpoint %d (throw)"), b->number);
-  else
-    printf_filtered (_("Catchpoint %d (catch)"), b->number);
+  int bp_temp;
+  int bp_throw;
+
+  bp_temp = b->loc->owner->disposition == disp_del;
+  bp_throw = strstr (b->addr_string, "throw") != NULL;
+  ui_out_text (uiout, bp_temp ? _("Temporary catchpoint ")
+			      : _("Catchpoint "));
+  ui_out_field_int (uiout, "bkptno", b->number);
+  ui_out_text (uiout, bp_throw ? _(" (throw)")
+			       : _(" (catch)"));
 }
 
 static struct breakpoint_ops gnu_v3_exception_catchpoint_ops = {
@@ -6555,7 +6577,7 @@ handle_gnu_v3_exceptions (int tempflag, 
 
   break_command_really (trigger_func_name, cond_string, -1,
 			0 /* condition and thread are valid.  */,
-			0, 0,
+			tempflag, 0,
 			0,
 			AUTO_BOOLEAN_TRUE /* pending */,
 			&gnu_v3_exception_catchpoint_ops, from_tty);

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

* Re: [patch] catchpoints bring output in-line with breakpoints output
  2008-05-28 15:20     ` Aleksandar Ristovski
@ 2008-05-28 16:25       ` Eli Zaretskii
  2008-05-28 19:31         ` Aleksandar Ristovski
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2008-05-28 16:25 UTC (permalink / raw)
  To: Aleksandar Ristovski; +Cc: gdb-patches

> From:  Aleksandar Ristovski <aristovski@qnx.com>
> Date:  Tue, 27 May 2008 16:00:29 -0400
> 
> >> +  int bp_temp;
> >> +  char msg[160];
> >> +  const char * msgspec;
> >> +  const char msgfmt[] = "\n%s %d (exception %s)\n";
> > 
> > This is not a good idea, because it defeats translation.  For
> > starters, this format string will not be caught by xgettext and won't
> > be in the message catalog.  Moreover, ...
> 
> Changed accordingly. I also adjusted MI output to better fit into breakpoint pattern. New diff attached.

Thanks, I'm happy now.


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

* Re: [patch] catchpoints bring output in-line with breakpoints output
  2008-05-28 16:25       ` Eli Zaretskii
@ 2008-05-28 19:31         ` Aleksandar Ristovski
  0 siblings, 0 replies; 6+ messages in thread
From: Aleksandar Ristovski @ 2008-05-28 19:31 UTC (permalink / raw)
  To: gdb-patches

Eli Zaretskii wrote:
> 
> Thanks, I'm happy now.
> 

Thanks for reviewing.

Committed now.


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

end of thread, other threads:[~2008-05-28 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-27 20:01 [patch] catchpoints bring output in-line with breakpoints output Aleksandar Ristovski
2008-05-27 21:32 ` Aleksandar Ristovski
2008-05-27 23:25   ` Eli Zaretskii
2008-05-28 15:20     ` Aleksandar Ristovski
2008-05-28 16:25       ` Eli Zaretskii
2008-05-28 19:31         ` Aleksandar Ristovski

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