[Lldb-commits] [lldb] r158016 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Commands/CommandObjectWatchpoint.cpp source/Core/ValueObject.cpp test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py test/functionalities/watchpoint/watchpoint_set_command/main.cpp
Johnny Chen
johnny.chen at apple.com
Tue Jun 5 12:37:43 PDT 2012
Author: johnny
Date: Tue Jun 5 14:37:43 2012
New Revision: 158016
URL: http://llvm.org/viewvc/llvm-project?rev=158016&view=rev
Log:
rdar://problem/11597911
Fix confusing error message about "expression did not evaluate to an address" when doing 'watchpoint set expression".
Instead of using 0 as the fail_value when invoking ValueObject::GetValueAsUnsigned(), modify the API to take an addition
bool pointer (defaults to NULL) to indicate success/failure of value conversion.
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/main.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=158016&r1=158015&r2=158016&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Jun 5 14:37:43 2012
@@ -690,7 +690,7 @@
std::string& destination);
virtual uint64_t
- GetValueAsUnsigned (uint64_t fail_value);
+ GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL);
virtual bool
SetValueFromCString (const char *value_str, Error& error);
Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=158016&r1=158015&r2=158016&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Tue Jun 5 14:37:43 2012
@@ -1196,8 +1196,9 @@
}
// Get the address to watch.
- addr = valobj_sp->GetValueAsUnsigned(0);
- if (!addr) {
+ bool success = false;
+ addr = valobj_sp->GetValueAsUnsigned(0, &success);
+ if (!success) {
result.GetErrorStream().Printf("error: expression did not evaluate to an address\n");
result.SetStatus(eReturnStatusFailed);
return false;
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=158016&r1=158015&r2=158016&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Jun 5 14:37:43 2012
@@ -1246,15 +1246,23 @@
// if > 8bytes, 0 is returned. this method should mostly be used
// to read address values out of pointers
uint64_t
-ValueObject::GetValueAsUnsigned (uint64_t fail_value)
+ValueObject::GetValueAsUnsigned (uint64_t fail_value, bool *success)
{
// If our byte size is zero this is an aggregate type that has children
if (ClangASTContext::IsAggregateType (GetClangType()) == false)
{
Scalar scalar;
if (ResolveValue (scalar))
+ {
+ if (success)
+ *success = true;
return scalar.GetRawBits64(fail_value);
+ }
+ // fallthrough, otherwise...
}
+
+ if (success)
+ *success = false;
return fail_value;
}
Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py?rev=158016&r1=158015&r2=158016&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py (original)
+++ lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py Tue Jun 5 14:37:43 2012
@@ -61,6 +61,10 @@
self.expect("watchpoint set expression -w write --", error=True,
startstr = 'error: required argument missing; specify an expression to evaulate into the addres to watch for')
+ # It's an error if the expression did not evaluate to an address.
+ self.expect("watchpoint set expression MyAggregateDataType", error=True,
+ startstr = 'error: expression did not evaluate to an address')
+
# Check for missing option terminator '--'.
self.expect("watchpoint set expression -w write -x 1 g_char_ptr", error=True,
startstr = 'error: did you forget to enter the option terminator string "--"?')
Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/main.cpp?rev=158016&r1=158015&r2=158016&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/main.cpp (original)
+++ lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/main.cpp Tue Jun 5 14:37:43 2012
@@ -98,6 +98,12 @@
err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2);
err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3);
+ struct {
+ int a;
+ int b;
+ int c;
+ } MyAggregateDataType;
+
printf ("Before turning all three threads loose...\n"); // Set break point at this line.
// Join all of our threads
More information about the lldb-commits
mailing list