Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03  4:15 Michael Elizabeth Chastain
  2003-01-03  4:59 ` Daniel Jacobowitz
  2003-01-03 14:43 ` Elena Zannoni
  0 siblings, 2 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03  4:15 UTC (permalink / raw)
  To: drow, msnyder; +Cc: ezannoni, gdb-patches

I think the problem is inherent in the design.  'until' with no argument
is meant for getting past loops in the current stack frame.  (The manual
says that).  So it makes sense that it skips over all subroutine calls
and also stops if the current stack frame inadvertently exits before
getting past the end of a loop.

'until LOCATION' is quite different.  The manual says:

  `until LOCATION'
  `u LOCATION'
       Continue running your program until either the specified location
       is reached, or the current stack frame returns.  LOCATION is any of
       the forms of argument acceptable to `break' (*note Setting
       breakpoints: Set Breaks).  This form of the command uses
       breakpoints, and hence is quicker than `until' without an argument.
      
Read this way, it looks like 'until LOCATION' is mostly a synonym for
'tbreak LOCATION; continue', with one extra tbreak at the return address
in the superior frame.  (break.exp says as much but they forgot about
the case where the current stack frame returns).

I think this is bad.  We already have 'tbreak'.  I think it's weird and
redundant to have another 'until LOCATION' which is a lot like 'tbreak'
and not much like 'until'.

Also I trust Michael Snyder's interpretation of the original intent more
than this particular section of The Fine Manual.  It's bad when the manual
talks about the implementation of both 'until' and 'until LOCATION' and
points out that they are different.  It implies that the original designers 
knew they had some inconsistency between 'until' and 'until LOCATION'.

How about this:

  . require that LOCATION in 'until LOCATION' to be in the current
    function and after $PC.  If it's not, then error.

  . use the same steppy implementation for 'until LOCATION' as 'until',
    not a breakpointy implementation.  In fact, 'until' with no arguments
    simply becomes 'until LOCATION' where gdb picks a location by default.

  . change the manual to reflect this

Specifically, in Elena's case of the factorial: if the user wants to
stop at line 99 in ANY frame, they can use 'tbreak 99' or 'break 99'.
If the user wants to stop at line 99 in the CURRENT frame, they can use
'until 99'.

And in Elena's second case: what if you are in 'bar' at the moment and you
say 'until bar'?  I think that should be an error, because 'bar' is in
the current function, but it is not after $PC.

Similarly if you are currently in 'bar' and say 'until quux'.  Just error it.
Don't turn it into a tbreak.

This would make both forms of 'until' behave the same, all the time.
The user can still do whatever they want.  Want to progress a little in
the same frame?  Call 'until', with or without an argument.  Want to be
somewhere and not care if the frames change?  Call 'break' or 'tbreak'.

From the Peanut Gallery,

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-11  1:04 Michael Elizabeth Chastain
  0 siblings, 0 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-11  1:04 UTC (permalink / raw)
  To: drow, ezannoni; +Cc: gdb-patches

Elena Zannoni writes:
> Not as an option, I was thinking as a separate command.
> (to tell you the through, it should just be an argument to 'continue').

I like that.  Then various frobs like 'stay in the current frame'
become options in the command.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-07  4:05 Michael Elizabeth Chastain
  0 siblings, 0 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-07  4:05 UTC (permalink / raw)
  To: ezannoni, msnyder; +Cc: drow, gdb-patches

Michael Snyder writes:
> Ah, that's right.  I was thinking of that usage, but I forgot
> that it starts from the beginning.

Whoa, so did somebody who worked on gdb.c++/namespace.exp and
a few other files.  That might even be me!

  #
  # set it up at a breakpoint so we can play with the variable values
  #
  if ![runto_main] then {
    perror "couldn't run to breakpoint"
    continue
  }

  if ![runto 'marker1'] then {
    perror "couldn't run to marker1"
    continue
  }

Optimization opportunity!

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-07  3:53 Michael Elizabeth Chastain
  0 siblings, 0 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-07  3:53 UTC (permalink / raw)
  To: ezannoni, msnyder; +Cc: drow, gdb-patches

Michael Snyder writes:
> run-to?

Psychologically, 'run-to' fits into a good niche, but it might run into
abbreviation problems.  If it doesn't run into abbreviation problems
then I like it as a new name for this sort of thing.

