mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 12:26:07 +00:00
Revert "Add runToBinaryEntry option for lldb-vscode"
This reverts commit f0c16f89124f2dc0630162ff9ea23934f5b2b75b because it breaks linux and mac bots.
This commit is contained in:
parent
5cfc22cafe
commit
14aace34c3
@ -286,7 +286,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
stopCommands=None, exitCommands=None, terminateCommands=None,
|
stopCommands=None, exitCommands=None, terminateCommands=None,
|
||||||
sourcePath=None, debuggerRoot=None, sourceInitFile=False, launchCommands=None,
|
sourcePath=None, debuggerRoot=None, sourceInitFile=False, launchCommands=None,
|
||||||
sourceMap=None, disconnectAutomatically=True, runInTerminal=False,
|
sourceMap=None, disconnectAutomatically=True, runInTerminal=False,
|
||||||
expectFailure=False, postRunCommands=None, runToBinaryEntry=False):
|
expectFailure=False, postRunCommands=None):
|
||||||
'''Sending launch request to vscode
|
'''Sending launch request to vscode
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -323,8 +323,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
sourceMap=sourceMap,
|
sourceMap=sourceMap,
|
||||||
runInTerminal=runInTerminal,
|
runInTerminal=runInTerminal,
|
||||||
expectFailure=expectFailure,
|
expectFailure=expectFailure,
|
||||||
postRunCommands=postRunCommands,
|
postRunCommands=postRunCommands)
|
||||||
runToBinaryEntry=runToBinaryEntry)
|
|
||||||
|
|
||||||
if expectFailure:
|
if expectFailure:
|
||||||
return response
|
return response
|
||||||
@ -347,7 +346,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
terminateCommands=None, sourcePath=None,
|
terminateCommands=None, sourcePath=None,
|
||||||
debuggerRoot=None, sourceInitFile=False, runInTerminal=False,
|
debuggerRoot=None, sourceInitFile=False, runInTerminal=False,
|
||||||
disconnectAutomatically=True, postRunCommands=None,
|
disconnectAutomatically=True, postRunCommands=None,
|
||||||
lldbVSCodeEnv=None, runToBinaryEntry=False):
|
lldbVSCodeEnv=None):
|
||||||
'''Build the default Makefile target, create the VSCode debug adaptor,
|
'''Build the default Makefile target, create the VSCode debug adaptor,
|
||||||
and launch the process.
|
and launch the process.
|
||||||
'''
|
'''
|
||||||
@ -360,5 +359,4 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
terminateCommands, sourcePath, debuggerRoot, sourceInitFile,
|
terminateCommands, sourcePath, debuggerRoot, sourceInitFile,
|
||||||
runInTerminal=runInTerminal,
|
runInTerminal=runInTerminal,
|
||||||
disconnectAutomatically=disconnectAutomatically,
|
disconnectAutomatically=disconnectAutomatically,
|
||||||
postRunCommands=postRunCommands,
|
postRunCommands=postRunCommands)
|
||||||
runToBinaryEntry=runToBinaryEntry)
|
|
||||||
|
@ -650,7 +650,7 @@ class DebugCommunication(object):
|
|||||||
terminateCommands=None ,sourcePath=None,
|
terminateCommands=None ,sourcePath=None,
|
||||||
debuggerRoot=None, launchCommands=None, sourceMap=None,
|
debuggerRoot=None, launchCommands=None, sourceMap=None,
|
||||||
runInTerminal=False, expectFailure=False,
|
runInTerminal=False, expectFailure=False,
|
||||||
postRunCommands=None, runToBinaryEntry=False):
|
postRunCommands=None):
|
||||||
args_dict = {
|
args_dict = {
|
||||||
'program': program
|
'program': program
|
||||||
}
|
}
|
||||||
@ -662,8 +662,6 @@ class DebugCommunication(object):
|
|||||||
args_dict['env'] = env
|
args_dict['env'] = env
|
||||||
if stopOnEntry:
|
if stopOnEntry:
|
||||||
args_dict['stopOnEntry'] = stopOnEntry
|
args_dict['stopOnEntry'] = stopOnEntry
|
||||||
if runToBinaryEntry:
|
|
||||||
args_dict['runToBinaryEntry'] = runToBinaryEntry
|
|
||||||
if disableASLR:
|
if disableASLR:
|
||||||
args_dict['disableASLR'] = disableASLR
|
args_dict['disableASLR'] = disableASLR
|
||||||
if disableSTDIO:
|
if disableSTDIO:
|
||||||
|
@ -78,29 +78,6 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
|
|||||||
reason, 'breakpoint',
|
reason, 'breakpoint',
|
||||||
'verify stop isn\'t "main" breakpoint')
|
'verify stop isn\'t "main" breakpoint')
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_runToBinaryEntry(self):
|
|
||||||
'''
|
|
||||||
Tests the runToBinaryEntry option can successfully launch a simple
|
|
||||||
program and hit a breakpoint and does not interupt the launch.
|
|
||||||
'''
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
self.build_and_launch(program, runToBinaryEntry=True)
|
|
||||||
self.set_function_breakpoints(['main'])
|
|
||||||
stopped_events = self.continue_to_next_stop()
|
|
||||||
console_output = self.get_console()
|
|
||||||
self.assertIn("Process stopped successfully at the binary's entry point", console_output)
|
|
||||||
|
|
||||||
for stopped_event in stopped_events:
|
|
||||||
if 'body' in stopped_event:
|
|
||||||
body = stopped_event['body']
|
|
||||||
if 'reason' in body:
|
|
||||||
reason = body['reason']
|
|
||||||
self.assertTrue(
|
|
||||||
reason == 'breakpoint',
|
|
||||||
'verify successfully stop at "main" breakpoint')
|
|
||||||
|
|
||||||
@skipIfWindows
|
@skipIfWindows
|
||||||
@skipIfRemote
|
@skipIfRemote
|
||||||
def test_cwd(self):
|
def test_cwd(self):
|
||||||
|
@ -528,8 +528,7 @@ void VSCode::RegisterRequestCallback(std::string request,
|
|||||||
request_handlers[request] = callback;
|
request_handlers[request] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds,
|
lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds) {
|
||||||
uint32_t old_stop_id) {
|
|
||||||
lldb::SBError error;
|
lldb::SBError error;
|
||||||
lldb::SBProcess process = target.GetProcess();
|
lldb::SBProcess process = target.GetProcess();
|
||||||
if (!process.IsValid()) {
|
if (!process.IsValid()) {
|
||||||
@ -539,11 +538,6 @@ lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds,
|
|||||||
auto timeout_time =
|
auto timeout_time =
|
||||||
std::chrono::steady_clock::now() + std::chrono::seconds(seconds);
|
std::chrono::steady_clock::now() + std::chrono::seconds(seconds);
|
||||||
while (std::chrono::steady_clock::now() < timeout_time) {
|
while (std::chrono::steady_clock::now() < timeout_time) {
|
||||||
// Wait for stop id changed before checking for stopped state.
|
|
||||||
// This is needed to make sure we are not checking old stopped state in
|
|
||||||
// async mode.
|
|
||||||
if (old_stop_id > 0 && process.GetStopID() <= old_stop_id)
|
|
||||||
continue;
|
|
||||||
const auto state = process.GetState();
|
const auto state = process.GetState();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case lldb::eStateAttaching:
|
case lldb::eStateAttaching:
|
||||||
|
@ -144,7 +144,6 @@ struct VSCode {
|
|||||||
lldb::tid_t focus_tid;
|
lldb::tid_t focus_tid;
|
||||||
bool sent_terminated_event;
|
bool sent_terminated_event;
|
||||||
bool stop_at_entry;
|
bool stop_at_entry;
|
||||||
bool run_to_binary_entry = false;
|
|
||||||
bool is_attach;
|
bool is_attach;
|
||||||
bool configuration_done_sent;
|
bool configuration_done_sent;
|
||||||
uint32_t reverse_request_seq;
|
uint32_t reverse_request_seq;
|
||||||
@ -262,14 +261,9 @@ struct VSCode {
|
|||||||
///
|
///
|
||||||
/// \param[in] seconds
|
/// \param[in] seconds
|
||||||
/// The number of seconds to poll the process to wait until it is stopped.
|
/// The number of seconds to poll the process to wait until it is stopped.
|
||||||
/// \param[in] old_stop_id
|
|
||||||
/// Optional old stop id which we should only check for stopped state if
|
|
||||||
/// the new stop id is greater than it. This is needed if the previous state
|
|
||||||
/// is stopped so that we can ensure we are checking new stopped state not
|
|
||||||
/// the old one in async mode.
|
|
||||||
///
|
///
|
||||||
/// \return Error if waiting for the process fails, no error if succeeds.
|
/// \return Error if waiting for the process fails, no error if succeeds.
|
||||||
lldb::SBError WaitForProcessToStop(uint32_t seconds, uint32_t old_stop_id = 0);
|
lldb::SBError WaitForProcessToStop(uint32_t seconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Send the JSON in "json_str" to the "out" stream. Correctly send the
|
// Send the JSON in "json_str" to the "out" stream. Correctly send the
|
||||||
|
@ -1610,68 +1610,6 @@ llvm::Error request_runInTerminal(const llvm::json::Object &launch_request) {
|
|||||||
error.GetCString());
|
error.GetCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
lldb::SBError RunToBinaryEntry() {
|
|
||||||
lldb::SBError error;
|
|
||||||
if (!g_vsc.run_to_binary_entry)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
if (g_vsc.stop_at_entry) {
|
|
||||||
g_vsc.SendOutput(OutputType::Console,
|
|
||||||
"RunToBinaryEntry is ignored due to StopOnEntry\n");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
lldb::SBTarget target = g_vsc.debugger.GetSelectedTarget();
|
|
||||||
if (!target.IsValid())
|
|
||||||
return error;
|
|
||||||
lldb::SBFileSpec exe_file = target.GetExecutable();
|
|
||||||
if (!exe_file.IsValid())
|
|
||||||
return error;
|
|
||||||
lldb::SBModule exe_module = target.FindModule(exe_file);
|
|
||||||
if (!exe_module.IsValid()) {
|
|
||||||
g_vsc.SendOutput(OutputType::Console,
|
|
||||||
"RunToBinaryEntry failed: invalid executable module\n");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
lldb::SBAddress entry_point = exe_module.GetObjectFileEntryPointAddress();
|
|
||||||
if (!entry_point.IsValid()) {
|
|
||||||
g_vsc.SendOutput(OutputType::Console,
|
|
||||||
"RunToBinaryEntry failed: can't find entry point\n");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
lldb::SBBreakpoint entry_breakpoint =
|
|
||||||
target.BreakpointCreateBySBAddress(entry_point);
|
|
||||||
if (!entry_breakpoint.IsValid() || entry_breakpoint.GetNumLocations() == 0) {
|
|
||||||
g_vsc.SendOutput(OutputType::Console,
|
|
||||||
"RunToBinaryEntry failed: can't resolve the entry point breakpoint\n");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t old_stop_id = target.GetProcess().GetStopID();
|
|
||||||
entry_breakpoint.SetOneShot(true);
|
|
||||||
error = target.GetProcess().Continue();
|
|
||||||
if (error.Fail())
|
|
||||||
return error;
|
|
||||||
|
|
||||||
const uint64_t timeout_seconds = 600;
|
|
||||||
error = g_vsc.WaitForProcessToStop(timeout_seconds, old_stop_id);
|
|
||||||
if (error.Fail())
|
|
||||||
return error;
|
|
||||||
|
|
||||||
// Successfully got a process stop; we still need to check if the stop is what
|
|
||||||
// we expected.
|
|
||||||
if (entry_breakpoint.GetHitCount() == 0)
|
|
||||||
g_vsc.SendOutput(OutputType::Telemetry,
|
|
||||||
"RunToBinaryEntry failed: process stopped not at the "
|
|
||||||
"binary's entry point\n");
|
|
||||||
else
|
|
||||||
g_vsc.SendOutput(OutputType::Telemetry,
|
|
||||||
"RunToBinaryEntry success: Process stopped successfully "
|
|
||||||
"at the binary's entry point\n");
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "LaunchRequest": {
|
// "LaunchRequest": {
|
||||||
// "allOf": [ { "$ref": "#/definitions/Request" }, {
|
// "allOf": [ { "$ref": "#/definitions/Request" }, {
|
||||||
// "type": "object",
|
// "type": "object",
|
||||||
@ -1721,7 +1659,6 @@ void request_launch(const llvm::json::Object &request) {
|
|||||||
std::vector<std::string> postRunCommands =
|
std::vector<std::string> postRunCommands =
|
||||||
GetStrings(arguments, "postRunCommands");
|
GetStrings(arguments, "postRunCommands");
|
||||||
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
|
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
|
||||||
g_vsc.run_to_binary_entry = GetBoolean(arguments, "runToBinaryEntry", false);
|
|
||||||
const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
|
const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
|
||||||
const uint64_t timeout_seconds = GetUnsigned(arguments, "timeout", 30);
|
const uint64_t timeout_seconds = GetUnsigned(arguments, "timeout", 30);
|
||||||
|
|
||||||
@ -1804,9 +1741,6 @@ void request_launch(const llvm::json::Object &request) {
|
|||||||
error = g_vsc.WaitForProcessToStop(timeout_seconds);
|
error = g_vsc.WaitForProcessToStop(timeout_seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.Success())
|
|
||||||
error = RunToBinaryEntry();
|
|
||||||
|
|
||||||
if (error.Fail()) {
|
if (error.Fail()) {
|
||||||
response["success"] = llvm::json::Value(false);
|
response["success"] = llvm::json::Value(false);
|
||||||
EmplaceSafeString(response, "message", std::string(error.GetCString()));
|
EmplaceSafeString(response, "message", std::string(error.GetCString()));
|
||||||
|
@ -157,11 +157,6 @@
|
|||||||
"description": "Automatically stop after launch.",
|
"description": "Automatically stop after launch.",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"runToBinaryEntry": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "run to program entry one-shot breakpoint during launch to ensure dependency modules are loaded.",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"disableASLR": {
|
"disableASLR": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Enable or disable Address space layout randomization if the debugger supports it.",
|
"description": "Enable or disable Address space layout randomization if the debugger supports it.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user