From 38ceac687a0aff817b904bf279b90f61d7f1e1d8 Mon Sep 17 00:00:00 2001 From: "Kennedy Ho@Renesas" Date: Tue, 3 Mar 2026 14:31:24 +0900 Subject: [PATCH] Minor improvements for ThreadX detection - Make _tx_semaphore_created_count, _tx_mutex_created_count and _tx_byte_pool_created_count optional in tryDetect() so that minimal ThreadX applications without all the objects can be detected. - Added number of objects indicator to tab title, similar to FreeRTOS. - Added help/guide text in empty tabs when objects are not found or symbols missing. --- CHANGELOG.md | 1 + src/rtos/rtos-threadx.ts | 113 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90234d5..7edd523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add FS-RTOS support. FS-RTOS is very similar to uC/OS-II, so no need to create a own implementation for it. - Add another tab to ThreadX to display byte pools. - Contribution to support for Renesas Electronics GDB hardware and simulator debugger +- Some minor improvements for ThreadX detection ## 0.0.14 - Jan 25, 2026 diff --git a/src/rtos/rtos-threadx.ts b/src/rtos/rtos-threadx.ts index eafc65e..15e8e60 100644 --- a/src/rtos/rtos-threadx.ts +++ b/src/rtos/rtos-threadx.ts @@ -166,21 +166,21 @@ export class RTOSThreadX extends RTOSCommon.RTOSBase { this.semaphoreCreatedCount, useFrameId, '_tx_semaphore_created_count', - false, + true, ); this.mutexCreatedCount = await this.getVarIfEmpty( this.mutexCreatedCount, useFrameId, '_tx_mutex_created_count', - false, + true, ); this.bytePoolCreatedCount = await this.getVarIfEmpty( this.bytePoolCreatedCount, useFrameId, '_tx_byte_pool_created_count', - false, + true, ); this.status = 'initialized'; @@ -290,12 +290,54 @@ export class RTOSThreadX extends RTOSCommon.RTOSBase { const htmlBytePools = this.getHTMLTable(BytePoolItemNames, BytePoolTableItems, this.bytePools, (_) => ''); - const tabs = [{ title: 'Threads' }, { title: 'Semaphores' }, { title: 'Mutexes' }, { title: 'Byte Pools' }]; + const tabs = [ + { + title: `Threads + + ${this.threads.length} + ` + }, + { + title: `Semaphores + + ${this.semaphores.length} + ` + }, + { + title: `Mutexes + + ${this.mutexes.length} + ` + }, + { + title: `Byte Pools + + ${this.bytePools.length} + ` + } + ]; + const views = [ - { content: htmlThreads.html }, - { content: htmlSemaphores.html }, - { content: htmlMutexes.html }, - { content: htmlBytePools.html }, + { + content:(this.threads.length > 0) + ? htmlThreads.html + : this.getNoThreadsFoundHtml().html + }, + { + content: this.semaphoreCreatedCount + ? ((this.semaphores.length > 0) ? htmlSemaphores.html : this.getNoObjectsCreatedHtml('Semaphores', 'tx_semaphore_create()').html) + : this.getObjectNotAvailableHtml('Semaphores').html + }, + { + content: this.mutexCreatedCount + ? ((this.mutexes.length > 0) ? htmlMutexes.html : this.getNoObjectsCreatedHtml('Mutexes', 'tx_mutex_create()').html) + : this.getObjectNotAvailableHtml('Mutexes').html + }, + { + content: this.bytePoolCreatedCount + ? ((this.bytePools.length > 0) ? htmlBytePools.html : this.getNoObjectsCreatedHtml('Byte Pools', 'tx_byte_pool_create()').html) + : this.getObjectNotAvailableHtml('Byte Pools').html + }, ]; const htmlPanels = this.getHTMLPanels(tabs, views, [], true); @@ -306,6 +348,61 @@ export class RTOSThreadX extends RTOSCommon.RTOSBase { return htmlContent; } + /** + * Gets the HTML help text for missing symbol caused by ThreadX object not compiled or linked. + * @param objectName - Name of the ThreadX object in plural form. + * @returns Help text in the form of RTOSCommon.HtmlInfo. + */ + private getObjectNotAvailableHtml(objectName: string): RTOSCommon.HtmlInfo{ + return { + html: ` +
+
${objectName} not available in F/W
+
+ ${objectName} not compiled or linked into the firmware that is being debugged. +
+
`, + css: '' + }; + } + + /** + * Gets the HTML help text for when no ThreadX threads are found. This function is specifically for threads only. + * @returns Help text in the form of RTOSCommon.HtmlInfo. + */ + private getNoThreadsFoundHtml() : RTOSCommon.HtmlInfo { + return { + html: ` +
+
${this.name} threads not found
+
+ No threads detected, perhaps RTOS not yet initialized or threads yet to be created.
+ Call tx_thread_create() to create them if necessary. +
+
`, + css: '' + }; + } + + /** + * Gets the HTML help text for when no ThreadX objects are found. This is a generic function for all objects. + * @param objectName - Name of the ThreadX object in plural form. + * @param createFunctionName - Name of the tx_*_create() function used to create the ThreadX object. + * @returns Help text in the form of RTOSCommon.HtmlInfo. + */ + private getNoObjectsCreatedHtml(objectName: string, createFunctionName: string) : RTOSCommon.HtmlInfo { + return { + html: ` +
+
No ${objectName} found
+
+ ${objectName} not created. Call ${createFunctionName} to create them if necessary. +
+
`, + css: '' + }; + } + private async getThreadInfo(numThreads: number, frameId: number): Promise { const threads: RTOSCommon.RTOSThreadInfo[] = [];