Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macOS lldb for Apple silicon macs #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@
"vscode-debugadapter": "^1.45.0"
},
"devDependencies": {
"@types/vscode": "^1.49.0",
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.0",
"@types/node": "^14.0.27",
"eslint": "^7.6.0",
"@types/vscode": "^1.49.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"glob": "^7.1.6",
"mocha": "^8.0.1",
"ts-loader": "^8.0.3",
"typescript": "^3.8.3",
"vscode-debugadapter-testsupport": "^1.45.0",
"vsce": "^1.81.1",
"ts-loader": "^8.0.3",
"vscode-debugadapter-testsupport": "^1.45.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
},
Expand Down Expand Up @@ -192,9 +192,10 @@
"custom",
"manual",
"default (win) Attach",
"default (gdb) Attach"
"default (gdb) Attach",
"default (lldb) Attach"
],
"description": "Pick 'default (win)/(gdb)' if you wish to use the default configuration, otherwise 'custom' and specify the 'cppAttachName' attribute",
"description": "Pick 'default (win)/(gdb)/(lldb)' if you wish to use the default configuration, otherwise 'custom' and specify the 'cppAttachName' attribute",
"default": "custom"
},
"entirePythonConfig": {
Expand Down Expand Up @@ -235,7 +236,7 @@
"type": "pythoncpp",
"request": "launch",
"pythonConfig": "default",
"cppConfig": "!!pick 'default (win) Attach' or 'default (gdb) Attach'"
"cppConfig": "!!!pick 'default (win) Attach' or 'default (gdb) Attach' or 'default (lldb) Attach'"
}
},
{
Expand All @@ -246,11 +247,11 @@
"type": "pythoncpp",
"request": "launch",
"pythonLaunchName": "Python: Current File",
"cppAttachName": "'(Windows) Attach' or '(gdb) Attach'"
"cppAttachName": "'(Windows) Attach' or '(gdb) Attach' or '(lldb) Attach'"
}
}
]
}
]
}
}
}
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ If you plan to use the default configuration of the python and/or C++ debugger,
* **C++:**
- `cppConfig: default (win) Attach` will attach the C++ debugger with the `(Windows) Attach` config.
- `cppConfig: default (gdb) Attach` will attach the C++ debugger with the `(gdb) Attach` config. This will also set the program path automatically to the path of the current python interpreter and lookup the gdb path.
- `cppConfig: default (lldb) Attach` will attach the C++ debugger with the `(lldb) Attach` config. This will also set the program path automatically to the path of the current python interpreter and lookup the lldb path.

