[Lldb-commits] [lldb] c687af0 - [lldb] Don't send invalid region addresses to lldb server
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 17 02:26:23 PDT 2020
Author: David Spickett
Date: 2020-09-17T10:26:16+01:00
New Revision: c687af0c30b4dbdc9f614d5e061c888238e0f9c5
URL: https://github.com/llvm/llvm-project/commit/c687af0c30b4dbdc9f614d5e061c888238e0f9c5
DIFF: https://github.com/llvm/llvm-project/commit/c687af0c30b4dbdc9f614d5e061c888238e0f9c5.diff
LOG: [lldb] Don't send invalid region addresses to lldb server
Previously when <addr> in "memory region <addr>" didn't
parse correctly, we'd print an error then also ask lldb-server
for a region containing LLDB_INVALID_ADDRESS.
(lldb) memory region not_an_address
error: invalid address argument "not_an_address"...
error: Server returned invalid range
Only send the command to lldb-server if the address
parsed correctly.
(lldb) memory region not_an_address
error: invalid address argument "not_an_address"...
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D87694
Added:
Modified:
lldb/source/Commands/CommandObjectMemory.cpp
lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 474c37710149..d91893799498 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1707,6 +1707,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed {
"invalid address argument \"%s\": %s\n", command[0].c_str(),
error.AsCString());
result.SetStatus(eReturnStatusFailed);
+ return false;
}
}
diff --git a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
index 283cc945ed09..61e64d44e794 100644
--- a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -41,6 +41,12 @@ def test(self):
self.assertFalse(result.Succeeded())
self.assertRegexpMatches(result.GetError(), "Usage: memory region ADDR")
+ # Test that when the address fails to parse, we show an error and do not continue
+ interp.HandleCommand("memory region not_an_address", result)
+ self.assertFalse(result.Succeeded())
+ self.assertEqual(result.GetError(),
+ "error: invalid address argument \"not_an_address\": address expression \"not_an_address\" evaluation failed\n")
+
# Now let's print the memory region starting at 0 which should always work.
interp.HandleCommand("memory region 0x0", result)
self.assertTrue(result.Succeeded())
More information about the lldb-commits
mailing list