From b62a3be1a23277de16a30636a021374b03532cce Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 30 Sep 2011 01:08:48 +0000 Subject: Add an accompanying option to the 'frame variable -w' command to, instead of watching the variable, watch the location pointed to by the variable. An example, (lldb) frame variable -w write -x 1 -g g_char_ptr (char *) g_char_ptr = 0x0000000100100860 ""... Watchpoint created: WatchpointLocation 1: addr = 0x100100860 size = 1 state = enabled type = w declare @ '/Volumes/data/lldb/svn/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp:21' ... (lldb) c Process 3936 resuming ... rocess 3936 stopped * thread #2: tid = 0x3403, 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27, stop reason = watchpoint 1 frame #0: 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27 24 do_bad_thing_with_location(char *char_ptr, char new_val) 25 { 26 *char_ptr = new_val; -> 27 } 28 29 uint32_t access_pool (uint32_t flag = 0); 30 (lldb) Also add TestWatchLocation.py test to exercise this functionality. llvm-svn: 140836 --- lldb/source/Interpreter/OptionGroupWatchpoint.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lldb/source/Interpreter/OptionGroupWatchpoint.cpp') 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; } -- cgit v1.2.3