Skip to content

Commit 6c26921

Browse files
authored
support the qModuleInfo packet in debug sessions
## Purpose Properly support the `qModuleInfo` packet in both platform and debug sessions. ## Overview * Move the `onModuleInfo` function from `PlatformSessionImpl` into `FileOperationsMixin`, making it available in both `PlatformSessionImpl` and `DebugSessionImpl` * Re-enable lldb tests that are fixed by this change ## Problem Details A lot of lldb tests rely on unwinding through stack frames in standard libraries like `libc.so` and `libc++.so`. It turns out ds2 was not properly resolving symbols in these libraries because it failed to query their module info and therefore lldb never copied them into module cache. This issue was addressed for processes running in Android sandboxes when `qModuleInfo` support was added in 246c9c0. However, this implementation was only wired-up in the **platform** session implementation and not in **debug** session. Apparently lldb uses `qModuleInfo` in both session contexts. By moving the implementation of `onQueryModuleInfo` into the shared `FileOperationsMixin` class, it becomes available in both session types. ## Validation Locally verified the re-enabled tests pass on an Android x86_64 emulator
1 parent c6617e5 commit 6c26921

File tree

5 files changed

+39
-82
lines changed

5 files changed

+39
-82
lines changed

Headers/DebugServer2/GDBRemote/Mixins/FileOperationsMixin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ template <typename T> class FileOperationsMixin : public T {
5050
protected:
5151
ErrorCode onFileSetPermissions(Session &session, std::string const &path,
5252
uint32_t mode) override;
53+
ErrorCode onQueryModuleInfo(Session &session, std::string &path,
54+
std::string &triple,
55+
ModuleInfo &info) const override;
5356

5457
#if 0
5558
// more F packets:

Headers/DebugServer2/GDBRemote/PlatformSessionImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ class PlatformSessionImplBase : public DummySessionDelegateImpl {
4343
ErrorCode onQueryGroupName(Session &session, GroupId const &gid,
4444
std::string &name) const override;
4545

46-
ErrorCode onQueryModuleInfo(Session &session, std::string &path,
47-
std::string &triple,
48-
ModuleInfo &info) const override;
49-
5046
protected:
5147
ErrorCode onLaunchDebugServer(Session &session, std::string const &host,
5248
uint16_t &port, ProcessId &pid) override;

Sources/GDBRemote/Mixins/FileOperationsMixin.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
#include "DebugServer2/GDBRemote/Mixins/FileOperationsMixin.h"
1414
#include "DebugServer2/Host/Platform.h"
1515

16+
#include <iomanip>
17+
#include <sstream>
18+
19+
using ds2::Host::File;
20+
using ds2::Host::Platform;
21+
1622
namespace ds2 {
1723
namespace GDBRemote {
1824

@@ -94,5 +100,35 @@ ErrorCode FileOperationsMixin<T>::onFileSetPermissions(Session &session,
94100
uint32_t mode) {
95101
return Host::File::chmod(path, mode);
96102
}
103+
104+
template <typename T>
105+
ErrorCode FileOperationsMixin<T>::onQueryModuleInfo(Session &session,
106+
std::string &path,
107+
std::string &triple,
108+
ModuleInfo &info) const {
109+
ByteVector buildId;
110+
if (!Platform::GetExecutableFileBuildID(path, buildId))
111+
return kErrorUnknown;
112+
113+
// TODO(andrurogerz): Not all executable files contain an embedded build ID.
114+
// If GetExecutableFileBuildID fails, calculate an md5 hash of the file
115+
// contents and return that as an "md5" field instead of the "uuid" field.
116+
117+
// send the uuid as a hex-encoded, upper-case string
118+
std::ostringstream ss;
119+
for(const auto b : buildId)
120+
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(b);
121+
122+
auto error = File::fileSize(path, info.file_size);
123+
if (error != kSuccess)
124+
return error;
125+
126+
info.uuid = ss.str();
127+
info.triple = triple;
128+
info.file_path = path;
129+
info.file_offset = 0;
130+
131+
return kSuccess;
132+
}
97133
} // namespace GDBRemote
98134
} // namespace ds2

Sources/GDBRemote/PlatformSessionImpl.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#include "DebugServer2/Host/ProcessSpawner.h"
1515
#include "DebugServer2/Utils/Log.h"
1616

17-
#include <sstream>
18-
19-
using ds2::Host::File;
20-
using ds2::Host::Platform;
2117
using ds2::Host::ProcessSpawner;
2218

2319
namespace ds2 {
@@ -96,31 +92,6 @@ ErrorCode PlatformSessionImplBase::onQueryGroupName(Session &,
9692
return kSuccess;
9793
}
9894

99-
ErrorCode PlatformSessionImplBase::onQueryModuleInfo(Session &session,
100-
std::string &path,
101-
std::string &triple,
102-
ModuleInfo &info) const {
103-
ByteVector buildId;
104-
if (!Platform::GetExecutableFileBuildID(path, buildId))
105-
return kErrorUnknown;
106-
107-
// send the uuid as a hex-encoded, upper-case string
108-
std::ostringstream ss;
109-
for(const auto b : buildId)
110-
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(b);
111-
112-
auto error = File::fileSize(path, info.file_size);
113-
if (error != kSuccess)
114-
return error;
115-
116-
info.uuid = ss.str();
117-
info.triple = triple;
118-
info.file_path = path;
119-
info.file_offset = 0;
120-
121-
return kSuccess;
122-
}
123-
12495
ErrorCode PlatformSessionImplBase::onLaunchDebugServer(Session &session,
12596
std::string const &host,
12697
uint16_t &port,

Support/Testing/Excluded/ds2/android-x86_64.excluded

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,34 @@ lldbsuite.test.lldbtest.TestPrintf.test_dwarf
33
lldbsuite.test.lldbtest.TestPrintf.test_dwo
44
TestAttachDenied.AttachDeniedTestCase.test_attach_to_process_by_id_denied
55
TestBadAddressBreakpoints.BadAddressBreakpointTestCase.test_bad_address_breakpoints
6-
TestBreakpointInGlobalConstructor.TestBreakpointInGlobalConstructors.test
76
TestBreakpointSetRestart.BreakpointSetRestart.test_breakpoint_set_restart_dwarf
87
TestBreakpointSetRestart.BreakpointSetRestart.test_breakpoint_set_restart_dwo
9-
TestBtAliasRepeat.TestCase.test_dwarf
10-
TestBtAliasRepeat.TestCase.test_dwo
118
TestChangeProcessGroup.ChangeProcessGroupTestCase.test_setpgid
12-
TestCompletion.CommandLineCompletionTestCase.test_process_unload
13-
TestConcurrentNWatchNBreak.ConcurrentNWatchNBreak.test
14-
TestConcurrentSignalNWatchNBreak.ConcurrentSignalNWatchNBreak.test
159
TestConcurrentVFork.TestConcurrentVFork.test_follow_child_fork_call_exec
1610
TestConcurrentVFork.TestConcurrentVFork.test_follow_child_fork_no_exec
1711
TestConcurrentVFork.TestConcurrentVFork.test_follow_child_vfork_call_exec
1812
TestConcurrentVFork.TestConcurrentVFork.test_follow_child_vfork_no_exec
19-
TestConstVariables.ConstVariableTestCase.test_and_run_command_dwarf
20-
TestConstVariables.ConstVariableTestCase.test_and_run_command_dwo
2113
TestContainerCommands.TestCmdContainer.test_container_add
22-
TestCPPThis.CPPThisTestCase.test_with_run_command_dwarf
23-
TestCPPThis.CPPThisTestCase.test_with_run_command_dwo
2414
TestCreateAfterAttach.CreateAfterAttachTestCase.test_create_after_attach_dwarf
2515
TestCreateAfterAttach.CreateAfterAttachTestCase.test_create_after_attach_dwo
26-
TestCStrings.CStringsTestCase.test_with_run_command_dwarf
27-
TestCStrings.CStringsTestCase.test_with_run_command_dwo
2816
TestDeletedExecutable.TestDeletedExecutable.test
29-
TestDWIMPrint.TestCase.test_expressions_dwarf
30-
TestDWIMPrint.TestCase.test_expressions_dwo
3117
TestExec.ExecTestCase.test_correct_thread_plan_state_before_exec
3218
TestExec.ExecTestCase.test_hitting_exec
3319
TestExec.ExecTestCase.test_skipping_exec
3420
TestExpressionInSyscall.ExprSyscallTestCase.test_setpgid_dwarf
3521
TestExpressionInSyscall.ExprSyscallTestCase.test_setpgid_dwo
36-
TestExprs.BasicExprCommandsTestCase.test_expr_commands_can_handle_quotes_dwarf
37-
TestExprs.BasicExprCommandsTestCase.test_expr_commands_can_handle_quotes_dwo
3822
TestFrames.FrameAPITestCase.test_get_arg_vals_for_call_stack_dwarf
3923
TestFrames.FrameAPITestCase.test_get_arg_vals_for_call_stack_dwo
40-
TestFunctionTypes.FunctionTypesTestCase.test_pointers_dwarf
41-
TestFunctionTypes.FunctionTypesTestCase.test_pointers_dwo
4224
TestGdbRemote
43-
TestHandleAbort.HandleAbortTestCase.test_inferior_handle_sigabrt
4425
TestHelloWorld.HelloWorldTestCase.test_with_attach_to_process_with_id_api
4526
TestHelloWorld.HelloWorldTestCase.test_with_attach_to_process_with_name_api
46-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_disassemble_dwarf
47-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_disassemble_dwo
48-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_dwarf
49-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_dwo
50-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_expr_dwarf
51-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_expr_dwo
52-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_step_dwarf
53-
TestInferiorAssert.AssertingInferiorTestCase.test_inferior_asserting_step_dwo
5427
TestInferiorCrashing.CrashingInferiorTestCase.test_inferior_crashing_dwarf
5528
TestInferiorCrashing.CrashingInferiorTestCase.test_inferior_crashing_dwo
56-
TestIRInterpreter.IRInterpreterTestCase.test_ir_interpreter
5729
TestLldbGdbServer
5830
TestLoadUnload.LoadUnloadTestCase.test_lldb_process_load_and_unload_commands
5931
TestLoadUnload.LoadUnloadTestCase.test_lldb_process_load_and_unload_commands_with_svr4
6032
TestLoadUnload.LoadUnloadTestCase.test_static_init_during_load
6133
TestMainThreadExit.ThreadExitTestCase.test
62-
TestMemoryFind.MemoryFindTestCase.test_memory_find_dwarf
63-
TestMemoryFind.MemoryFindTestCase.test_memory_find_dwo
6434
TestNonStop.LldbGdbServerTestCase.test_exit_llgs
6535
TestNonStop.LldbGdbServerTestCase.test_exit_query_llgs
6636
TestNonStop.LldbGdbServerTestCase.test_leave_nonstop_llgs
@@ -75,13 +45,9 @@ TestNonStop.LldbGdbServerTestCase.test_vCont_then_partial_stop_llgs
7545
TestNonStop.LldbGdbServerTestCase.test_vCont_then_partial_stop_run_both_llgs
7646
TestNonStop.LldbGdbServerTestCase.test_vCont_then_stop_llgs
7747
TestNonStop.LldbGdbServerTestCase.test_vCtrlC_llgs
78-
TestNoreturnUnwind.NoreturnUnwind.test_dwarf
79-
TestNoreturnUnwind.NoreturnUnwind.test_dwo
8048
TestPartialResume.TestPartialResume.test_vCont_cxcx_llgs
8149
TestPartialResume.TestPartialResume.test_vCont_cxcxt_llgs
8250
TestPlatformCommand.PlatformCommandTestCase.test_status
83-
TestPrintfAfterUp.Radar9531204TestCase.test_expr_commands_dwarf
84-
TestPrintfAfterUp.Radar9531204TestCase.test_expr_commands_dwo
8551
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_id
8652
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_id_autocontinue
8753
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_id_correct_executable_offset
@@ -98,11 +64,6 @@ TestReturnValue.ReturnValueTestCase.test_vector_values_dwarf
9864
TestReturnValue.ReturnValueTestCase.test_vector_values_dwo
9965
TestReturnValue.ReturnValueTestCase.test_with_python_dwarf
10066
TestReturnValue.ReturnValueTestCase.test_with_python_dwo
101-
TestSaveJITObjects.SaveJITObjectsTestCase.test_save_jit_objects_dwarf
102-
TestSaveJITObjects.SaveJITObjectsTestCase.test_save_jit_objects_dwo
103-
TestScriptedResolver.TestScriptedResolver.test_command_line
104-
TestScriptedResolver.TestScriptedResolver.test_scripted_resolver
105-
TestScriptedResolver.TestScriptedResolver.test_search_depths
10667
TestSendSignal.SendSignalTestCase.test_with_run_command_dwarf
10768
TestSendSignal.SendSignalTestCase.test_with_run_command_dwo
10869
TestSettings.SettingsCommandTestCase.test_launchsimple_args_and_env_vars
@@ -115,24 +76,14 @@ TestSignal.TestSignal.test_signal_minus_one_llgs
11576
TestSignal.TestSignal.test_signal_process_by_pid_llgs
11677
TestSignal.TestSignal.test_signal_process_minus_one_llgs
11778
TestSignal.TestSignal.test_signal_process_without_tid_llgs
118-
TestSignedTypes.SignedTypesTestCase.test_dwarf
119-
TestSignedTypes.SignedTypesTestCase.test_dwo
12079
TestStateAfterExpression.TestStopReasonAfterExpression.test_thread_state_after_expr_dwarf
12180
TestStateAfterExpression.TestStopReasonAfterExpression.test_thread_state_after_expr_dwo
122-
TestStdCXXDisassembly.StdCXXDisassembleTestCase.test_stdcxx_disasm_dwarf
123-
TestStdCXXDisassembly.StdCXXDisassembleTestCase.test_stdcxx_disasm_dwo
124-
TestStepAndBreakpoints.TestCStepping.test_and_python_api_dwarf
125-
TestStepAndBreakpoints.TestCStepping.test_and_python_api_dwo
126-
TestStepThroughTrampoline.StepThroughTrampoline.test_dwarf
127-
TestStepThroughTrampoline.StepThroughTrampoline.test_dwo
12881
TestSyntheticCapping.SyntheticCappingTestCase.test_with_run_command_dwo
12982
TestTargetCreateDeps.TargetDependentsTestCase.test_dependents_explicit_default_exe
13083
TestTargetCreateDeps.TargetDependentsTestCase.test_dependents_explicit_false_exe
13184
TestTargetCreateDeps.TargetDependentsTestCase.test_dependents_explicit_false_lib
13285
TestTargetCreateDeps.TargetDependentsTestCase.test_dependents_implicit_default_exe
13386
TestTargetCreateDeps.TargetDependentsTestCase.test_dependents_implicit_default_lib
134-
TestThreadAPI.ThreadAPITestCase.test_step_out_of_malloc_into_function_b_dwarf
135-
TestThreadAPI.ThreadAPITestCase.test_step_out_of_malloc_into_function_b_dwo
13687
TestThreadSelectionBug.TestThreadSelectionBug.test
13788
TestUnalignedLargeWatchpoint.UnalignedLargeWatchpointTestCase.test_unaligned_large_watchpoint
13889
TestUnwindExpression.UnwindFromExpressionTest.test_unwind_expression_dwarf

0 commit comments

Comments
 (0)