forked from OSchip/llvm-project
Remove the functionality of using 'frame variable -w' to set a watchpoint now that 'watchpoint set variable/expression'
is working. Also update the relevant test cases. llvm-svn: 150514
This commit is contained in:
parent
3d34834bb0
commit
973cf9e8ae
|
@ -14,7 +14,6 @@
|
|||
#include <string>
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Breakpoint/Watchpoint.h"
|
||||
#include "lldb/Core/DataVisualization.h"
|
||||
#include "lldb/Core/Debugger.h"
|
||||
#include "lldb/Core/Module.h"
|
||||
|
@ -32,7 +31,6 @@
|
|||
#include "lldb/Interpreter/OptionGroupFormat.h"
|
||||
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
|
||||
#include "lldb/Interpreter/OptionGroupVariable.h"
|
||||
#include "lldb/Interpreter/OptionGroupWatchpoint.h"
|
||||
#include "lldb/Symbol/ClangASTType.h"
|
||||
#include "lldb/Symbol/ClangASTContext.h"
|
||||
#include "lldb/Symbol/ObjectFile.h"
|
||||
|
@ -330,20 +328,12 @@ public:
|
|||
"If any arguments are specified, they can be names of "
|
||||
"argument, local, file static and file global variables. "
|
||||
"Children of aggregate variables can be specified such as "
|
||||
"'var->child.x'. "
|
||||
"You can choose to watch a variable with the '-w' option; "
|
||||
"with the additional '-x' option to specify the region size, "
|
||||
"the variable's value will be used as the starting address of "
|
||||
"the region to watch for, instead. "
|
||||
"Note that hardware resources for watching are often limited. "
|
||||
"See alo 'watchpoint set' where you can use an expression to "
|
||||
"specify the address to watch for.",
|
||||
"'var->child.x'.",
|
||||
NULL,
|
||||
eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
|
||||
m_option_group (interpreter),
|
||||
m_option_variable(true), // Include the frame specific options by passing "true"
|
||||
m_option_format (eFormatDefault),
|
||||
m_option_watchpoint(),
|
||||
m_varobj_options()
|
||||
{
|
||||
CommandArgumentEntry arg;
|
||||
|
@ -361,7 +351,6 @@ public:
|
|||
|
||||
m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
||||
m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
|
||||
m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
||||
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
||||
m_option_group.Finalize();
|
||||
}
|
||||
|
@ -432,23 +421,6 @@ public:
|
|||
|
||||
if (variable_list)
|
||||
{
|
||||
// If watching a variable, there are certain restrictions to be followed.
|
||||
if (m_option_watchpoint.watch_type_specified)
|
||||
{
|
||||
if (command.GetArgumentCount() != 1) {
|
||||
result.GetErrorStream().Printf("error: specify exactly one variable when using the '-w' option\n");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
} else if (m_option_variable.use_regex) {
|
||||
result.GetErrorStream().Printf("error: specify your variable name exactly (no regex) when using the '-w' option\n");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Things have checked out ok...
|
||||
// m_option_watchpoint.watch_type specifies the type of watching.
|
||||
}
|
||||
|
||||
const Format format = m_option_format.GetFormat();
|
||||
|
||||
if (command.GetArgumentCount() > 0)
|
||||
|
@ -543,49 +515,6 @@ public:
|
|||
valobj_sp->GetParent() ? name_cstr : NULL,
|
||||
options,
|
||||
format);
|
||||
// Process watchpoint if necessary.
|
||||
if (m_option_watchpoint.watch_type_specified)
|
||||
{
|
||||
AddressType addr_type;
|
||||
lldb::addr_t addr = 0;
|
||||
size_t size = 0;
|
||||
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;
|
||||
Watchpoint *wp = exe_ctx.GetTargetRef().CreateWatchpoint(addr, size, watch_type).get();
|
||||
if (wp)
|
||||
{
|
||||
if (var_sp && var_sp->GetDeclaration().GetFile())
|
||||
{
|
||||
StreamString ss;
|
||||
// True to show fullpath for declaration file.
|
||||
var_sp->GetDeclaration().DumpStopContext(&ss, true);
|
||||
wp->SetDeclInfo(ss.GetString());
|
||||
}
|
||||
StreamString ss;
|
||||
output_stream.Printf("Watchpoint created: ");
|
||||
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
|
||||
output_stream.EOL();
|
||||
result.SetStatus(eReturnStatusSuccessFinishResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendErrorWithFormat("Watchpoint creation failed.\n");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
}
|
||||
return (wp != NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -688,7 +617,6 @@ protected:
|
|||
OptionGroupOptions m_option_group;
|
||||
OptionGroupVariable m_option_variable;
|
||||
OptionGroupFormat m_option_format;
|
||||
OptionGroupWatchpoint m_option_watchpoint;
|
||||
OptionGroupValueObjectDisplay m_varobj_options;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ class CommandLineCompletionTestCase(TestBase):
|
|||
system(["/bin/sh", "-c", "rm -f child_send.txt"])
|
||||
system(["/bin/sh", "-c", "rm -f child_read.txt"])
|
||||
|
||||
def test_frame_variable_dash_w(self):
|
||||
"""Test that 'frame variable -w' completes to 'frame variable -w '."""
|
||||
self.complete_from_to('frame variable -w', 'frame variable -w ')
|
||||
def test_watchpoint_set_variable_dash_w(self):
|
||||
"""Test that 'watchpoint set variable -w' completes to 'watchpoint set variable -w '."""
|
||||
self.complete_from_to('watchpoint set variable -w', 'watchpoint set variable -w ')
|
||||
|
||||
def test_frame_variable_dash_w_space(self):
|
||||
"""Test that 'frame variable -w ' completes to ['Available completions:', 'read', 'write', 'read_write']."""
|
||||
self.complete_from_to('frame variable -w ', ['Available completions:', 'read', 'write', 'read_write'])
|
||||
def test_watchpoint_set_variable_dash_w_space(self):
|
||||
"""Test that 'watchpoint set variable -w ' completes to ['Available completions:', 'read', 'write', 'read_write']."""
|
||||
self.complete_from_to('watchpoint set variable -w ', ['Available completions:', 'read', 'write', 'read_write'])
|
||||
|
||||
def test_watchpoint_set_ex(self):
|
||||
"""Test that 'watchpoint set ex' completes to 'watchpoint set expression '."""
|
||||
|
|
|
@ -60,7 +60,7 @@ class HelloWatchLocationTestCase(TestBase):
|
|||
# The main.cpp, by design, misbehaves by not following the agreed upon
|
||||
# protocol of using a mutex while accessing the global pool and by not
|
||||
# incrmenting the global pool by 2.
|
||||
self.expect("frame variable -w write -x 1 -g g_char_ptr", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set expression -w write -x 1 -- g_char_ptr", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 1', 'type = w'])
|
||||
self.runCmd("expr unsigned val = *g_char_ptr; val")
|
||||
self.expect(self.res.GetOutput().splitlines()[0], exe=False,
|
||||
|
|
|
@ -11,30 +11,17 @@ class HelloWatchpointTestCase(TestBase):
|
|||
|
||||
mydir = os.path.join("functionalities", "watchpoint", "hello_watchpoint")
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
def test_hello_watchpoint_with_dsym_using_frame_var(self):
|
||||
"""Test a simple sequence of watchpoint creation and watchpoint hit."""
|
||||
self.buildDsym(dictionary=self.d)
|
||||
self.setTearDownCleanup(dictionary=self.d)
|
||||
self.hello_watchpoint()
|
||||
|
||||
def test_hello_watchpoint_with_dwarf_using_frame_var(self):
|
||||
"""Test a simple sequence of watchpoint creation and watchpoint hit."""
|
||||
self.buildDwarf(dictionary=self.d)
|
||||
self.setTearDownCleanup(dictionary=self.d)
|
||||
self.hello_watchpoint()
|
||||
|
||||
def test_hello_watchpoint_with_dsym_using_watchpoint_set(self):
|
||||
"""Test a simple sequence of watchpoint creation and watchpoint hit."""
|
||||
self.buildDsym(dictionary=self.d)
|
||||
self.setTearDownCleanup(dictionary=self.d)
|
||||
self.hello_watchpoint(use_frame_var=False)
|
||||
self.hello_watchpoint()
|
||||
|
||||
def test_hello_watchpoint_with_dwarf_using_watchpoint_set(self):
|
||||
"""Test a simple sequence of watchpoint creation and watchpoint hit."""
|
||||
self.buildDwarf(dictionary=self.d)
|
||||
self.setTearDownCleanup(dictionary=self.d)
|
||||
self.hello_watchpoint(use_frame_var=False)
|
||||
self.hello_watchpoint()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
|
@ -49,7 +36,7 @@ class HelloWatchpointTestCase(TestBase):
|
|||
self.exe_name = self.testMethodName
|
||||
self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
|
||||
|
||||
def hello_watchpoint(self, use_frame_var=True):
|
||||
def hello_watchpoint(self):
|
||||
"""Test a simple sequence of watchpoint creation and watchpoint hit."""
|
||||
exe = os.path.join(os.getcwd(), self.exe_name)
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
@ -70,14 +57,9 @@ class HelloWatchpointTestCase(TestBase):
|
|||
|
||||
# Now let's set a write-type watchpoint for 'global'.
|
||||
# There should be only one watchpoint hit (see main.c).
|
||||
if use_frame_var:
|
||||
self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = w',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
else:
|
||||
self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = w',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = w',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
# Use the '-v' option to do verbose listing of the watchpoint.
|
||||
# The hit count should be 0 initially.
|
||||
|
|
|
@ -64,7 +64,7 @@ class WatchpointForMultipleThreadsTestCase(TestBase):
|
|||
# The main.cpp, by design, misbehaves by not following the agreed upon
|
||||
# protocol of using a mutex while accessing the global pool and by not
|
||||
# writing to the variable.
|
||||
self.expect("frame variable -w write -g g_val", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = w'])
|
||||
|
||||
# Use the '-v' option to do verbose listing of the watchpoint.
|
||||
|
|
|
@ -111,7 +111,7 @@ class WatchpointCommandsTestCase(TestBase):
|
|||
|
||||
# Now let's set a read_write-type watchpoint for 'global'.
|
||||
# There should be two watchpoint hits (see main.c).
|
||||
self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = rw',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
@ -167,7 +167,7 @@ class WatchpointCommandsTestCase(TestBase):
|
|||
|
||||
# Now let's set a read_write-type watchpoint for 'global'.
|
||||
# There should be two watchpoint hits (see main.c).
|
||||
self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = rw',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
@ -209,7 +209,7 @@ class WatchpointCommandsTestCase(TestBase):
|
|||
|
||||
# Now let's set a read_write-type watchpoint for 'global'.
|
||||
# There should be two watchpoint hits (see main.c).
|
||||
self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = rw',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
@ -255,7 +255,7 @@ class WatchpointCommandsTestCase(TestBase):
|
|||
|
||||
# Now let's set a read_write-type watchpoint for 'global'.
|
||||
# There should be two watchpoint hits (see main.c).
|
||||
self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = rw',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
@ -314,7 +314,7 @@ class WatchpointCommandsTestCase(TestBase):
|
|||
|
||||
# Now let's set a read_write-type watchpoint for 'global'.
|
||||
# There should be two watchpoint hits (see main.c).
|
||||
self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = rw',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class WatchpointConditionCmdTestCase(TestBase):
|
|||
|
||||
# Now let's set a write-type watchpoint for 'global'.
|
||||
# With a condition of 'global==5'.
|
||||
self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED,
|
||||
self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
|
||||
substrs = ['Watchpoint created', 'size = 4', 'type = w',
|
||||
'%s:%d' % (self.source, self.decl)])
|
||||
|
||||
|
|
Loading…
Reference in New Issue