[lldb-dev] Programmatically set breakpoint in C++ code

David Earlam David.Earlam at csr.com
Mon Mar 17 10:40:21 PDT 2014


llvm's clang already has an intrinsic __builtin_debugger(), and

https://github.com/scottt/debugbreak

provides a wrapper for the equivalent on ARM/Thumb - including a Python script to awkwardly step past
such a breakpoint when using gdb - and there's always raising sigtrap for a hosted (not freestanding) C++ program.

David Earlam

> Greg Clayton wrote:
> Of course this only works for x86 32 and 64 bit targets so you will
> need to #ifdef it out for other architectures.
> 
> On Mar 15, 2014, at 3:21 PM, Richard Mitton <richard at codersnotes.com>
> wrote:
> 
> >     __asm volatile ("int3");
> >
> > Should work on any debugger, not just lldb.
> > Also on Windows, you should generally use __debugbreak() instead of
> DebugBreak, as the latter is a kernel-level call, whereas you generally
> want a user-level breakpoint. The difference is that the user
> breakpoint gives a nicer callstack.
> >
> > Richard Mitton
> >
> > richard at codersnotes.com
> > On 03/15/2014 05:59 AM, Deepankar Sharma wrote:
> >> Is there a way that I can programmatically hit a breakpoint in my
> C++ code. I am looking for the lldb equivalent of the DebugBreak
> function on windows.


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.




More information about the lldb-dev mailing list