summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp20
-rw-r--r--lldb/source/Interpreter/OptionGroupWatchpoint.cpp21
2 files changed, 34 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 4790eef4cde..288a5ea1b7d 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -436,7 +436,7 @@ public:
}
// Things have checked out ok...
- // m_option_watchpoint.watch_mode specifies the mode for watching.
+ // m_option_watchpoint.watch_type specifies the type of watching.
}
if (command.GetArgumentCount() > 0)
{
@@ -532,12 +532,20 @@ public:
if (m_option_watchpoint.watch_variable)
{
AddressType addr_type;
- lldb::addr_t addr = valobj_sp->GetAddressOf(false, &addr_type);
+ lldb::addr_t addr = 0;
size_t size = 0;
- if (addr_type == eAddressTypeLoad) {
- // We're in business.
- // Find out the size of this variable.
- size = valobj_sp->GetByteSize();
+ if (m_option_watchpoint.watch_size == 0) {
+ addr = valobj_sp->GetAddressOf(false, &addr_type);
+ if (addr_type == eAddressTypeLoad) {
+ // We're in business.
+ // Find out the size of this variable.
+ size = valobj_sp->GetByteSize();
+ }
+ } else {
+ // The '-xsize'/'-x' option means to treat the value object as
+ // a pointer and to watch the pointee with the specified size.
+ addr = valobj_sp->GetValueAsUnsigned(0);
+ size = m_option_watchpoint.watch_size;
}
uint32_t watch_type = m_option_watchpoint.watch_type;
WatchpointLocation *wp_loc = exe_ctx.GetTargetRef().CreateWatchpointLocation(addr, size, watch_type).get();
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index b0f381ef4b3..076d010ae7e 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -28,11 +28,21 @@ static OptionEnumValueElement g_watch_type[] =
{ 0, NULL, NULL }
};
+static OptionEnumValueElement g_watch_size[] =
+{
+ { 1, "1", "Watch for byte size of 1"},
+ { 2, "2", "Watch for byte size of 2"},
+ { 4, "4", "Watch for byte size of 4"},
+ { 8, "8", "Watch for byte size of 8"},
+ { 0, NULL, NULL }
+};
+
// if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions()
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a memory location (read, write, or read/write)."}
+ { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a variable (read, write, or read/write)."},
+ { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a location (1, 2, 4, or 8)."}
};
@@ -61,6 +71,14 @@ OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg);
break;
}
+ case 'x': {
+ bool success = false;
+ OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
+ watch_size = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &success);
+ if (!success)
+ error.SetErrorStringWithFormat("Invalid option arg for '-x': '%s'.\n", option_arg);
+ break;
+ }
default:
error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
break;
@@ -74,6 +92,7 @@ OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
{
watch_variable = false;
watch_type = eWatchInvalid;
+ watch_size = 0;
}
OpenPOWER on IntegriCloud