Skip to content

Commit

Permalink
Make stack_trace() shortcut use default program argument logic
Browse files Browse the repository at this point in the history
Instead of always using the default program, if the thread argument is
an Object, we should use thread.prog_.

Signed-off-by: Omar Sandoval <[email protected]>
  • Loading branch information
osandov committed Dec 1, 2023
1 parent 8ed2403 commit 433c735
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drgn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import pkgutil
import sys
import types
from typing import Union

from _drgn import (
NULL,
Expand Down Expand Up @@ -263,11 +264,17 @@ def task_exe_path(task):
del sys.modules["__main__"]


def stack_trace(thread: Object) -> StackTrace:
def stack_trace(thread: Union[Object, IntegerLike]) -> StackTrace:
"""
Get the stack trace for the given thread in the :ref:`default-program`.
Get the stack trace for the given thread using the :ref:`default program
argument <default-program>`.
This is equivalent to ``get_default_prog().stack_trace(thread)``. See
:meth:`Program.stack_trace()` for more details.
See :meth:`Program.stack_trace()` for more details.
:param thread: Thread ID, ``struct pt_regs`` object, or
``struct task_struct *`` object.
"""
return get_default_prog().stack_trace(thread)
if isinstance(thread, Object):
return thread.prog_.stack_trace(thread)
else:
return get_default_prog().stack_trace(thread)

0 comments on commit 433c735

Please sign in to comment.