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 support for SMP on FreeRTOS #44

Open
wants to merge 2 commits into
base: main
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rtos-views",
"displayName": "RTOS Views",
"description": "RTOS views for microcontrollers",
"version": "0.0.8",
"version": "0.0.9",
"publisher": "mcu-debug",
"preview": true,
"repository": {
Expand Down Expand Up @@ -114,7 +114,7 @@
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@vscode/test-electron": "^2.1.5",
"esbuild": "^0.14.53",
"esbuild": "^0.14.54",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"glob": "^8.0.3",
Expand Down
52 changes: 39 additions & 13 deletions src/rtos/rtos-freertos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {
private xDelayedTaskList2: RTOSCommon.RTOSVarHelperMaybe;
private xPendingReadyList: RTOSCommon.RTOSVarHelperMaybe;
private pxCurrentTCB: RTOSCommon.RTOSVarHelperMaybe;
private pxCurrentTCBs: RTOSCommon.RTOSVarHelperMaybe;
private xSuspendedTaskList: RTOSCommon.RTOSVarHelperMaybe;
private xTasksWaitingTermination: RTOSCommon.RTOSVarHelperMaybe;
private ulTotalRunTime: RTOSCommon.RTOSVarHelperMaybe;
private ulTotalRunTimeVal = 0;

private stale = true;
private curThreadAddr = 0;
private curThreadInfo = 0; // address (from pxCurrentTCB) of status (when multicore)
private foundThreads: RTOSCommon.RTOSThreadInfo[] = [];
private finalThreads: RTOSCommon.RTOSThreadInfo[] = [];
private timeInfo = '';
Expand Down Expand Up @@ -144,7 +145,13 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {
useFrameId,
'xPendingReadyList'
);
this.pxCurrentTCB = await this.getVarIfEmpty(this.pxCurrentTCB, useFrameId, 'pxCurrentTCB');
this.pxCurrentTCB = await this.getVarIfEmpty(this.pxCurrentTCB, useFrameId, 'pxCurrentTCB', true);
this.pxCurrentTCBs = await this.getVarIfEmpty(this.pxCurrentTCBs, useFrameId, 'pxCurrentTCBs', true);
if (this.pxCurrentTCBs === null && this.pxCurrentTCB === null) {
this.pxCurrentTCB = undefined;
this.pxCurrentTCBs = undefined;
throw Error('pxCurrentTCB nor pxCurrentTCBs not found');
}
this.xSuspendedTaskList = await this.getVarIfEmpty(
this.xSuspendedTaskList,
useFrameId,
Expand Down Expand Up @@ -220,15 +227,19 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {

private updateCurrentThreadAddr(frameId: number): Promise<void> {
return new Promise<void>((resolve, reject) => {
this.pxCurrentTCB?.getValue(frameId).then(
(ret) => {
this.curThreadAddr = parseInt(ret || '');
resolve();
},
(e) => {
reject(e);
}
);
if (this.pxCurrentTCB !== null) {
this.pxCurrentTCB?.getValue(frameId).then(
(ret) => {
this.curThreadInfo = parseInt(ret || '');
resolve();
},
(e) => {
reject(e);
}
);
} else {
resolve();
}
});
}

Expand Down Expand Up @@ -364,7 +375,7 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {
`((TCB_t*)${RTOSCommon.hexFormat(threadId)})`,
frameId
);
const threadRunning = threadId === this.curThreadAddr;
let threadRunning : boolean;
const tmpThName =
(await this.getExprVal('(char *)' + thInfo['pcTaskName']?.exp, frameId)) || '';
const match = tmpThName.match(/"([^*]*)"$/);
Expand All @@ -379,7 +390,22 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {
mySetter(DisplayFields.ID, thInfo['uxTCBNumber']?.val || '??');
mySetter(DisplayFields.Address, RTOSCommon.hexFormat(threadId));
mySetter(DisplayFields.TaskName, thName);
mySetter(DisplayFields.Status, threadRunning ? 'RUNNING' : state);
if (this.pxCurrentTCB !== null) {
threadRunning = threadId === this.curThreadInfo;
mySetter(DisplayFields.Status, threadRunning ? 'RUNNING' : state);
} else {
const xTaskRunState = thInfo['xTaskRunState']?.val;
if (xTaskRunState === '-2') {
threadRunning = false;
mySetter(DisplayFields.Status, 'YIELD');
}else if (xTaskRunState === '-1') {
threadRunning = false;
mySetter(DisplayFields.Status, state);
} else {
threadRunning = true;
mySetter(DisplayFields.Status, 'RUNNING(' + xTaskRunState + ')');
}
}
mySetter(DisplayFields.StackStart, RTOSCommon.hexFormat(stackInfo.stackStart));
mySetter(DisplayFields.StackTop, RTOSCommon.hexFormat(stackInfo.stackTop));
mySetter(
Expand Down