[lldb-dev] How to set source line breakpoint using BreakpointCreateByLocation?

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Oct 8 09:46:02 PDT 2015


> On Oct 7, 2015, at 8:31 PM, Jeffrey Tan via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hi, 
> 
> I am writing a python script to set source line breakpoint in ObjC on Mac OSX. But self.debugger.GetSelectedTarget().BreakpointCreateByLocation("EATAnimatedView.m", line) always fail. Any ideas?

As long as you have a selected target, this should work as long as you have debug info that matches.
> 
> Also, can I use full path instead of file basename?

Yes you can, but it must match exactly if you use the full path.

> In lldb, I found "b /Users/jeffreytan/fbsource/fbobjc/Apps/Internal/MPKEats/MPKEats/View/EATAnimatedView.m:21" will fail to bind but "b EATAnimatedView.m:21" will succeed. 

This is usually because you have a makefile build system that is creating debug info that doesn't contain a path that matches. When you launch a compiler, it can often end up with different paths than what you think you have. So set the breakpoint by basename first, then do:

(lldb) b main.c:12
Breakpoint 1: where = a.out`main + 70 at main.c:12, address = 0x0000000100000b96
(lldb) breakpoint list --verbose
Current breakpoints:
1: file = 'main.c', line = 12
    1.1: 
      module = /Volumes/work/gclayton/Documents/src/args/a.out
      compile unit = main.c
      function = main
      location = /Volumes/work/gclayton/Documents/src/args/main.c:12
      address = a.out[0x0000000100000b96]
      resolved = false
      hit count = 0   


You will see the full path to your source file in the "location" value. You will probably notice that the path is different. We try to take care of removing and extra "../useless_dir" things from the paths and still make things match, but you might have a case that we aren't handling. Let me know what you see when you set the breakpoint by basename.


> Traceback (most recent call last):
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/chromedebugger.py", line 69, in _generate_response
>     params=message.get('params', {}),
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/handler.py", line 42, in handle
>     return self._domains[domain_name].handle(method_name, params)
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/handler.py", line 106, in handle
>     return self._handlers[method](params)
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/handler.py", line 56, in _handler_wrapper
>     ret = func(self, params)
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/debugger.py", line 248, in setBreakpointByUrl
>     int(params['lineNumber']) + 1)
>   File "/Users/jeffreytan/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide/debugger/lldb/scripts/debugger.py", line 283, in _set_breakpoint_by_filespec
>     breakpoint = self.debugger.GetSelectedTarget().BreakpointCreateByLocation(filespec, line)
>   File "/Applications/Xcode.app/Contents/Developer/../SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 8650, in BreakpointCreateByLocation
>     return _lldb.SBTarget_BreakpointCreateByLocation(self, *args)
> NotImplementedError: Wrong number of arguments for overloaded function 'SBTarget_BreakpointCreateByLocation'.
>   Possible C/C++ prototypes are:
>     BreakpointCreateByLocation(lldb::SBTarget *,char const *,uint32_t)
>     BreakpointCreateByLocation(lldb::SBTarget *,lldb::SBFileSpec const &,uint32_t)
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list