The original 'until' name is a bit weird.  The point is to get out of a
loop, so 'progress' or 'endloop' or 'outloop' or 'done' ... but 'until'??
Maybe somebody wanted a name that started with 'u' for easy abbreviation.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-04  0:37 Michael Elizabeth Chastain
  2003-01-05 17:02 ` Andrew Cagney
  0 siblings, 1 reply; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-04  0:37 UTC (permalink / raw)
  To: ezannoni, msnyder; +Cc: drow, gdb-patches

Michael Snyder formulates:
> 1) Use find_pc_partial_function to determine bounds and
> distinguish between in-bounds and out-of-bounds locations.
> 2) For func_start > loc >= func_end, use a frame-relative bp.
> 3) For func_start == loc or loc < func_start or loc > func_end,
> use a frameless bp.
> 4) document, document, document!
> Including the recursive corner case.

In this formulation, my proposal would have: '3) error'.  It's
actually a pretty cool formulation because it makes the diff
between elena's idea and my idea a small diff.

I think that my proposal has gotten a sufficient hearing.
So go ahead.

Michael C
loyal opposition


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03 18:03 Michael Elizabeth Chastain
  0 siblings, 0 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03 18:03 UTC (permalink / raw)
  To: ezannoni; +Cc: drow, gdb-patches, msnyder

Elena Z writes:
> this is essentially what it does now.  But instead of erroring out it
> stops at the exit from the current frame.  Because we cannot reliably
> distinguish a. from b. Roughly, your error is equivalent to exiting
> the frame.

Yes.  It is quite similar to the existing behavior, just with the
error attached.

In a way, the point of the error is to seal off an unruly possibility.
That enables 'until' and 'until LOCATION' to be simple and consistent:
they would always stop in either the current frame or the return-breakpoint.

It's up to you to decide, I just needed to voice my proposal.

I will calm down now.  :)

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03 17:40 Michael Elizabeth Chastain
  0 siblings, 0 replies; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03 17:40 UTC (permalink / raw)
  To: drow; +Cc: gdb-patches

> We support other compilers; we support other versions of GCC.  The life
> of a debugger is that making people fix the compiler isn't going to
> fly.

Yeah, I see where you are coming from.

I am talking about a mapping from file:line to source function
without going through PC's at all.  That would not handle the case
of 'until *0x12345678'.  But it would handle other cases.

In your example: the target program is on line 11, "return a * baz()".
The user asks to proceed "until 4", which is the "-complicated" part of
inline function baz().

In my design, gdb would say: "error, line 4 is not in main".  I think your
point is that code from line 4 actually is present in main() because baz()
got inlined into main.  (And in your example, line 4 is present exactly
once in main, whereas in the general case it could be present multiple
times).

What happens right now when the user types "break 4" to break inside
the inline function?  I'm experimenting, and it looks like gdb sets one
breakpoint on one caller to the inline function.  "break 4" does not
work properly.

Once we have mechanism to implement "break 4", we can use the same
mechanism for "until 4".  We can calculate the set of locations for "break
4" and intersect that with the low_pc and high_pc of the current frame.
If that set is null, then error.  Then set momentary breakpoints on those
locations, restricted to the current frame, plus a momentary breakpoint
on the return location, and proceed.

Until "break 4" works, "until 4" can at least refuse to do anything.

> [Similarly, we need to stop assuming a symbol name maps to one PC. 
   This causes us to mess up constructor breakpoints right now.  GDB has
   essentially no support for debugging inline functions, and it's a
   problem there too.]

I agree.  The constructor part is really hurting users.  With inline
functions, the programmer knows "I have copies of the object code
for the function everywhere, I understand why gdb is not smart enough
to handle that yet."  With constructors, the programmer does not know
that they have multiple copies of the object code, so gdb's deficiency
shows up as a surprise.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03 17:07 Michael Elizabeth Chastain
  2003-01-03 17:51 ` Elena Zannoni
  0 siblings, 1 reply; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03 17:07 UTC (permalink / raw)
  To: ezannoni, msnyder; +Cc: drow, gdb-patches

My proposal for the behavior matrix is:

until:
  continue until any source line > the current source line is reached,
  in the current stack frame, or the current stack frame pops,
  whichever comes first.