```json
{
Expand All @@ -41,7 +42,7 @@ If you plan to use the default configuration of the python and/or C++ debugger,

To manually define the configurations you can set the attributes `pythonLaunchName` & `cppAttachName` to the name of the configuration you wish to use from your launch.json file.

The following is an example launch.json file for windows users. If your working on Linux make sure to have a `(gdb) Attach` configuration instead of `(Windows) Attach`.
The following is an example launch.json file for windows users. If your working on Linux make sure to have a `(gdb) Attach` configuration, or on macOS use `(lldb) Attach`, instead of `(Windows) Attach`.

```json
{
Expand Down
45 changes: 32 additions & 13 deletions src/activatePythonCppDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function activatePythonCppDebug(context: vscode.ExtensionContext, factory
name: 'PythonCpp Debug',
request: 'launch',
pythonConfig: 'default',
cppConfig: os.platform().startsWith("win") ? "default (win) Attach" : "default (gdb) Attach"
cppConfig: os.platform().startsWith("win") ? "default (win) Attach" : os.platform() === "darwin" ? "default (lldb) Attach" : "default (gdb) Attach"
},
{ noDebug: true }
);
Expand All @@ -40,7 +40,7 @@ export function activatePythonCppDebug(context: vscode.ExtensionContext, factory
name: 'PythonCpp Debug',
request: 'launch',
pythonConfig: 'default',
cppConfig: os.platform().startsWith("win") ? "default (win) Attach" : "default (gdb) Attach"
cppConfig: os.platform().startsWith("win") ? "default (win) Attach" : os.platform() === "darwin" ? "default (lldb) Attach" : "default (gdb) Attach"
});
}
})
Expand Down Expand Up @@ -93,9 +93,9 @@ class PythonCppConfigurationProvider implements vscode.DebugConfigurationProvide
((config.pythonConfig && (config.pythonConfig === 'custom' || config.pythonConfig === 'manual')) || !config.pythonConfig) &&
!config.pythonLaunchName
) {
let msg =
"Make sure to either set 'pythonLaunchName' to the name of " +
"your python configuration or set 'pythonConfig: default'";
let msg =
"Make sure to either set 'pythonLaunchName' to the name of " +
"your python configuration or set 'pythonConfig: default'";
return vscode.window.showErrorMessage(msg).then(_ => {
return undefined; // abort launch
});
Expand All @@ -106,9 +106,9 @@ class PythonCppConfigurationProvider implements vscode.DebugConfigurationProvide
((config.cppConfig && (config.cppConfig === 'custom' || config.cppConfig === 'manual')) || !config.cppConfig) &&
!config.cppAttachName
) {
let msg =
"Make sure to either set 'cppAttachName' to the name of " +
"your C++ configuration or set 'cppConfig' to the default configuration you wish to use";
let msg =
"Make sure to either set 'cppAttachName' to the name of " +
"your C++ configuration or set 'cppConfig' to the default configuration you wish to use";
return vscode.window.showErrorMessage(msg).then(_ => {
return undefined; // abort launch
});
Expand All @@ -118,7 +118,7 @@ class PythonCppConfigurationProvider implements vscode.DebugConfigurationProvide
}

async provideDebugConfigurations(
folder?: vscode.WorkspaceFolder,
folder?: vscode.WorkspaceFolder,
token?: vscode.CancellationToken
): Promise<vscode.DebugConfiguration[]> {

Expand All @@ -127,6 +127,24 @@ class PythonCppConfigurationProvider implements vscode.DebugConfigurationProvide
type: string;
}

const lldbConfig: vscode.DebugConfiguration = {
"name": "(lldb) Attach",
"type": "cppdbg",
"request": "attach",
"program": await getPythonPath(null),
"processId": "",
// eslint-disable-next-line @typescript-eslint/naming-convention
"MIMode": "lldb",
"miDebuggerPath": "/path/to/lldb or remove this attribute for the path to be found automatically",
"setupCommands": [
{
"description": "Enable pretty-printing for lldb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
};

const gdbConfig: vscode.DebugConfiguration = {
"name": "(gdb) Attach",
"type": "cppdbg",
Expand Down Expand Up @@ -155,18 +173,19 @@ class PythonCppConfigurationProvider implements vscode.DebugConfigurationProvide
const items: MenuItem[] = [
{ label: "Python C++ Debugger", configuration: winConfig, description: "Default", type: "Default" },
{ label: "Python C++ Debugger", configuration: winConfig, description: "Custom: Windows", type: "(Windows)" },
{ label: "Python C++ Debugger", configuration: gdbConfig, description: "Custom: GDB", type: "(gdb)" }
{ label: "Python C++ Debugger", configuration: gdbConfig, description: "Custom: GDB", type: "(gdb)" },
{ label: "Python C++ Debugger", configuration: lldbConfig, description: "Custom: LLDB", type: "(lldb)" }
];

const selection: MenuItem | undefined = await vscode.window.showQuickPick(items, { placeHolder: "Select a configuration" });
if(!selection || selection.type === "Default") {
if (!selection || selection.type === "Default") {
const defaultConfig: vscode.DebugConfiguration = {
"name": "Python C++ Debugger",
"type": "pythoncpp",
"request": "launch",
"pythonConfig": "default",
"cppConfig": os.platform().startsWith("win") ? "default (win) Attach" : "default (gdb) Attach"
};
cppConfig: os.platform().startsWith("win") ? "default (win) Attach" : os.platform() === "darwin" ? "default (lldb) Attach" : "default (gdb) Attach"
};
return [defaultConfig];
}

Expand Down
Loading