Requesting registers one by one takes a while in our project.
We want to get rid of it by using target.xml.
Details
Diff Detail
Event Timeline
Yeah, we should fill in the other attributes too. As that will probably noticeably increase the amount of code, it would be good to put this stuff into a separate function (or two..). For a test, you could create some kind of a lldb-server test (packages/Python/lldbsuite/test/tools/lldb-server/). I am imagining something that will check that this parses as valid xml, and then does some kind of basic validation on the contents.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
---|---|---|
2916 | "target.xml" would be a better buffer name than __FUNCTION__. |
I think this is looking pretty good overall. I just have a bunch of stylistic remarks...
lldb/packages/Python/lldbsuite/test/tools/lldb-server/registers-target-xml-reading/main.cpp | ||
---|---|---|
2 | I don't think the choice of inferior really matters here. This code could just be like int main(){} | |
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | ||
850 | You can put this outside the #ifdef | |
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
380–459 | These should return a llvm::StringRef to avoid copies, and take the argument as a reference to convey non-nullness. | |
2873–2997 | Please move this into a separate function | |
2875–2879 | This check could be factored to the front of the function (the svr4 branch does currently not have it, but it most likely should). | |
2928–2930 | We generally don't put curly braces around statements which fit on a single line. | |
2958–2981 | Make a utility function (lambda?) for this? |
Just a couple of comments to make this code more llvm-y. Without those, we have just moved the place which constructs the temporary std::string. I haven't highlighted all the uses, but overall I'd recommend using the Format function or something similar instead of Printf, as the latter can be error-prone (because of the need to pass the right PRIx macro to get the integer size right) and/or inefficient (need to do the .str().c_str() dance on StringRefs).
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
---|---|---|
1794 | Despite the name, PutCString actually takes a StringRef, so you can just drop the .str().c_str() thingy. In fact, I'd consider just writing response << "encoding:" << encoding << ';'; | |
2783 | Similarly, response << "encoding='" << encoding << "' ", or response.Format("encoding='{0}'", encoding) would be shorter, and avoid string copying. | |
2875 | no braces |
Just one more thing I didn't catch in the previous round :(.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
---|---|---|
461–481 | Sorry I wasn't clear about this, but my idea was to make a _single_ utility function for this. If you pass in the uint32_t* to the function instead of the whole RegisterInfo struct, then you can use the same code in both places.. |
Hi Pavel,
Thank you for review.
Could you also commit this to master, since I don't have commit access?
Committed as aedc196101e33bd58f7443c5b93398418ce55edf. I've updated the commit message to include a better description of what is being changed.
This breaks LLDB AArch64 Linux buildbot http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/1713
I have reverted this change temporarily. Please look at the test failure. I ll also do the same at my end. Thanks!
lldb/packages/Python/lldbsuite/test/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py | ||
---|---|---|
70 | Why don't you test all the fields here? | |
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
2783 | Nit: Now it is a funny mixture of operator<<, Printfs and PutCString. Is there a reason not to use << for everything? (I guess PutHex8 can't be easily done with <<, but everything else can?) |
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
---|---|---|
2917 | I know this is copy&paste from qRegisterInfo, but should not this be if (reg_info->invalidate_regs && reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM)? |
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | ||
---|---|---|
2783 | Yeah, I'm all for using anything else than printf (operator<<, the Format function, etc.). I just didn't feel like raising this point at that time. :/ |
Hi Muhammad,
Thank you for finding this issue.
After I fix that, could I update current review or should I create new one?
In this revision I fix value_regnums and invalidate_regnums serialization in target.xml.
However I'm not so sure that this is the cause of problem with ARM tests.
From tests log it seems like there are some unexpected value in register.
Is it possible to get logs output from this test run http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/1713/steps/test/logs/stdio that would help us a lot to fix it.
I have tested this not sure why it actually failed on the buildbot. The test seems to pass independently. Lets see if the new version fixes the issue.
Hi Muhammad,
Thank you for review.
Could you or Pavel commit this to master, since I don't have commit access?
Hi Patrios,
There was some problem with our buildbot and it went down overnight. I have put it back in place and will commit your patch today.
Why don't you test all the fields here?