Skip to content

Commit

Permalink
new setting for debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
haneefdm committed Mar 21, 2023
1 parent 1ecd934 commit b60a4ac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@
"minimum": -1,
"maximum": 32,
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device. -1 means never combine registers and is very slow"
},
"mcu-debug.peripheral-viewer.debugLevel": {
"type": "number",
"default": 0,
"minimum": 0,
"maximum": 2,
"multipleOf": 1,
"description": "Enable debug output in the OUTPUT Tab (Peripheral Viewer section). Some debug output may also be found in the `Mcu-debug Tracker` section which is controlled separately. Changing this value requires a Reload of the window"
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/debug-tracker-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*/

import * as vscode from 'vscode';
import * as manifest from './manifest';
import { DebugSessionStatus, DebugTracker, IDebuggerTrackerEvent, IDebugTracker, TRACKER_EXT_ID } from 'debug-tracker-vscode';
import { logOutputChannel, logToOutputWindow } from './vscode-utils';
import { setLogOutput, logOutputChannel, logToOutputWindow } from './vscode-utils';

export class DebugTrackerWrapper {
private isLocalTracker = false;
private dbgLevel: 0 | 1 | 2 = 0;
public constructor(private debugType = '*') {
}

Expand All @@ -28,6 +30,14 @@ export class DebugTrackerWrapper {

private sessionIdMap: {[id: string]: vscode.DebugSession} = {};
public async activate(context: vscode.ExtensionContext): Promise<void> {
// TODO: Make this dynamic so reloads are needed if setting changes
const dbgLevel = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get<number>(manifest.DEBUG_LEVEL, 0);
if ((dbgLevel >= 0) && (dbgLevel <= 2)) {
this.dbgLevel = dbgLevel as 0 | 1 | 2;
}
if (this.dbgLevel > 0) {
setLogOutput(true);
}
logToOutputWindow('activating debug tracker');
const debugtracker = await this.getTracker(context);
if (debugtracker) {
Expand All @@ -37,7 +47,7 @@ export class DebugTrackerWrapper {
body: {
debuggers: '*',
handler: async (event: IDebuggerTrackerEvent) => {
if (!this.isLocalTracker) {
if (!this.isLocalTracker || (this.dbgLevel > 1)) {
logToOutputWindow(JSON.stringify(event));
}
const session = this.sessionIdMap[event.sessionId];
Expand Down Expand Up @@ -78,7 +88,7 @@ export class DebugTrackerWrapper {
// We could use our own channel in the future for debug
this.isLocalTracker = true;
logToOutputWindow('Using local debug tracker');
ret = new DebugTracker(context, logOutputChannel, 1);
ret = new DebugTracker(context, logOutputChannel, this.dbgLevel);
} else {
logToOutputWindow('Using shared debug tracker');
}
Expand Down
1 change: 1 addition & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export const CONFIG_ADDRGAP = 'svdAddrGapThreshold';
export const DEFAULT_ADDRGAP = 16;
export const CONFIG_ASSET_PATH = 'packAssetUrl';
export const DEFAULT_ASSET_PATH = 'https://pack-asset-service.keil.arm.com';
export const DEBUG_LEVEL = 'debugLevel';
7 changes: 4 additions & 3 deletions src/vscode-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export const getSelection = async (title: string, items: QuickPickItem[], value?
}
};


let enableLogOutput = false;
export let logOutputChannel: vscode.OutputChannel | undefined;
// eslint-disable-next-line prefer-const
export let enableLogOutput = false; // TODO: This should be an extension option
export function setLogOutput(val: boolean) {
enableLogOutput = val;
}
export function logToOutputWindow(msg: string) {
if (enableLogOutput) {
if (!logOutputChannel) {
Expand Down

0 comments on commit b60a4ac

Please sign in to comment.