This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Let gdbserver doesn't tell GDB it support target-side breakpoint conditions and commands if it doesn't support 'Z' packet
- From: Hui Zhu <hui_zhu at mentor dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Sun, 8 Dec 2013 13:13:57 +0800
- Subject: Re: [PATCH] Let gdbserver doesn't tell GDB it support target-side breakpoint conditions and commands if it doesn't support 'Z' packet
- Authentication-results: sourceware.org; auth=none
- References: <5265022F dot 8060203 at mentor dot com> <52654A2C dot 9010202 at redhat dot com> <529707C7 dot 4040504 at mentor dot com> <5298AE7C dot 6020607 at redhat dot com> <529C80D2 dot 2080608 at mentor dot com> <529C9B42 dot 20600 at redhat dot com> <529D62F7 dot 80701 at mentor dot com> <52A22582 dot 8040509 at redhat dot com>
On 12/07/13 03:29, Pedro Alves wrote:
Please analyze the insert_bp_location's error handling carefully:
- if solib_name_from_address is true (the dprintf is set in a
shared library), we won't see this new error message, while
we should.
I change all this part to:
First, output error message.
Second, if it is solib breakpoint, disable breakpoint.
- 'hw_bp_err_string' ends up misnamed after this patch.
Change it to "bp_err_string".
Post a new patch according to your comments.
This patch is tested and pass the regression test in x86_64 linux.
Please help me review it.
Thanks,
Hui
2013-12-08 Hui Zhu <hui@codesourcery.com>
PR gdb/16101
* breakpoint.c (insert_bp_location): Change hw_bp_err_string to
bp_err_string.
Output error message of software breakpoints.
Make solib error message output use same code with hardware
breakpoints and software breakpoints.
* remote.c (remote_insert_breakpoint): If this breakpoint has
target-side commands but this stub doesn't support Z0 packets,
throw error.
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2396,7 +2396,7 @@ insert_bp_location (struct bp_location *
int *hw_bp_error_explained_already)
{
int val = 0;
- char *hw_bp_err_string = NULL;
+ char *bp_err_string = NULL;
struct gdb_exception e;
if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update))
@@ -2501,7 +2501,7 @@ insert_bp_location (struct bp_location *
if (e.reason < 0)
{
val = 1;
- hw_bp_err_string = (char *) e.message;
+ bp_err_string = (char *) e.message;
}
}
else
@@ -2543,7 +2543,7 @@ insert_bp_location (struct bp_location *
if (e.reason < 0)
{
val = 1;
- hw_bp_err_string = (char *) e.message;
+ bp_err_string = (char *) e.message;
}
}
else
@@ -2557,6 +2557,36 @@ insert_bp_location (struct bp_location *
if (val)
{
/* Can't set the breakpoint. */
+ if (bl->loc_type == bp_loc_hardware_breakpoint)
+ {
+ *hw_breakpoint_error = 1;
+ *hw_bp_error_explained_already = bp_err_string != NULL;
+ fprintf_unfiltered (tmp_error_stream,
+ "Cannot insert hardware breakpoint %d%s",
+ bl->owner->number, bp_err_string ? ":" : ".\n");
+ if (bp_err_string)
+ fprintf_unfiltered (tmp_error_stream, "%s.\n", bp_err_string);
+ }
+ else if (bp_err_string != NULL)
+ {
+ fprintf_unfiltered (tmp_error_stream,
+ "Cannot insert breakpoint %d:%s\n",
+ bl->owner->number, bp_err_string);
+ }
+ else
+ {
+ char *message = memory_error_message (TARGET_XFER_E_IO,
+ bl->gdbarch, bl->address);
+ struct cleanup *old_chain = make_cleanup (xfree, message);
+
+ fprintf_unfiltered (tmp_error_stream,
+ "Cannot insert breakpoint %d.\n"
+ "%s\n",
+ bl->owner->number, message);
+
+ do_cleanups (old_chain);
+ }
+
if (solib_name_from_address (bl->pspace, bl->address))
{
/* See also: disable_breakpoints_in_shlibs. */
@@ -2564,45 +2594,13 @@ insert_bp_location (struct bp_location *
bl->shlib_disabled = 1;
observer_notify_breakpoint_modified (bl->owner);
if (!*disabled_breaks)
- {
- fprintf_unfiltered (tmp_error_stream,
- "Cannot insert breakpoint %d.\n",
- bl->owner->number);
- fprintf_unfiltered (tmp_error_stream,
- "Temporarily disabling shared "
- "library breakpoints:\n");
- }
+ fprintf_unfiltered (tmp_error_stream,
+ "Temporarily disabling shared "
+ "library breakpoints:\n");
*disabled_breaks = 1;
fprintf_unfiltered (tmp_error_stream,
"breakpoint #%d\n", bl->owner->number);
}
- else
- {
- if (bl->loc_type == bp_loc_hardware_breakpoint)
- {
- *hw_breakpoint_error = 1;
- *hw_bp_error_explained_already = hw_bp_err_string != NULL;
- fprintf_unfiltered (tmp_error_stream,
- "Cannot insert hardware breakpoint %d%s",
- bl->owner->number, hw_bp_err_string ? ":" : ".\n");
- if (hw_bp_err_string)
- fprintf_unfiltered (tmp_error_stream, "%s.\n", hw_bp_err_string);
- }
- else
- {
- char *message = memory_error_message (TARGET_XFER_E_IO,
- bl->gdbarch, bl->address);
- struct cleanup *old_chain = make_cleanup (xfree, message);
-
- fprintf_unfiltered (tmp_error_stream,
- "Cannot insert breakpoint %d.\n"
- "%s\n",
- bl->owner->number, message);
-
- do_cleanups (old_chain);
- }
-
- }
}
else
bl->inserted = 1;
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8260,6 +8260,12 @@ remote_insert_breakpoint (struct gdbarch
}
}
+ /* If this breakpoint has target-side commands but this stub doesn't
+ support Z0 packets, throw error. */
+ if (!VEC_empty (agent_expr_p, bp_tgt->tcommands))
+ error (_("\
+Target doesn't support breakpoints that have target side commands."));
+
return memory_insert_breakpoint (gdbarch, bp_tgt);
}