Add a check for div by zero
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Given that testing packet speed by sending no packets seems pointless, I wonder if this should be asserts on the packet counts instead.
If this speed test is something we do as part of connection setup, you'd probably want to know that something went wrong rather than lldb claiming that any speed/packet size/whatever is fine. Then failing to send any real packets later.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | ||
---|---|---|
2483 | This could have the same issue if num_packets parameter is 0. |
The function has a void return type, with no way to communicate its success/failure status. Perhaps the right thing to do is to mod the function to return error Status, in addition to adding the assert (or some runtime check that works for all build flavors)?
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | ||
---|---|---|
2483 | This instance of average_per_packet variable is not even being used anywhere in the code, in its local scope. Same for packets_per_second just above it. |
I stopped being lazy and went and found where this is used. It's actually a command you can run from the interpreter that prints out the results of the testing.
(lldb) process plugin packet speed-test -c 0 Testing sending 0 packets of various sizes: <...> qSpeedTest(send= 1024, recv= 1024) in 0.000000120 s for 0.00 packets/s (0.000000 ms per packet) with standard deviation of 0.000000 ms Testing receiving 4.0MB of data using varying receive packet sizes: <...> qSpeedTest(send= 0, recv= 1024) 4096 packets needed to receive 4.0MB in 0.222097710 s for 18.01 MB/sec for 18442.33 packets/sec (0.054223 ms per packet)
So I think it is legitimate to specify 0 send packets here, if you just want to test receiving. So keep the check you've got and add the same sort of check for the instance above it.
(whether this command should even print anything if you're sending 0 packets, that's a matter for another time)
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | ||
---|---|---|
2483 | It's used to print to the stream below. |
Thanks for these fixes! I'll fix up the 0 packets sent behaviour when I find some spare time.
This could have the same issue if num_packets parameter is 0.