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

Seanmcm/debug fixes #3244

Merged
merged 8 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 15 additions & 0 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@
"command": "C_Cpp.TakeSurvey",
"title": "%c_cpp.command.takeSurvey.title%",
"category": "C/C++"
},
{
"command": "C_Cpp.BuildAndDebugActiveFile",
"title": "%c_cpp.command.buildAndDebugActiveFile.title%",
"category": "C/C++"
}
],
"keybindings": [
Expand Down Expand Up @@ -1393,6 +1398,16 @@
"when": "editorLangId == cpp",
"command": "workbench.action.showAllSymbols",
"group": "other@4"
},
{
"when": "editorLangId == cpp",
"command": "C_Cpp.BuildAndDebugActiveFile",
"group": "other@5"
},
{
"when": "editorLangId == c",
"command": "C_Cpp.BuildAndDebugActiveFile",
"group": "other@5"
}
]
},
Expand Down
13 changes: 6 additions & 7 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import * as debugUtils from './utils';
import * as os from 'os';
import * as path from 'path';
import * as vscode from 'vscode';
import { /*getBuildTasks,*/ BuildTaskDefinition } from '../LanguageServer/extension';
import { getBuildTasks, BuildTaskDefinition } from '../LanguageServer/extension';
import * as util from '../common';
import * as fs from 'fs';
//import * as assert from 'assert';
import * as Telemetry from '../telemetry';
import { buildAndDebugActiveFileStr } from './extension';

Expand Down Expand Up @@ -57,9 +56,9 @@ export class QuickPickConfigurationProvider implements vscode.DebugConfiguration

return vscode.window.showQuickPick(items, {placeHolder: "Select a configuration"}).then(async selection => {
// Wrap in new Promise to make sure task kicks off before VS Code switches the active document to launch.json
return new Promise<vscode.DebugConfiguration[]>(async resolve => {
return new Promise<vscode.DebugConfiguration[]>(async (resolve, reject) => {
if (!selection) {
return resolve([defaultConfig]); // User canceled it. Choose the default config?
return reject([]); // User canceled it.
bobbrow marked this conversation as resolved.
Show resolved Hide resolved
}
if (selection.label.indexOf(buildAndDebugActiveFileStr()) !== -1 && selection.configuration.preLaunchTask) {
try {
Expand Down Expand Up @@ -93,8 +92,8 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
* Returns a list of initial debug configurations based on contextual information, e.g. package.json or folder.
*/
async provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken): Promise<vscode.DebugConfiguration[]> {
let buildTasks: vscode.Task[]; // = await getBuildTasks(); // TODO
if (!buildTasks || buildTasks.length === 0) {
let buildTasks: vscode.Task[] = await getBuildTasks(); // TODO
sean-mcmanus marked this conversation as resolved.
Show resolved Hide resolved
if (buildTasks.length === 0 || this.type === DebuggerType.cppvsdbg) {
return Promise.resolve(this.provider.getInitialConfigurations(this.type));
}
const defaultConfig: vscode.DebugConfiguration = this.provider.getInitialConfigurations(this.type).find(config => {
Expand Down Expand Up @@ -127,7 +126,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
const suffix: string = suffixIndex === -1 ? "" : compilerName.substr(suffixIndex);
debuggerName = (platform === "darwin" ? "lldb" : "lldb-mi") + suffix;
} else {
debuggerName = "gdb";
debuggerName = platform === "win32" ? "gdb.exe" : "gdb";
sean-mcmanus marked this conversation as resolved.
Show resolved Hide resolved
}

const debuggerPath: string = path.join(compilerDirname, debuggerName);
Expand Down
4 changes: 2 additions & 2 deletions Extension/src/Debugger/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from 'vscode';
import * as os from 'os';
import { AttachPicker, RemoteAttachPicker, AttachItemsProvider } from './attachToProcess';
import { NativeAttachItemsProviderFactory } from './nativeAttach';
import { /*QuickPickConfigurationProvider,*/ ConfigurationAssetProviderFactory, CppVsDbgConfigurationProvider, CppDbgConfigurationProvider, ConfigurationSnippetProvider, IConfigurationAssetProvider } from './configurationProvider';
import { QuickPickConfigurationProvider, ConfigurationAssetProviderFactory, CppVsDbgConfigurationProvider, CppDbgConfigurationProvider, ConfigurationSnippetProvider, IConfigurationAssetProvider } from './configurationProvider';
import { CppdbgDebugAdapterDescriptorFactory, CppvsdbgDebugAdapterDescriptorFactory } from './debugAdapterDescriptorFactory';
import * as util from '../common';
import * as Telemetry from '../telemetry';
Expand Down Expand Up @@ -35,7 +35,7 @@ export function initialize(context: vscode.ExtensionContext): void {
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppvsdbg', new CppVsDbgConfigurationProvider(configurationProvider)));
}
const provider: CppDbgConfigurationProvider = new CppDbgConfigurationProvider(configurationProvider);
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppdbg', provider)); //new QuickPickConfigurationProvider(provider))); // TODO
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppdbg', new QuickPickConfigurationProvider(provider))); // TODO
sean-mcmanus marked this conversation as resolved.
Show resolved Hide resolved

disposables.push(vscode.commands.registerTextEditorCommand("C_Cpp.BuildAndDebugActiveFile", async (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => {
const folder: vscode.WorkspaceFolder = vscode.workspace.getWorkspaceFolder(textEditor.document.uri);
Expand Down
2 changes: 2 additions & 0 deletions Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export async function ensureBuildTaskExists(taskName: string): Promise<void> {
delete definition.compilerPath;
}

rawTasksJson.version = "2.0.0";

if (!rawTasksJson.tasks.find(task => { return task.label === selectedTask.definition.label; })) {
rawTasksJson.tasks.push(selectedTask.definition);
}
Expand Down