(thInfo: object, stackPattern: number)
| 379 | } |
| 380 | |
| 381 | protected async getStackInfo(thInfo: object, stackPattern: number): Promise<RTOSCommon.RTOSStackInfo> { |
| 382 | const TopOfStack = thInfo['pStack-val']; |
| 383 | |
| 384 | /* only available with #if (OS_SUPPORT_STACKCHECK != 0) || (OS_SUPPORT_MPU != 0) (optional) */ |
| 385 | const StackSize = thInfo['StackSize-val']; |
| 386 | let EndOfStack: any; |
| 387 | |
| 388 | if (thInfo.hasOwnProperty('pStackBase-val')) { |
| 389 | EndOfStack = thInfo['pStackBase-val']; |
| 390 | } |
| 391 | else { |
| 392 | /* older embOS versions used pStackBot instead of pStackBase */ |
| 393 | EndOfStack = thInfo['pStackBot-val']; |
| 394 | } |
| 395 | |
| 396 | let Stack = 0; |
| 397 | if (EndOfStack && StackSize) { |
| 398 | if (this.stackIncrements < 0) { |
| 399 | Stack = parseInt(EndOfStack) + parseInt(StackSize); |
| 400 | } |
| 401 | else { |
| 402 | Stack = parseInt(EndOfStack) - parseInt(StackSize); |
| 403 | } |
| 404 | } |
| 405 | else { |
| 406 | /* As stackStart is mandatory, we need to set it to some reasonable value */ |
| 407 | Stack = parseInt(TopOfStack); |
| 408 | } |
| 409 | |
| 410 | const stackInfo: RTOSCommon.RTOSStackInfo = { |
| 411 | stackStart: Stack, |
| 412 | stackTop: parseInt(TopOfStack) |
| 413 | }; |
| 414 | |
| 415 | if (EndOfStack && StackSize) { |
| 416 | stackInfo.stackEnd = parseInt(EndOfStack); |
| 417 | stackInfo.stackSize = parseInt(StackSize); |
| 418 | |
| 419 | if (this.stackIncrements < 0) { |
| 420 | const stackDelta = stackInfo.stackStart - stackInfo.stackTop; |
| 421 | stackInfo.stackFree = stackInfo.stackSize - stackDelta; |
| 422 | stackInfo.stackUsed = stackDelta; |
| 423 | } |
| 424 | else { |
| 425 | const stackDelta = stackInfo.stackTop - stackInfo.stackStart; |
| 426 | stackInfo.stackFree = stackDelta; |
| 427 | stackInfo.stackUsed = stackInfo.stackSize - stackDelta; |
| 428 | } |
| 429 | |
| 430 | /* check stack peak */ |
| 431 | const memArg: DebugProtocol.ReadMemoryArguments = { |
| 432 | memoryReference: hexFormat(Math.min(stackInfo.stackTop, stackInfo.stackEnd)), |
| 433 | count: stackInfo.stackFree |
| 434 | }; |
| 435 | try { |
| 436 | const stackData = await this.session.customRequest('readMemory', memArg); |
| 437 | const buf = Buffer.from(stackData.data, 'base64'); |
| 438 | stackInfo.bytes = new Uint8Array(buf); |
no test coverage detected