Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for function args + local variables #322

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mmaybee
Copy link
Contributor

@mmaybee mmaybee commented Mar 21, 2023

= Problem

Need a convenient way to see argument names and associated values when viewing call stacks.

= Solution

This PR introduces a new command stack_args that can be used to display detailed information (including values for local variables) for frames in a call stack. It takes one or more stack pointers as input. E.g.

    sdb> echo 0xffff96609b7d4680 | stack_args
    (struct task_struct *)0xffff96609b7d4680
    #0  struct rq *context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next, struct rq_flags *rf)
          rf = (struct rq_flags *)<absent>
          next = (struct task_struct *)<absent>
          prev = (struct task_struct *)<absent>
          rq = (struct rq *)<absent>
    #1  void __schedule(bool preempt)
          preempt = (bool)<absent>
          prev = (struct task_struct *)0xffff96609b7d4680
          next = (struct task_struct *)<absent>
          switch_count = (unsigned long *)<absent>
          rf = (struct rq_flags){ 0, {}, 4 }
          rq = (struct rq *)<absent>
          cpu = (int)<absent>
    #2  void schedule()
          tsk = (struct task_struct *)<absent>
    ...

The command accepts two arguments:

  1. -f <frame#> - will print only the requested frame of the stack, and provide more detail values provided for locals.
  2. -r - will print available register values for each stack frame.

Note that the syntax used here is still evolving and subject to change.

sdb/commands/linux/stacks.py Outdated Show resolved Hide resolved
sdb/commands/linux/stacks.py Outdated Show resolved Hide resolved
sdb/commands/linux/stacks.py Outdated Show resolved Hide resolved
...
"""

names = ["stack_args"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other names we might consider for this:

  • locals (it prints local variables)
  • stack --args (extension to existing command rather than new command)

sdb/commands/linux/stacks.py Show resolved Hide resolved
@grodr grodr changed the base branch from 6.0/stage to develop April 17, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants