This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [RFC stub-side break conditions 3/5] GDB-side changes


On 01/06/2012 06:44 AM, Eli Zaretskii wrote:
Date: Thu, 05 Jan 2012 12:56:16 -0200
From: Luis Machado<luis_gustavo@mentor.com>

This machinery works by marking locations modified through the
"condition_changed" field. Conditions change whenever we create a new
location, use the "condition" command or delete an old duplicate
location. Furthermore, if a location at addr 0xdeadbeef had its
condition modified, all duplicate locations at 0xdeadbeef are marked
modified as well.

The modification detection takes place inside
update_global_location_list (...). By calling
force_breakpoint_reinsertion (...), we mark every location at address
0xdeadbeef as modified. When consolidating the final updated list of
locations, we detect these locations and mark the non-duplicate location
at 0xdeafbeef as "needs_update".

The "needs_update" field is used during breakpoint insertion. It forces
insertion of breakpoints even if they are marked as inserted already.

Now that we have information about locations that we should reinsert in
the target, we proceed to build a list of hex-encoded agent expressions.

At this point, if any conditional expressions fail to parse to a valid
agent expression, we assume that the conditions will be evaluated on
GDB's side. Thus we don't send the conditions to the stub. Otherwise, we
proceed to insert the breakpoints and the remote code now attaches the
hex-encoded expressions to the z0/z1 packet.

Regarding always-inserted mode, if it is "on" we must send condition
changes right away, or else the target will potentially miss breakpoint
hits. If always-inserted is "off", this isn't too critical, so we just
wait for the insertion call to send all the conditions to the stub. We
will remove them when stopping anyway.
WIBNI these details were somewhere in the source comments or (gasp!)
in gdbint.texinfo?

I could probably improve source documentation if it is not enough. I did point out in some places that conditions need to be synched with the target.


Regarding the internal documentation, i can include such descriptions there, no problem.
+/* Shows the current mode of breakpoint condition evaluation.  Explicitly shows
+   what "auto" is translating to.  */
+
+static void
+show_condition_evaluation_mode (struct ui_file *file, int from_tty,
+				struct cmd_list_element *c, const char *value)
+{
+  if (condition_evaluation_mode == condition_evaluation_auto)
+    fprintf_filtered (file,
+		      _("Breakpoint condition evaluation "
+			"mode is %s (currently %s).\n"),
+		      value,
+		      breakpoint_condition_evaluation_mode ());
+  else
+    fprintf_filtered (file, _("Breakpoint condition evaluation mode is %s.\n"),
+		      value);
+}
+
Is it a good idea to show "gdb" or "stub" rather than "auto"?  After
all, as you explained elsewhere, the translation is not 100% accurate,
depending on the specifics of each individual condition.

This will only show what the global setting is. If "auto", it will show "auto", but will also show what GDB is currently using given the available features.


If the user decides to switch to either "gdb" or "stub" (or "target"), this is what will be displayed by this function. This one does not relate directly to what is shown in "info break".

What is displayed in "info break" depends on the global setting and on the successful parsing of an expression into an agent expression, so it displays exactly where each location condition will be evaluated.

If "gdb" is set, every condition will be evaluated by GDB. If "stub" (or "target") is set, there is no guarantee everything will be handled by the target (given the documented limitations), so the fallback is to evaluate conditions on GDB's side.

I'm regretting the "info break" change a little, it seems to obscure rather than clarify. :-)
+      /* Print whether the remote stub is doing the breakpoint's condition
+	 evaluation.  If GDB is doing the evaluation, don't print anything.  */
+      if (loc&&  is_breakpoint (b)&&  loc->cond_bytecode
+	&&  breakpoint_condition_evaluation_mode ()
+	  != condition_evaluation_gdb)
+	{
+	  ui_out_text (uiout, " (");
+	  ui_out_field_string (uiout, "condeval",
+			       breakpoint_condition_evaluation_mode ());
I suggest "cond.eval." instead of "condeval".  Better yet, how about
"evaluated by"?
Sounds good. I'll make that change.

Fixed all the other comments.
Btw, what happens if I set the mode to "stub" and the sub does not
support this?  Do I get any feedback, and if so, at what time?

If the target (stub) does not advertise support for condition evaluation, nothing will happen. We will fallback to "gdb" mode automatically.


Target-side condition evaluation only happens if:

1 - Target supports it (via ConditionalBreakpoints feature).
2 - breakpoint condition-evaluation is "auto" or "stub".

There isn't a warning message though.

I'll send an updated version of the patch with the fixes.

Thanks

--
Luis
lgustavo@codesourcery.com


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