until LOCATION:
  a. LOCATION is in current function: continue until $PC == LINE
     in the current stack frame, or the current stack frame pops,
     whichever comes first.
  b. LOCATION not in current function: error

In the 'until LOCATION' case, I guess it's okay for the user to be on
line 70 and ask to continue 'until line 65'.  The user is expecting
the program to get to line 65 and they are probably right.

I don't want to say "for every command line, choose some behavior and
implement it".  That leads to a bunch of quirky non-orthogonal commands.
I want to say "for everything we can imagine the user doing,
provide one simple way to do it."  In Elena's matrix:

  until funcname:
    d. funcname called from current frame (2) --> continue until func is reached
    e. funcname not called from current frame --> cont until current frame pops.

There is already a way to do almost exactly this in gdb:

  tbreak funcname
  finish

If we had a user-accessible 'mbreak' command for momentary breakpoints,
then this would be identical:

  mbreak funcname
  finish

Judging by the November thread, most people really want to have
'until LOCATION' always do something, even when LOCATION is not in
the current frame.  I really think it should give an error
in that case.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03 16:48 Michael Elizabeth Chastain
  2003-01-03 23:33 ` Michael Snyder
  0 siblings, 1 reply; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03 16:48 UTC (permalink / raw)
  To: ezannoni; +Cc: drow, gdb-patches, msnyder

Hi Elena,

> See the thread from November on gdb@sources.

Gotcha.  Thanks.

> I think that using decode_line_1 may be the real problem, because that
> allows all kind of arguments to be used, just like for a breakpoint.

I think the real problems are: (a) we haven't designed what should
actually happen in all cases, and then (b) Daniel J says that some
decision-making information is not reliable to get (when the user says
'until 70' gdb cannot reliably tell whether line 70 is in the current
function).

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03 16:38 Michael Elizabeth Chastain
  2003-01-03 16:57 ` Daniel Jacobowitz
  0 siblings, 1 reply; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03 16:38 UTC (permalink / raw)
  To: drow; +Cc: gdb-patches

Hi Daniel,

mec> So we might need additional promises.
mec> I think it would be reasonable for us to ask for them if we decide
mec> we need them.

drow> I don't.  Promises don't mean anything; we have existing code.

A promise in a manual is a contract.  If gcc violates its contract,
then gcc is at fault, and we can file bug reports against it.  That's
what I'm getting at.

mec> If we are in foo:67, and the user asks to 'until 70',
mec> then I bet we can figure out that '70' is in the current function no
mec> matter where its object code addresses are.

drow> No, we can't.  It's a pretty fundamental rule that we can never do
drow> anything except display source lines.  Consider code re-organization,
drow> templates, macros, #line directives...

Okay, I am naive here.  I see a DW_TAG_subprogram for each function
with a DW_AT_decl_line.  Can't we use that information to build a table
that maps source line #'s to function names?

But you know much more about this area then I do so if you are gloomy,
I have to be gloomy, too.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [RFA/PATCH] breakpoint.c: fix until command
@ 2003-01-03  6:49 Michael Elizabeth Chastain
  2003-01-03 15:17 ` Daniel Jacobowitz
  0 siblings, 1 reply; 61+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-03  6:49 UTC (permalink / raw)
  To: drow, gdb-patches

Daniel J says:

> With a modern compiler, "after $PC" is pretty much meaningless.  Not
> going to fly.  It could be re-ordered; there can be out-of-line code in
> separate sections.

I'm thinking of a famous promise in the gcc manual:

  Without `-O', the compiler's goal is to reduce the cost of
  compilation and to make debugging produce the expected results.
  Statements are independent: if you stop the program with a
  breakpoint between statements, you can then assign a new value to
  any variable or change the program counter to any other statement
  in the function and get exactly the results you would expect from
  the source code.

Statements which are independent can could be re-ordered, like moving
error-handling blocks far away to a different section of the address
space to improve cache locality.  So we might need additional promises.
I think it would be reasonable for us to ask for them if we decide
we need them.

With optimized code, I agree, gdb is just going to degrade, the way
it does now with stepping through for loops.

