Msg/FunctionNestCount: Difference between revisions
From CPUlator Wiki
< Msg
< Msg
Created page with "A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the..." |
No edit summary |
||
Line 6: | Line 6: | ||
* Make sure functions are returning, not stuck in an unending recursion. | * Make sure functions are returning, not stuck in an unending recursion. | ||
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction. | * Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction. | ||
* Use the [https://cpulator.01xz.net/doc/#callstack '''Call stack window'''] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call in the | * Use the [https://cpulator.01xz.net/doc/#callstack '''Call stack window'''] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up. | ||
* The [https://cpulator.01xz.net/doc/#callstack '''Trace window'''] may also be useful to see the last 200 instructions executed. | * The [https://cpulator.01xz.net/doc/#callstack '''Trace window'''] may also be useful to see the last 200 instructions executed. | ||
Revision as of 08:32, 11 March 2019
A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.
This isn't technically an error, but if this behaviour is not expected, it is likely indicative of a bug.
Debugging
- Make sure functions are returning, not stuck in an unending recursion.
- Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.
- Use the Call stack window (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up.
- The Trace window may also be useful to see the last 200 instructions executed.
Implementation
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.
Disabling this message
This debugging check can be disabled in the Debugging Checks section of the Settings box: Function nesting too deep.