Fix in how lldb-mi integrates with the debugger detection logic (#1315)
* Tweak in the logic of detecting the CppTools lldb-mi debugger * Updated test expectations. One more fix regarding how lldb-mi integrates with the debugger detection logic. * Fix a mistake in the IF/ELSE changes * Improve readability in the debugger detection code
This commit is contained in:
Родитель
d1539be372
Коммит
e593c7c337
|
@ -151,29 +151,34 @@ export async function getDebugConfigurationFromCache(cache: CMakeCache, target:
|
|||
}
|
||||
|
||||
if (!debuggerPathOverride) {
|
||||
const clang_compiler_regex = /(clang[\+]{0,2})+(?!-cl)/gi;
|
||||
// Look for a debugger, in the following order:
|
||||
const cpptoolsExtension = vscode.extensions.getExtension('ms-vscode.cpptools');
|
||||
const cpptoolsDebuggerPath = cpptoolsExtension ? path.join(cpptoolsExtension.extensionPath, "debugAdapters", "lldb-mi", "bin", "lldb-mi") : undefined;
|
||||
let clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb-mi');
|
||||
// 1. lldb-mi in the compiler path
|
||||
if ((clang_debugger_path.search(new RegExp('lldb-mi')) != -1) && await checkDebugger(clang_debugger_path)) {
|
||||
return createLLDBDebugConfiguration(clang_debugger_path, target);
|
||||
} else if (cpptoolsDebuggerPath && await checkDebugger(cpptoolsDebuggerPath)) {
|
||||
// 2. lldb-mi installed by CppTools
|
||||
return createLLDBDebugConfiguration(cpptoolsDebuggerPath, target);
|
||||
} else {
|
||||
// 3. gdb in the compiler path
|
||||
clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'gdb');
|
||||
if ((clang_debugger_path.search(new RegExp('gdb')) != -1) && await checkDebugger(clang_debugger_path)) {
|
||||
return createGDBDebugConfiguration(clang_debugger_path, target);
|
||||
} else {
|
||||
// 4. lldb in the compiler path
|
||||
clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb');
|
||||
if ((clang_debugger_path.search(new RegExp('lldb')) != -1) && await checkDebugger(clang_debugger_path)) {
|
||||
return createLLDBDebugConfiguration(clang_debugger_path, target);
|
||||
}
|
||||
// 1. LLDB-MI
|
||||
const clang_compiler_regex = /(clang[\+]{0,2})+(?!-cl)/gi;
|
||||
let mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb-mi');
|
||||
if ((mi_debugger_path.search(new RegExp('lldb-mi')) != -1)) {
|
||||
const cpptoolsExtension = vscode.extensions.getExtension('ms-vscode.cpptools');
|
||||
const cpptoolsDebuggerPath = cpptoolsExtension ? path.join(cpptoolsExtension.extensionPath, "debugAdapters", "lldb-mi", "bin", "lldb-mi") : undefined;
|
||||
// 1a. lldb-mi in the compiler path
|
||||
if (await checkDebugger(mi_debugger_path)) {
|
||||
return createLLDBDebugConfiguration(mi_debugger_path, target);
|
||||
}
|
||||
|
||||
// 1b. lldb-mi installed by CppTools
|
||||
if (cpptoolsDebuggerPath && await checkDebugger(cpptoolsDebuggerPath)) {
|
||||
return createLLDBDebugConfiguration(cpptoolsDebuggerPath, target);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. gdb in the compiler path
|
||||
mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'gdb');
|
||||
if ((mi_debugger_path.search(new RegExp('gdb')) != -1) && await checkDebugger(mi_debugger_path)) {
|
||||
return createGDBDebugConfiguration(mi_debugger_path, target);
|
||||
}
|
||||
|
||||
// 3. lldb in the compiler path
|
||||
mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb');
|
||||
if ((mi_debugger_path.search(new RegExp('lldb')) != -1) && await checkDebugger(mi_debugger_path)) {
|
||||
return createLLDBDebugConfiguration(mi_debugger_path, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as chai from 'chai';
|
||||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
|
@ -37,13 +38,24 @@ suite('Select debugger', async () => {
|
|||
throw new Error();
|
||||
}
|
||||
expect(config.name).to.be.eq('Debug Test');
|
||||
expect(config['MIMode']).to.be.eq('gdb');
|
||||
expect(config.type).to.be.eq('cppdbg');
|
||||
expect(config['miDebuggerPath']).to.be.eq('gdb');
|
||||
expect(stub.called).to.be.true;
|
||||
|
||||
// If CppTools extension is installed, the lldb-mi installed with that extension
|
||||
// will represent the debugger fallback instead of gdb.
|
||||
const cpptoolsExtension = vscode.extensions.getExtension('ms-vscode.cpptools');
|
||||
const cpptoolsDebuggerPath = cpptoolsExtension ? path.join(cpptoolsExtension.extensionPath, "debugAdapters", "lldb-mi", "bin", "lldb-mi") : undefined;
|
||||
if (cpptoolsDebuggerPath) {
|
||||
expect(config['MIMode']).to.be.eq('lldb');
|
||||
expect(config['miDebuggerPath']).to.be.eq(cpptoolsDebuggerPath);
|
||||
expect(stub.calledWith('gdb')).to.be.false;
|
||||
} else {
|
||||
expect(config['MIMode']).to.be.eq('gdb');
|
||||
expect(config['miDebuggerPath']).to.be.eq('gdb');
|
||||
expect(stub.calledWith('gdb')).to.be.true;
|
||||
}
|
||||
|
||||
expect(stub.calledWith('lldb-mi')).to.be.true;
|
||||
expect(stub.calledWith('gdb')).to.be.true;
|
||||
});
|
||||
|
||||
test('Create debug config from cache - GCC', async () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче