[lldb] Rewrite TestAutoInstallMainExecutable logic

The test uses debug info from one binary to debug a different one. This
does not work on macos, and its pure luck that it works elsewhere (the
variable that it inspects happens to have the same address in both).

The purpose of this test is to verify that lldb has not overwritten the
target executable. That can be more easily achieved by checking the exit
code of the binary, so change the test to do that.

Also remove the llgs_test decorator, as it's preventing the test from
running on macos. All the test needs is the platform functionality of
lldb-server, which is available everywhere.
This commit is contained in:
Pavel Labath 2021-04-01 11:58:45 +02:00
parent fcea4181bb
commit 48e3da1351
3 changed files with 8 additions and 29 deletions

View File

@ -1,9 +1,9 @@
CXX_SOURCES := main.cpp
CXXFLAGS := -DBUILD=\"stock\"
CXXFLAGS := -DBUILD=47
a.out: a.device.out
include Makefile.rules
a.device.out:
$(CXX) $(CXXFLAGS) -DBUILD=\"device\" -o $@ $(SRCDIR)/main.cpp
$(CXX) $(CXXFLAGS) -DBUILD=74 -o $@ $(SRCDIR)/main.cpp

View File

@ -15,10 +15,11 @@ class TestAutoInstallMainExecutable(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
@llgs_test
@skipIfRemote
@expectedFailureAll(oslist=["windows"]) # process modules not loaded
def test_target_auto_install_main_executable(self):
if lldbgdbserverutils.get_lldb_server_exe() is None:
self.skipTest("lldb-server not found")
self.build()
hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]
@ -69,23 +70,4 @@ class TestAutoInstallMainExecutable(TestBase):
(dest.fullpath,
self.getBuildArtifact("a.out")))
target = self.dbg.GetSelectedTarget()
breakpoint = target.BreakpointCreateByName("main")
launch_info = target.GetLaunchInfo()
error = lldb.SBError()
process = target.Launch(launch_info, error)
self.assertTrue(process, PROCESS_IS_VALID)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(
thread.IsValid(),
"There should be a thread stopped due to breakpoint")
frame = thread.GetFrameAtIndex(0)
self.assertEqual(frame.GetFunction().GetName(), "main")
self.expect("target variable build", substrs=['"device"'],
msg="Magic in the binary is wrong")
process.Continue()
self.expect("process launch", substrs=["exited with status = 74"])

View File

@ -1,8 +1,5 @@
#include <cstdio>
int build = BUILD;
const char* build = BUILD;
int main(int argc, char **argv) {
printf("argc: %d\n", argc);
return argv[0][0];
int main() {
return BUILD;
}