[lldb-dev] Problem unwinding from inside of a CRT function

jingham at apple.com jingham at apple.com
Tue Jan 20 11:09:53 PST 2015


> On Jan 20, 2015, at 4:21 AM, Hafiz Abid Qadeer <hafiz_abid at mentor.com> wrote:
> 
> On 16/01/15 21:53:00, Greg Clayton wrote:
>> How about:
>> 
>> 2     for (int i=0; i<100; i++)
>> 3 ->    printf ("i = %i\n", i); //
>> 4     printf ("this won't be executed after line 3 except for the 
>> last
>> time\n");
>> 
>> If you set a breakpoint on line 4 after line 3 when you will fail to
>> return to line 3 when single stepping.
>> 
>> How about:
>> 
>> 2 ->  goto carp;
>> 3     puts("won't ever be executed");
>> 4    carp:
>> 5     puts("will get executed");
>> 
>> If you set a breakpoint at line 3 you won't stop.
>> 
>> Another:
>> 
>> 2 -> throw foo();
>> 3    puts("this will never get hit");
>> 
>> If you set a breakpoint at line 3 you will never hit it.
>> 
>> Please trust that we know what we are doing when it comes to single
>> stepping. I am glad you are thinking about how things are done, but
>> just be sure think about the problem in a wider scope than "the code 
>> I
>> am thinking about is linear" and think about all sorts of single
>> stepping and what you would expect to happen.
> 
> In a properietary debugger that we developed in house, we spent quite a 
> bit of effort on making this work mixing emulation and symbol 
> information. It made a real improvements when debuggign remote 
> targets using slow connections. There was always the fall back on 
> stepping individual instruction when it did not work.
> 
> GDB also has range stepping thing now.
> https://sourceware.org/ml/gdb-patches/2013-03/msg00450.html

That's not the same thing.  That change is to have gdb send the step range to gdbserver and then gdbserver does the single stepping till it is outside the range.  That is great when you are doing remote debugging since it reduces the number of packets you have to send and receive.  But somebody is still single stepping.  

In lldb, we don't single-step from branch to branch, we set a breakpoint on the next branch within the range and continue.  The only times lldb single-steps are to step over breakpoints, and branches.  I'm sure gdb could easily do this trick as well, though I doubt gdbserver could.  gdb does know about what instructions do (e.g. for ARM chips without hardware single-step you have to emulate every instruction so you can set breakpoints on the destination and run there.)  But at least last time I looked gdbserver was much lighter-weight than this.

Jim

> 
> Regards,
> Abid
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev





More information about the lldb-dev mailing list