Most of the changes are very straight-forward, the only tricky part was the
"packet speed-test" function, which is very time-heavy. As the function was
completely untested, I added a quick unit smoke test for it.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | ||
---|---|---|
2144 ↗ | (On Diff #74013) | First function I'd like to stash somewhere. |
source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp | ||
---|---|---|
192 ↗ | (On Diff #74013) | using namespace std is generally frowned upon, but I wonder if we could be more lenient about using namespace std::chrono? Would make a lot of those code easier on the eyes. |
193–194 ↗ | (On Diff #74013) | Why do you need the duration_cast here? Can't you just pass in the result of GetPacketTimeout(), where GetPacketTimeout() is updated to return a std::chrono::duration<int>? |
source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | ||
266–267 ↗ | (On Diff #74013) | Same here. You should just be able to pass the duration straight through, and update ReadPacket to do the cast. |
source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h | ||
86 ↗ | (On Diff #74013) | To make this more generic, this could be a std::chrono::duration<int>. If for any reason someone wanted 3.2 seconds, they could then specify it. |
source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp | ||
---|---|---|
192 ↗ | (On Diff #74013) | I started using it in some tighter scopes, which are chrono-heavy. I'd be fine with the using directive at file level though. |
source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | ||
266–267 ↗ | (On Diff #74013) | These should go away, when everything is updated to use chrono, but the hierarchy there is multiple levels deep, so I cannot do it in a single pass (ReadPacket just calls WaitForPacketWithTimeoutMicroSecondsNoLock, which would also need to be updated... the real cast should only happen somewhere in the Connection classes, once you actually start issuing system calls). |
source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h | ||
86 ↗ | (On Diff #74013) | I don't think that works the way you think it does. If you don't specify the ratio template argument, it will just get defaulted to std::ratio<1>, meaning seconds. To have it generic you'd have to make this a template function, with the ratio as the parameter, but at that point you might as well just choose a type with the highest precision you are willing to accept. So, I could make this take a milli or micro second durations, but I don't think that's necessary for a packet timeout. |
Clean up the code a bit now that I have learned better how to use the chrono library.