diff --git a/lldb/tools/lldb-vscode/README.md b/lldb/tools/lldb-vscode/README.md --- a/lldb/tools/lldb-vscode/README.md +++ b/lldb/tools/lldb-vscode/README.md @@ -181,15 +181,15 @@ ### Loading a Core File -Loading a core file can use the `"attach"` request along with the -`"attachCommands"` to implement a custom attach: +This loads the coredump file `/cores/123.core` associated with the program +`/tmp/a.out`: ```javascript { - "name": "Attach to Name (wait)", + "name": "Load coredump", "type": "lldb-vscode", "request": "attach", - "attachCommands": ["target create -c /path/to/123.core /path/to/executable"], - "stopOnEntry": false + "coreFile": "/cores/123.core", + "program": "/tmp/a.out" } ``` diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -530,7 +530,9 @@ g_vsc.stop_commands = GetStrings(arguments, "stopCommands"); g_vsc.exit_commands = GetStrings(arguments, "exitCommands"); auto attachCommands = GetStrings(arguments, "attachCommands"); - g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false); + auto core_file = GetString(arguments, "coreFile"); + g_vsc.stop_at_entry = + core_file.empty() ? GetBoolean(arguments, "stopOnEntry", false) : true; const auto debuggerRoot = GetString(arguments, "debuggerRoot"); // This is a hack for loading DWARF in .o files on Mac where the .o files @@ -569,7 +571,10 @@ // Disable async events so the attach will be successful when we return from // the launch call and the launch will happen synchronously g_vsc.debugger.SetAsync(false); - g_vsc.target.Attach(attach_info, error); + if (core_file.empty()) + g_vsc.target.Attach(attach_info, error); + else + g_vsc.target.LoadCore(core_file.data(), error); // Reenable async events g_vsc.debugger.SetAsync(true); } else { @@ -584,7 +589,7 @@ SetSourceMapFromArguments(*arguments); - if (error.Success()) { + if (error.Success() && core_file.empty()) { auto attached_pid = g_vsc.target.GetProcess().GetProcessID(); if (attached_pid == LLDB_INVALID_PROCESS_ID) { if (attachCommands.empty()) diff --git a/lldb/tools/lldb-vscode/package.json b/lldb/tools/lldb-vscode/package.json --- a/lldb/tools/lldb-vscode/package.json +++ b/lldb/tools/lldb-vscode/package.json @@ -218,8 +218,12 @@ }, "exitCommands": { "type": "array", - "description": "Commands executed at the end of debugging session.", - "default": [] + "description": "Commands executed at the end of debugging session.", + "default": [] + }, + "coreFile": { + "type": "string", + "description": "Path to the core file to debug. It's necessary to specify the \"program\" argument as well." } } }