<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">You can register a listener, but that is more “low-level”, i.e. it will let you know when the process stopped (by giving you an SBEvent), and then you can look around the state of your program to figure out if the stop reason is a breakpoint, and if so “which” breakpoint.<div>This is similar to what the lldb-perf TestCase class does, so you can refer to TestCase::Loop() for an example of how you would to that.</div><div>Unfortunately, what you get from that API is the breakpoint number, which might be not very informative by itself.</div><div>We discussed the option of letting you “name” breakpoints and then retrieve that name for situations like this, but haven’t gotten around to doing anything more than discussing it.</div><div>You can of course work around the issue by having a number -> name table, or by writing a patch for named breakpoints :-)<br><div><br><div>
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="font-size: medium; orphans: 2; widows: 2; border-collapse: separate; border-spacing: 0px;"><span style="font-size: 12px; orphans: auto; widows: auto;">Enrico Granata</span><br style="font-size: 12px; orphans: auto; widows: auto;"><span style="font-size: 12px; orphans: auto; widows: auto;">✉ egranata@</span><font color="#ff2600" style="font-size: 12px; orphans: auto; widows: auto;"></font><span style="font-size: 12px; orphans: auto; widows: auto;">.com</span><br style="font-size: 12px; orphans: auto; widows: auto;"><span style="font-size: 12px; orphans: auto; widows: auto;">✆ 27683</span></div></div>
</div>
<br><div><div>On Apr 24, 2013, at 11:33 AM, "Malea, Daniel" <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Thanks for the explanation Enrico, that's what I thought.<br><br>So, is it possible to use SBListener to register some callback on a breakpoint hit? Or is it possible only via the C++ API or the "target stop-hook" commands?<br><br>From: Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a><<a href="mailto:egranata@apple.com">mailto:egranata@apple.com</a>>><br>Date: Wednesday, 24 April, 2013 2:23 PM<br>To: Daniel Malea <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a><<a href="mailto:daniel.malea@intel.com">mailto:daniel.malea@intel.com</a>>><br>Cc: Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a><<a href="mailto:gclayton@apple.com">mailto:gclayton@apple.com</a>>>, "<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><<a href="mailto:lldb-dev@cs.uiuc.edu">mailto:lldb-dev@cs.uiuc.edu</a>>" <<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><<a href="mailto:lldb-dev@cs.uiuc.edu">mailto:lldb-dev@cs.uiuc.edu</a>>><br>Subject: Re: [lldb-dev] Callback API question<br><br>I don’t think we currently supporting setting Python breakpoint callbacks through the SB API<br>We would need to add some code that takes a meaningful representation of a Python callable, and makes a C++ thunk that knows how to call into Python and get the result back to C++-land<br>It’s definitely an enhancement worth considering<br><br>Enrico Granata<br>✉ egranata@.com<br>✆ 27683<br><br>On Apr 24, 2013, at 11:00 AM, "Malea, Daniel" <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a><<a href="mailto:daniel.malea@intel.com">mailto:daniel.malea@intel.com</a>>> wrote:<br><br>Hi Greg, or whoever reads this first,<br><br>I have a question about the python API lldb.SBBreakpoint.SetCallback function. According to the docs, the signature is:<br><br>SetCallback(self, *args) unbound lldb.SBBreakpoint method<br>  SetCallback(self, BreakpointHitCallback callback, void baton)<br><br>However, I am not sure how to create an instance of the BreakpointHitCallback type that is required for the second parameter. I'm not seeing any class in the Python API that is named that; only the C++ API has a typedef of that name:<br><br>typedef bool (*BreakpointHitCallback) (void *baton,<br>                                     SBProcess &process,<br>                                     SBThread &thread,<br>                                     lldb::SBBreakpointLocation &location);<br><br><br>I tried passing a function that has (what I believe is) the correct signature:<br><br>class MyTestCase(TestBase):<br>def bp_callback(self, process, thread, breakpoint_loc):<br>  Pass<br><br>def register_callback(self, target)<br>  breakpoint = target.BreakpointCreateByLocation('main.c', self.line1)<br>  breakpoint.SetCallback(self.bp_callback, self)<br><br><br>But I am getting a python error:<br><br>TypeError: in method 'SBBreakpoint_SetCallback', argument 2 of type 'lldb::SBBreakpoint::BreakpointHitCallback'<br><br>So, my question is: is it possible to register a callback to be called when a breakpoint is hit using that function? If so, what am I doing wrong? If not, is it preferable to create an SBListener for this purpose, or is the "target stop-hook add" command the only way to do what I'm trying to do? I'm trying to avoid using the built-in script interpreter..<br><br><br><br>Thanks,<br>Dan<br><br>_______________________________________________<br>lldb-dev mailing list<br><a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><<a href="mailto:lldb-dev@cs.uiuc.edu">mailto:lldb-dev@cs.uiuc.edu</a>><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a></div></blockquote></div><br></div></div></body></html>