Unfortunately for us, the no-argument form of 'until' pretty much depends
on the "after" property.  Perhaps we could re-implement 'until' to set
a breakpoint on *every* source line after the current source line and
then get rid of the object code address comparison and the steppy
implementation.  That would take some work and doubtless have its own
issues.

> I don't see any reason for that to go to a single-steppy behavior
> however.

My primitive impulse is to have 'until' and 'until LOCATION' use the same
mechanism so that they will behave the same way in all the hard cases.

I admit, this is not a compelling reason, it just feels right to me.

> And what it means when LOCATION is not in function is not clear.
> The problem is, do we know well enough when LOCATION is or is not in
> FUNCTION to make any statements?

If we can get more promises from gcc, then we can know this is true
in un-optimized code.

We can also know whether LOCATION is in the function if we operate
on LOCATION while it is in source form before we translate to object
code location.  If we are in foo:67, and the user asks to 'until 70',
then I bet we can figure out that '70' is in the current function no
matter where its object code addresses are.

> The implicit breakpoint at the return is still somewhat useful, IMHO. 
> It's not quite the same; when you hit one of the breakpoints (or stop
> for some other reason), both vanish.  I don't think that's what tbreaks
> do.

And lo ... 'finish'.

This command has a non-intuitive name.  It is actually the same as
'continue' plus a momentary breakpoint on the return.  The momentary
breakpoint vanishes as soon as proceed() returns.

It looks perfectly okay to use 'finish' almost all the time, even if you
expect the momentary breakpoint not to be hit.  In fact, I'm personally
going to try debugging this way, because I've had too many Ellen Feiss
moments where the debugger didn't hit the breakpoint I thought it would
hit and then it went beep beep beep beep and ate all my stack frames
and the inferior was back in something useless like main().

