Skip to content

GDB: AmForth Stack Framing #2

@mkobetic

Description

@mkobetic

It might be possible to make GDB backtrace usable with AmForth, the Google AI tips below might be worth checking out:

For significant customization, such as handling non-standard calling conventions or modifying how frame information is presented, GDB provides a powerful Python API.

Custom Unwinders:
You can write a custom gdb.Unwinder in Python to define how GDB should traverse the stack and locate frame information, especially useful for functions that omit frame pointers (e.g., those compiled with -fomit-frame-pointer) or use unusual stack layouts.

Frame Decorators and Filters:
Frame Decorators (gdb.FrameDecorator) allow you to modify the information associated with an existing frame object, such as changing how function names or arguments appear.
Frame Filters are used to register these decorators with GDB's global frame filter dictionary, allowing your custom logic to be applied to the stack trace output.

A possible solution might be:

  • if we can somehow distinguish return IPs from other stuff on return stack we can build a frame for each of those
  • if we could somehow capture parameter stack depth at each frame that would be awesome, that may require injecting markers into the return stack or a parallel stack indexing the return stack (a debug mode forth?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions