Skip to content

Commit 03bdb35

Browse files
Catch unable to read memory errors (#739)
* logging failed addresses as hex values instead of base10, sending undefined when unable to read memory * adjusting to catch error message --------- Co-authored-by: Thorsten de Buhr <thorsten.deBuhr@arm.com>
1 parent 6e1536e commit 03bdb35

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/views/component-viewer/component-viewer-target-access.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ export class ComponentViewerTargetAccess {
149149
const response = await this._activeSession?.session.customRequest('readMemory', args) as DebugProtocol.ReadMemoryResponse['body'];
150150
return response?.data;
151151
} catch (error: unknown) {
152-
const errorMessage = (error as Error)?.message;
153-
logger.debug(`Session '${this._activeSession?.session.name}': Failed to read memory at address '${address}' - '${errorMessage}'`);
152+
// Change address to hex format for better logging
153+
const hexAddress = `0x${Number(address).toString(16)}`;
154+
const errorMessage = (error as Error)?.message + ` at address ${hexAddress}`;
155+
logger.debug(`Session '${this._activeSession?.session.name}': Failed to read memory at address '${hexAddress}' - '${errorMessage}'`);
154156
return errorMessage === 'custom request failed' ? 'No active session' : errorMessage;
155157
}
156158
}

src/views/component-viewer/scvd-debug-target.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ export class ScvdDebugTarget {
226226
if (typeof dataAsString !== 'string') {
227227
return undefined;
228228
}
229+
// if data is returned as error message string
230+
if (dataAsString.startsWith('Unable')) {
231+
return undefined;
232+
}
229233
// Convert String data to Uint8Array
230234
const byteArray = this.decodeGdbData(dataAsString);
231235

0 commit comments

Comments
 (0)