(Just "define cont \n finish \n end" and try debugging for a while,
it's kind of nice to lose only one stack frame at a time!)

The current implementation of 'until LOCATION' looks close to 'tbreak
LOCATION; finish".  'until LOCATION' uses a momentary breakpoint on
'LOCATION' and 'tbreak LOCATION' (obviously) uses a tbreak.  But they
both set momentary breakpoints on the return.

> I'm still undecided about what to do if LOCATION is not in the
> function.  Maybe you're right and we should make this an error.  What
> if LOCATION is in the frame that called this one?

I still say, make it an error.  I like the idea that 'until' is all
about the current frame.

And it seems weird.  The user should know it's not in the current
frame when they type in in LOCATION.  And they know that 'until' rolls
right over function calls.  So the user knows that LOCATION is in a
calling frame.  This collides head on with the idea that 'until' has
a momentary breakpoint on the return location in the caller.  Try it.
It will always take the return-breakpoint.  It will never reach LOCATION.

So 'until LOCATION' behaves very similar to 'finish' and the user knows
this, so they should just type 'finish'.  If the user wants to hit the
return-breakpoint, they want 'finish'.  If they do not want the
return-breakpoint, they want 'tbreak/continue' (almost).  Either way,
'until LOCATION' is redundant with something else.

Also try 'until LOCATION' where LOCATION gets hit in an inner frame.
Right now it also behaves like a 'finish' because of the next-y behavior
of function calls .

So 'until LOCATION' is already practically useless if LOCATION is not
in the current frame, either way.

Michael C


^ permalink raw reply	[flat|nested] 61+ messages in thread
* [RFA/PATCH] breakpoint.c: fix until command
@ 2002-12-20 10:19 Elena Zannoni
  2002-12-23 15:55 ` Michael Snyder
  0 siblings, 1 reply; 61+ messages in thread
From: Elena Zannoni @ 2002-12-20 10:19 UTC (permalink / raw)
  To: gdb-patches


This fixes the problem reported in:
http://sources.redhat.com/ml/gdb/2002-11/msg00144.html

testsuite patch coming

Elena

2002-12-20  Elena Zannoni  <ezannoni@redhat.com>

	Fix PR breakpoints/898.
	* breakpoint.c (until_break_command): Don't use selected_frame,
	but the null frame.

Index: breakpoint.c
===================================================================
RCS file: /cvs/uberbaum/gdb/breakpoint.c,v
retrieving revision 1.104
diff -u -p -r1.104 breakpoint.c
--- breakpoint.c	17 Dec 2002 17:27:44 -0000	1.104
+++ breakpoint.c	20 Dec 2002 18:06:27 -0000
@@ -5615,9 +5615,7 @@ until_break_command (char *arg, int from
 
   resolve_sal_pc (&sal);
 
-  breakpoint = 
-    set_momentary_breakpoint (sal,get_frame_id (deprecated_selected_frame),
-			      bp_until);
+  breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
 
   if (!event_loop_p || !target_can_async_p ())
     old_chain = make_cleanup_delete_breakpoint (breakpoint);


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

end of thread, other threads:[~2003-01-11  1:04 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-03  4:15 [RFA/PATCH] breakpoint.c: fix until command Michael Elizabeth Chastain
2003-01-03  4:59 ` Daniel Jacobowitz
2003-01-03 21:52   ` Michael Snyder
2003-01-03 21:54     ` Daniel Jacobowitz
2003-01-03 22:39       ` Elena Zannoni
2003-01-03 23:09         ` Michael Snyder
2003-01-03 14:43 ` Elena Zannoni
2003-01-03 22:06   ` Michael Snyder
2003-01-03 22:43     ` Elena Zannoni
2003-01-03 23:13       ` Michael Snyder
  -- strict thread matches above, loose matches on Subject: below --
2003-01-11  1:04 Michael Elizabeth Chastain
2003-01-07  4:05 Michael Elizabeth Chastain
2003-01-07  3:53 Michael Elizabeth Chastain
2003-01-04  0:37 Michael Elizabeth Chastain
2003-01-05 17:02 ` Andrew Cagney
2003-01-07  1:30   ` Michael Snyder
2003-01-03 18:03 Michael Elizabeth Chastain
2003-01-03 17:40 Michael Elizabeth Chastain
2003-01-03 17:07 Michael Elizabeth Chastain
2003-01-03 17:51 ` Elena Zannoni
2003-01-03 16:48 Michael Elizabeth Chastain
2003-01-03 23:33 ` Michael Snyder
2003-01-03 16:38 Michael Elizabeth Chastain
2003-01-03 16:57 ` Daniel Jacobowitz
2003-01-03  6:49 Michael Elizabeth Chastain
2003-01-03 15:17 ` Daniel Jacobowitz
2002-12-20 10:19 Elena Zannoni
2002-12-23 15:55 ` Michael Snyder
2002-12-23 16:13   ` Daniel Jacobowitz
2002-12-23 16:59     ` Michael Snyder
2002-12-23 19:23       ` Daniel Jacobowitz
2003-01-02 20:25         ` Michael Snyder
2003-01-02 20:34           ` Elena Zannoni
2003-01-02 20:40             ` Michael Snyder
2003-01-03  0:12             ` Elena Zannoni
2003-01-03  1:44               ` Michael Snyder
2003-01-03  1:50                 ` Daniel Jacobowitz
2003-01-03  2:37                   ` Michael Snyder
2003-01-03 14:29                     ` Elena Zannoni
2003-01-03 23:51                       ` Michael Snyder
2003-01-03 23:53                         ` Elena Zannoni
2003-01-04  0:05                           ` Michael Snyder
2003-01-04  1:54                             ` Daniel Jacobowitz
2003-01-06 22:06                               ` Elena Zannoni
2003-01-07  1:27                                 ` Michael Snyder
2003-01-07  1:45                                   ` Elena Zannoni
2003-01-07  2:09                                     ` Michael Snyder
2003-01-07  4:31                                       ` Daniel Jacobowitz
2003-01-08 22:08                                         ` Elena Zannoni
2003-01-09  1:52                                           ` Daniel Jacobowitz
2003-01-10 22:25                                             ` Elena Zannoni
2003-01-10 22:28                                               ` Daniel Jacobowitz
2003-01-10 23:20                                                 ` Elena Zannoni
2003-01-03 14:15                   ` Elena Zannoni
2003-01-03 23:31                     ` Michael Snyder
2003-01-03 23:51                       ` Elena Zannoni
2003-01-03 23:58                         ` Michael Snyder
2003-01-03 14:13                 ` Elena Zannoni
2003-01-03 23:28                   ` Michael Snyder
2003-01-02 20:01       ` Elena Zannoni
2003-01-02 20:29         ` Michael Snyder

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