<div dir="ltr">Yes, that was pretty much my assessment when I read through the code.<div><br></div><div>My existing patch (which I will post when I get home) takes a very conservative approach and only modifies what is strictly necessary to make the callback feature work.</div><div><br></div><div>That said, I found myself copy / paste / slight changing a fair bit of code to make it work. Usually a very bad sign.</div><div><br></div><div>If we can agree that a more aggressive refactor is desirable I would prefer that route.</div><div><br></div><div>It may be worth looking at the GDB Python API (<a href="https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html#Breakpoints-In-Python">https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html#Breakpoints-In-Python</a>). Watchpoints are just a species of breakpoint in that implementation.</div><div><br></div><div>I have done extensive work with that API, and while there are things I would do very differently, I generally consider it to be fairly good.</div><div><br></div><div>In fact, I think that the LLDB SB API could profit quite a bit from several of the things GDB has done on that front. That is particularly true with respect to symbols, variables, and frames. That subject likely deserves a different thread.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">\author{Dan}</div></div></div>
<br><div class="gmail_quote">On Fri, Sep 9, 2016 at 3:52 PM, Jim Ingham <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The main problem with the watchpoint code is that it doesn't share nearly as much of the implementation of options and callback handling with the breakpoints as it should. For instance, there's very little need for WatchpointOptions and BreakpointOptions to be separate classes, they do pretty much exactly the same thing. If you want to hack on this, the best approach I think would be to remove the watchpoint options, and see how far you can get using the breakpoint option class. I bet a lot of goodness will fall out of that. The PerformActions for the StopInfoWatchpoint and StopInfoBreakpoint could probably share much of their implementations as well. This is one of those cleanups that's been floating around on all our to-do lists for a while now, but keeps getting displaced by other tasks.<br>
<br>
The BreakpointOptions.h and WatchpointOptions.h files a pretty well documented. That's a fairly good example of how we used to do this. We don't tend to put top-level docs in .cpp files.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jim<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On Sep 9, 2016, at 2:13 PM, Daniel Noland via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I have also noticed a few problems similar to Ted's and I plan to<br>
> address them assuming nobody else is already on it. That said, I am new<br>
> around here so please bear with me :)<br>
><br>
> In fact, I have been hacking on a few watchpoint methods for a while<br>
> now. I have implemented some features I personally wanted (specifically<br>
> callback functions in the SBWatchpoint api).<br>
><br>
> I have not yet created a PR (or whatever SVN equivalent) for several<br>
> reasons (obviously including the big reformat), but mostly I am a bit<br>
> lost with respect to proper procedure here. I have gone through the<br>
> code guidelines for LLVM and LLDB, but I am confused about some things.<br>
><br>
> * I have written unit test logic, but I don't really understand the LLDB<br>
> testing framework. Also, I understand from other threads that the<br>
> framework is currently in flux in any case.<br>
><br>
> * I have written documentation, but I don't know if what I have written<br>
> is even desirable. For instance, the corresponding breakpoint<br>
> implementation is almost totally lacking in source doc.<br>
><br>
> * I will need to rebase this patch on the reformatted code. That is no<br>
> big deal, but I have little experience with SVN and I will need to do<br>
> some research to avoid turning an eventual merge into a big chore.<br>
><br>
> * I am pretty unclear on the appropriate way to make my changes work<br>
> with the Python API. Should that be on a different PR? Are we<br>
> targeting Python 2.7 and 3.{4,5} on all platforms?<br>
><br>
> * Do I need to check that the test suite passes on other platforms, or<br>
> will other devs take care of that? I don't use OSX or Windows.<br>
><br>
> Basically, I would like to help, but more than that I want my "help" to<br>
> be helpful.<br>
><br>
> If somebody who knows what is going on would help me out I would greatly<br>
> appreciate it.<br>
><br>
> \author{Daniel Noland}<br>
><br>
> On 09/09/2016 11:28 AM, Greg Clayton via lldb-dev wrote:<br>
>>> On Sep 8, 2016, at 4:47 PM, Ted Woodward via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> I recently discovered a problem with watchpoints talking to the Hexagon simulator:<br>
>>><br>
>>> (lldb) w s e 0x1000<br>
>>> error: Watchpoint creation failed (addr=0x1000, size=4).<br>
>>> error: Target supports (0) hardware watchpoint slots.<br>
>>><br>
>>><br>
>>> It seems that lldb now sends a qWatchpointSupportInfo packet. But this packet isn’t defined in lldb-gdb-remote.txt.<br>
>>><br>
>>> Looking at the code, it expects to get back a pair “num:#”. If it doesn’t it returns 0. The caller will report the above error if the number returned is 0. So if qWatchpointSupportInfo isn’t supported, lldb can’t set a watchpoint.<br>
>>><br>
>>><br>
>>> What is the definition of the response to qWatchpointSupportInfo? Is the the number of supported watchpoints, or the number of available watchpoints? If it’s supported, then CheckIfWatchpointsExhausted won’t really check if the watchpoints are exhausted. If it’s available, then a return of 0 doesn’t let us aggregate watchpoints – a 4 byte watchpoint at 0x1000 and one at 0x1004 could be one going from 0x1000-0x1007.<br>
>> The person that checked this in no longer is working on LLDB and it has been like this since May 2012. It should return the total number of supported watchpoints.<br>
>>><br>
>>> Wouldn’t it be better to try to set the watchpoint, then report a failure if we get an error back from the remote server?<br>
>> It is kind of nice to know that you can't set watchpoints because they aren't supported since we can provide a nicer message than "E98 returned from GDB server". Errors in GDB remote protocol are a horrible mess and they don't mean anything. So any clearer we can be about this, the better, so we should keep the qWatchpointSupportInfo packet IMHO. I am fine with us modifying the GDBRemoteCommunicationClient to try and send this packet and if it comes back as unimplemented (response of $#00), you can set the num supported hardware watchpoints to UINT32_MAX. We should document that this means we don't know how many hardware watchpoints are supported, but it should then allow us to set hardware watchpoints if the GDB server doesn't support this packet.<br>
>><br>
>> Watchpoints definitely need some work as they were done quickly by someone that is no longer around and they could use some TLC.<br>
>><br>
>>><br>
>>> --<br>
>>> Qualcomm Innovation Center, Inc.<br>
>>> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> lldb-dev mailing list<br>
>>> <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br>
>> ______________________________<wbr>_________________<br>
>> lldb-dev mailing list<br>
>> <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br>
<br>
</div></div></blockquote></div><br></div>