Skip to content

[lldb][Symbol] Make sure we decrement PC before checking location list #74772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lldb/source/Symbol/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
// contains the current address when converted to a load address
return m_location_list.ContainsAddress(
loclist_base_load_addr,
frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
target_sp.get()));
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
C_SOURCES := main.c
CXX_SOURCES := main.cpp
CFLAGS_EXTRAS := -O1
include Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@


class LocationListLookupTestCase(TestBase):
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)

@skipIf(oslist=["linux"], archs=["arm"])
def test_loclist(self):
self.build()
exe = self.getBuildArtifact("a.out")

# Create a target by the debugger.
exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
self.dbg.SetAsync(False)
Expand All @@ -27,12 +22,15 @@ def test_loclist(self):
self.assertTrue(process.IsValid())
self.assertTrue(process.is_stopped)

# Find `main` on the stack, then
# find `argv` local variable, then
# check that we can read the c-string in argv[0]
# Find `bar` on the stack, then
# make sure we can read out the local
# variables (with both `frame var` and `expr`)
for f in process.GetSelectedThread().frames:
if f.GetDisplayFunctionName() == "main":
if f.GetDisplayFunctionName().startswith("Foo::bar"):
argv = f.GetValueForVariablePath("argv").GetChildAtIndex(0)
strm = lldb.SBStream()
argv.GetDescription(strm)
self.assertNotEqual(strm.GetData().find("a.out"), -1)

process.GetSelectedThread().SetSelectedFrame(f.idx)
self.expect_expr("this", result_type="Foo *")
23 changes: 0 additions & 23 deletions lldb/test/API/functionalities/location-list-lookup/main.c

This file was deleted.

23 changes: 23 additions & 0 deletions lldb/test/API/functionalities/location-list-lookup/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <cstdio>
#include <cstdlib>

void func(int in);

struct Foo {
int x;
[[clang::noinline]] void bar(char **argv);
};

int main(int argc, char **argv) {
Foo f{.x = 5};
std::printf("%p\n", &f.x);
f.bar(argv);
return f.x;
}

void Foo::bar(char **argv) {
std::printf("%p %p\n", argv, this);
std::abort(); /// 'this' should be still accessible
}

void func(int in) { printf("%d\n", in); }