mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-09 04:14:11 +00:00
Add missing boundary checks to variable completion.
Summary: Stopgap patch to at least stop all the crashes I get from this code. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49949 llvm-svn: 338177
This commit is contained in:
parent
a90d24da1c
commit
d4ff5ba926
@ -38,6 +38,46 @@ class CommandLineCompletionTestCase(TestBase):
|
|||||||
"""Test that 'de' completes to 'detach '."""
|
"""Test that 'de' completes to 'detach '."""
|
||||||
self.complete_from_to('de', 'detach ')
|
self.complete_from_to('de', 'detach ')
|
||||||
|
|
||||||
|
@skipIfFreeBSD # timing out on the FreeBSD buildbot
|
||||||
|
def test_frame_variable(self):
|
||||||
|
self.build()
|
||||||
|
self.main_source = "main.cpp"
|
||||||
|
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||||
|
self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
|
||||||
|
|
||||||
|
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
|
||||||
|
'// Break here', self.main_source_spec)
|
||||||
|
self.assertEquals(process.GetState(), lldb.eStateStopped)
|
||||||
|
# FIXME: This pulls in the debug information to make the completions work,
|
||||||
|
# but the completions should also work without.
|
||||||
|
self.runCmd("frame variable fooo")
|
||||||
|
|
||||||
|
self.complete_from_to('frame variable fo',
|
||||||
|
'frame variable fooo')
|
||||||
|
self.complete_from_to('frame variable fooo.',
|
||||||
|
'frame variable fooo.')
|
||||||
|
self.complete_from_to('frame variable fooo.dd',
|
||||||
|
'frame variable fooo.dd')
|
||||||
|
|
||||||
|
self.complete_from_to('frame variable ptr_fooo->',
|
||||||
|
'frame variable ptr_fooo->')
|
||||||
|
self.complete_from_to('frame variable ptr_fooo->dd',
|
||||||
|
'frame variable ptr_fooo->dd')
|
||||||
|
|
||||||
|
self.complete_from_to('frame variable cont',
|
||||||
|
'frame variable container')
|
||||||
|
self.complete_from_to('frame variable container.',
|
||||||
|
'frame variable container.MemberVar')
|
||||||
|
self.complete_from_to('frame variable container.Mem',
|
||||||
|
'frame variable container.MemberVar')
|
||||||
|
|
||||||
|
self.complete_from_to('frame variable ptr_cont',
|
||||||
|
'frame variable ptr_container')
|
||||||
|
self.complete_from_to('frame variable ptr_container->',
|
||||||
|
'frame variable ptr_container->MemberVar')
|
||||||
|
self.complete_from_to('frame variable ptr_container->Mem',
|
||||||
|
'frame variable ptr_container->MemberVar')
|
||||||
|
|
||||||
@skipIfFreeBSD # timing out on the FreeBSD buildbot
|
@skipIfFreeBSD # timing out on the FreeBSD buildbot
|
||||||
def test_process_attach_dash_dash_con(self):
|
def test_process_attach_dash_dash_con(self):
|
||||||
"""Test that 'process attach --con' completes to 'process attach --continue '."""
|
"""Test that 'process attach --con' completes to 'process attach --continue '."""
|
||||||
|
@ -7,8 +7,15 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Container { int MemberVar; };
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Foo f;
|
Foo fooo;
|
||||||
f.Bar(1, 2);
|
Foo *ptr_fooo = &fooo;
|
||||||
|
fooo.Bar(1, 2);
|
||||||
|
|
||||||
|
Container container;
|
||||||
|
Container *ptr_container = &container;
|
||||||
|
return container.MemberVar = 3; // Break here
|
||||||
}
|
}
|
||||||
|
@ -644,11 +644,12 @@ static void PrivateAutoComplete(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
if (partial_path[1] == '>' && !prefix_path.str().empty()) {
|
if (partial_path.size() > 1 && partial_path[1] == '>' &&
|
||||||
|
!prefix_path.str().empty()) {
|
||||||
switch (type_class) {
|
switch (type_class) {
|
||||||
case lldb::eTypeClassPointer: {
|
case lldb::eTypeClassPointer: {
|
||||||
CompilerType pointee_type(compiler_type.GetPointeeType());
|
CompilerType pointee_type(compiler_type.GetPointeeType());
|
||||||
if (partial_path[2]) {
|
if (partial_path.size() > 2 && partial_path[2]) {
|
||||||
// If there is more after the "->", then search deeper
|
// If there is more after the "->", then search deeper
|
||||||
PrivateAutoComplete(
|
PrivateAutoComplete(
|
||||||
frame, partial_path.substr(2), prefix_path + "->",
|
frame, partial_path.substr(2), prefix_path + "->",
|
||||||
@ -672,7 +673,7 @@ static void PrivateAutoComplete(
|
|||||||
case lldb::eTypeClassUnion:
|
case lldb::eTypeClassUnion:
|
||||||
case lldb::eTypeClassStruct:
|
case lldb::eTypeClassStruct:
|
||||||
case lldb::eTypeClassClass:
|
case lldb::eTypeClassClass:
|
||||||
if (partial_path[1]) {
|
if (partial_path.size() > 1 && partial_path[1]) {
|
||||||
// If there is more after the ".", then search deeper
|
// If there is more after the ".", then search deeper
|
||||||
PrivateAutoComplete(frame, partial_path.substr(1),
|
PrivateAutoComplete(frame, partial_path.substr(1),
|
||||||
prefix_path + ".", compiler_type, matches,
|
prefix_path + ".", compiler_type, matches,
|
||||||
|
Loading…
Reference in New Issue
Block a user