def attach(self, program=None, pid=None, waitFor=None, trace=None,
initCommands=None, preRunCommands=None, stopCommands=None,
- exitCommands=None, attachCommands=None):
+ exitCommands=None, attachCommands=None, coreFile=None):
'''Build the default Makefile target, create the VSCode debug adaptor,
and attach to the process.
'''
program=program, pid=pid, waitFor=waitFor, trace=trace,
initCommands=initCommands, preRunCommands=preRunCommands,
stopCommands=stopCommands, exitCommands=exitCommands,
- attachCommands=attachCommands)
+ attachCommands=attachCommands, coreFile=coreFile)
if not (response and response['success']):
self.assertTrue(response['success'],
'attach failed (%s)' % (response['message']))
def request_attach(self, program=None, pid=None, waitFor=None, trace=None,
initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None,
- attachCommands=None):
+ attachCommands=None, coreFile=None):
args_dict = {}
if pid is not None:
args_dict['pid'] = pid
args_dict['exitCommands'] = exitCommands
if attachCommands:
args_dict['attachCommands'] = attachCommands
+ if coreFile:
+ args_dict['coreFile'] = coreFile
command_dict = {
'command': 'attach',
'type': 'request',
--- /dev/null
+"""
+Test lldb-vscode coreFile attaching
+"""
+
+
+import unittest2
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbvscode_testcase
+import os
+
+
+class TestVSCode_coreFile(lldbvscode_testcase.VSCodeTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows
+ @skipIfRemote
+ @skipIfLLVMTargetMissing("X86")
+ def test_core_file(self):
+ current_dir = os.path.dirname(os.path.realpath(__file__))
+ exe_file = os.path.join(current_dir, "linux-x86_64.out")
+ core_file = os.path.join(current_dir, "linux-x86_64.core")
+
+ self.create_debug_adaptor()
+ self.attach(exe_file, coreFile=core_file)
+
+ expected_frames = [
+ {'column': 0, 'id': 524288, 'line': 4, 'name': 'bar', 'source': {'name': 'main.c', 'path': '/home/labath/test/main.c'}},
+ {'column': 0, 'id': 524289, 'line': 10, 'name': 'foo', 'source': {'name': 'main.c', 'path': '/home/labath/test/main.c'}},
+ {'column': 0, 'id': 524290, 'line': 16, 'name': '_start', 'source': {'name': 'main.c', 'path': '/home/labath/test/main.c'}},
+ ]
+
+ self.assertEquals(self.get_stackFrames(), expected_frames)
+
+ # Resuming should have no effect and keep the process stopped
+ self.continue_to_next_stop()
+ self.assertEquals(self.get_stackFrames(), expected_frames)
+
+ self.vscode.request_next(threadId=32259)
+ self.assertEquals(self.get_stackFrames(), expected_frames)
### 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"
}
```
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);
+ llvm::StringRef core_file = GetString(arguments, "coreFile");
+ g_vsc.stop_at_entry =
+ core_file.empty() ? GetBoolean(arguments, "stopOnEntry", false) : true;
const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
// This is a hack for loading DWARF in .o files on Mac where the .o files
// 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 {
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())
},
"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."
}
}
}