Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ed800ed14 | ||
|
|
1dddce718c |
@@ -1158,6 +1158,11 @@
|
||||
"light": "assets/ref-ungroup-by-type-light.svg",
|
||||
"dark": "assets/ref-ungroup-by-type-dark.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "C_Cpp.debugger.MemoryView",
|
||||
"title": "Open Memory View",
|
||||
"category": "C/C++"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
@@ -2030,6 +2035,10 @@
|
||||
{
|
||||
"command": "C_Cpp.referencesViewUngroupByType",
|
||||
"when": "cppReferenceTypes:hasResults"
|
||||
},
|
||||
{
|
||||
"command": "C_Cpp.debugger.MemoryView",
|
||||
"when": "debugType == 'cppdbg' && inDebugMode"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -342,29 +342,32 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
|
||||
let message: string = "";
|
||||
const sourceFileMapTarget: string = config.sourceFileMap[sourceFileMapSource];
|
||||
|
||||
// TODO: pass config.environment as 'additionalEnvironment' to resolveVariables when it is { key: value } instead of { "key": key, "value": value }
|
||||
const newSourceFileMapSource: string = util.resolveVariables(sourceFileMapSource, undefined);
|
||||
const newSourceFileMapTarget: string = util.resolveVariables(sourceFileMapTarget, undefined);
|
||||
if (util.isString(sourceFileMapTarget))
|
||||
{
|
||||
// TODO: pass config.environment as 'additionalEnvironment' to resolveVariables when it is { key: value } instead of { "key": key, "value": value }
|
||||
const newSourceFileMapSource: string = util.resolveVariables(sourceFileMapSource, undefined);
|
||||
const newSourceFileMapTarget: string = util.resolveVariables(sourceFileMapTarget, undefined);
|
||||
|
||||
let source: string = sourceFileMapSource;
|
||||
let target: string = sourceFileMapTarget;
|
||||
let source: string = sourceFileMapSource;
|
||||
let target: string = sourceFileMapTarget;
|
||||
|
||||
if (sourceFileMapSource !== newSourceFileMapSource) {
|
||||
message = "\t" + localize("replacing.sourcepath", "Replacing {0} '{1}' with '{2}'.", "sourcePath", sourceFileMapSource, newSourceFileMapSource);
|
||||
delete config.sourceFileMap[sourceFileMapSource];
|
||||
source = newSourceFileMapSource;
|
||||
}
|
||||
if (sourceFileMapSource !== newSourceFileMapSource) {
|
||||
message = "\t" + localize("replacing.sourcepath", "Replacing {0} '{1}' with '{2}'.", "sourcePath", sourceFileMapSource, newSourceFileMapSource);
|
||||
delete config.sourceFileMap[sourceFileMapSource];
|
||||
source = newSourceFileMapSource;
|
||||
}
|
||||
|
||||
if (sourceFileMapTarget !== newSourceFileMapTarget) {
|
||||
// Add a space if source was changed, else just tab the target message.
|
||||
message += (message ? ' ' : '\t');
|
||||
message += localize("replacing.targetpath", "Replacing {0} '{1}' with '{2}'.", "targetPath", sourceFileMapTarget, newSourceFileMapTarget);
|
||||
target = newSourceFileMapTarget;
|
||||
}
|
||||
if (sourceFileMapTarget !== newSourceFileMapTarget) {
|
||||
// Add a space if source was changed, else just tab the target message.
|
||||
message += (message ? ' ' : '\t');
|
||||
message += localize("replacing.targetpath", "Replacing {0} '{1}' with '{2}'.", "targetPath", sourceFileMapTarget, newSourceFileMapTarget);
|
||||
target = newSourceFileMapTarget;
|
||||
}
|
||||
|
||||
if (message) {
|
||||
config.sourceFileMap[source] = target;
|
||||
messages.push(message);
|
||||
if (message) {
|
||||
config.sourceFileMap[source] = target;
|
||||
messages.push(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
enum DebugSessionState {
|
||||
Unknown,
|
||||
Started,
|
||||
Running,
|
||||
Stopped,
|
||||
Exited
|
||||
}
|
||||
|
||||
export class CppDbgDebugAdapterTracker implements vscode.DebugAdapterTracker {
|
||||
|
||||
private state: DebugSessionState;
|
||||
|
||||
constructor(private session: vscode.DebugSession) {
|
||||
this.state = DebugSessionState.Unknown;
|
||||
}
|
||||
|
||||
sendEvaluateRequest(expression: string): Thenable<any> {
|
||||
if (this.state == DebugSessionState.Stopped)
|
||||
{
|
||||
return this.session.customRequest("evaluate", {
|
||||
expression: "-exec " + expression,
|
||||
context: "repl",
|
||||
frameId: -1
|
||||
})
|
||||
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
sendReadMemoryRequest(address: string, offset: number, count: number): Thenable<any> {
|
||||
if (this.state == DebugSessionState.Stopped)
|
||||
{
|
||||
return this.session.customRequest("readMemory", {
|
||||
memoryReference: address,
|
||||
offset: offset,
|
||||
count: count
|
||||
})
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* A session with the debug adapter is about to be started.
|
||||
*/
|
||||
onWillStartSession?(): void {
|
||||
this.state = DebugSessionState.Started;
|
||||
console.log("Started Session")
|
||||
}
|
||||
/**
|
||||
* The debug adapter is about to receive a Debug Adapter Protocol message from VS Code.
|
||||
*/
|
||||
onWillReceiveMessage?(message: any): void {
|
||||
console.log("Message Incomming!")
|
||||
}
|
||||
/**
|
||||
* The debug adapter has sent a Debug Adapter Protocol message to VS Code.
|
||||
*/
|
||||
onDidSendMessage?(message: any): void {
|
||||
if (message)
|
||||
{
|
||||
console.log(message)
|
||||
switch (message.type)
|
||||
{
|
||||
case "event":
|
||||
switch(message.event)
|
||||
{
|
||||
case "stopped":
|
||||
this.state = DebugSessionState.Stopped;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case "response":
|
||||
break
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The debug adapter session is about to be stopped.
|
||||
*/
|
||||
onWillStopSession?(): void {
|
||||
console.log("Stopping soon.")
|
||||
}
|
||||
/**
|
||||
* An error with the debug adapter has occurred.
|
||||
*/
|
||||
onError?(error: Error): void {
|
||||
console.log("Uh oh!")
|
||||
}
|
||||
/**
|
||||
* The debug adapter has exited with the given exit code or signal.
|
||||
*/
|
||||
onExit?(code: number | undefined, signal: string | undefined): void {
|
||||
console.log("Exiting!")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { CppDbgDebugAdapterTracker } from './debugAdapterTracker';
|
||||
|
||||
export class CppDbgDebugAdapterTrackerFactory implements vscode.DebugAdapterTrackerFactory {
|
||||
|
||||
activeTracker: CppDbgDebugAdapterTracker | undefined;
|
||||
|
||||
createDebugAdapterTracker(session: vscode.DebugSession): vscode.ProviderResult<vscode.DebugAdapterTracker> {
|
||||
this.activeTracker = new CppDbgDebugAdapterTracker(session);
|
||||
return this.activeTracker;
|
||||
}
|
||||
|
||||
getActiveDebugAdapterTracker(): CppDbgDebugAdapterTracker | undefined
|
||||
{
|
||||
return this.activeTracker;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import { AttachPicker, RemoteAttachPicker, AttachItemsProvider } from './attachT
|
||||
import { NativeAttachItemsProviderFactory } from './nativeAttach';
|
||||
import { QuickPickConfigurationProvider, ConfigurationAssetProviderFactory, CppVsDbgConfigurationProvider, CppDbgConfigurationProvider, ConfigurationSnippetProvider, IConfigurationAssetProvider } from './configurationProvider';
|
||||
import { CppdbgDebugAdapterDescriptorFactory, CppvsdbgDebugAdapterDescriptorFactory } from './debugAdapterDescriptorFactory';
|
||||
import { CppDbgDebugAdapterTrackerFactory } from './debugAdapterTrackerFactory';
|
||||
import * as util from '../common';
|
||||
import * as Telemetry from '../telemetry';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { CppDbgDebugAdapterTracker } from './debugAdapterTracker';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
@@ -43,6 +45,45 @@ export function initialize(context: vscode.ExtensionContext): void {
|
||||
const provider: CppDbgConfigurationProvider = new CppDbgConfigurationProvider(configurationProvider);
|
||||
disposables.push(vscode.debug.registerDebugConfigurationProvider('cppdbg', new QuickPickConfigurationProvider(provider)));
|
||||
|
||||
const trackerFactory: CppDbgDebugAdapterTrackerFactory = new CppDbgDebugAdapterTrackerFactory();
|
||||
disposables.push(vscode.debug.registerDebugAdapterTrackerFactory("cppdbg", trackerFactory))
|
||||
|
||||
disposables.push(vscode.commands.registerCommand("C_Cpp.debugger.MemoryView", (any) => {
|
||||
vscode.window.showInputBox({
|
||||
prompt: "What memory do you want."
|
||||
}, undefined).then(memoryAddress => {
|
||||
vscode.window.showInputBox({
|
||||
prompt: "With what offset?"
|
||||
}, undefined).then(offset => {
|
||||
vscode.window.showInputBox({
|
||||
prompt: "How much do you want to show?"
|
||||
}, undefined).then(size => {
|
||||
if (memoryAddress)
|
||||
{
|
||||
const tracker: CppDbgDebugAdapterTracker | undefined = trackerFactory.getActiveDebugAdapterTracker()
|
||||
if (tracker)
|
||||
{
|
||||
tracker.sendReadMemoryRequest(memoryAddress, Number(offset), Number(size)).then(response => {
|
||||
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[0].uri.fsPath)
|
||||
{
|
||||
const filePath = "C:\\cdmem\\memory.txt"
|
||||
const fsURI = vscode.Uri.parse(`file://${filePath}`);
|
||||
vscode.workspace.fs.writeFile(fsURI, Uint8Array.from(response.data)).then(() => {
|
||||
vscode.commands.executeCommand("vscode.openWith", fsURI, "hexEditor.hexedit", { preview: false });
|
||||
}, (error) => {
|
||||
const msg = (error.message || '') + '\nPerhaps expression for "address" contains invalid file name characters';
|
||||
vscode.window.showErrorMessage(`Unable to create/write memory file memory from ${fsURI.toString()}: ${msg}`);
|
||||
});
|
||||
console.log(response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}));
|
||||
|
||||
disposables.push(vscode.commands.registerTextEditorCommand("C_Cpp.BuildAndDebugActiveFile", async (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => {
|
||||
const folder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(textEditor.document.uri);
|
||||
if (!folder) {
|
||||
|
||||
Reference in New Issue
Block a user