mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 01:33:06 +00:00
c24ba99c8c
It's quite useful to run drgn's interactive REPL from a user-provided script. One reason is saving the drgn core dump and debuginfo setup into a script to more easily start analysis. Another might be to replace drgn's debuginfo loading scheme with one customized to a different environment. Or, a script might want to handle errors by allowing an interactive user to examine the program themselves. To serve all of these cases and more, separate out the logic of running the drgn REPL from the internal logic relating to argument parsing, choosing the correct target, and loading debuginfo. While this may seem like a simple case of code.interact, there are several important internal features drgn provides in its CLI: a custom displayhook, a custom readline completer, a history file, and of course the logic to import and include the proper drgn APIs and helpers for a core dump. This means creating a run_interactive() function and moving the cli module out of the drgn.internal package. Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
138 lines
2.8 KiB
ReStructuredText
138 lines
2.8 KiB
ReStructuredText
API Reference
|
|
=============
|
|
|
|
.. module:: drgn
|
|
|
|
Programs
|
|
--------
|
|
|
|
.. drgndoc:: Program
|
|
:exclude: (void|int|bool|float|struct|union|class|enum|typedef|pointer|array|function)_type
|
|
.. drgndoc:: ProgramFlags
|
|
.. drgndoc:: FindObjectFlags
|
|
|
|
.. drgndoc:: Thread
|
|
|
|
.. _api-filenames:
|
|
|
|
Filenames
|
|
^^^^^^^^^
|
|
|
|
The :meth:`Program.type()`, :meth:`Program.object()`,
|
|
:meth:`Program.variable()`, :meth:`Program.constant()`, and
|
|
:meth:`Program.function()` methods all take a *filename* parameter to
|
|
distinguish between multiple definitions with the same name. The filename
|
|
refers to the source code file that contains the definition. It is matched with
|
|
:func:`filename_matches()`. If multiple definitions match, one is returned
|
|
arbitrarily.
|
|
|
|
.. drgndoc:: filename_matches
|
|
|
|
.. _api-program-constructors:
|
|
|
|
Program Constructors
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
The drgn command line interface automatically creates a :class:`Program` named
|
|
``prog``. However, drgn may also be used as a library without the CLI, in which
|
|
case a ``Program`` must be created manually.
|
|
|
|
.. drgndoc:: program_from_core_dump
|
|
.. drgndoc:: program_from_kernel
|
|
.. drgndoc:: program_from_pid
|
|
|
|
Platforms
|
|
^^^^^^^^^
|
|
|
|
.. drgndoc:: Platform
|
|
.. drgndoc:: Architecture
|
|
.. drgndoc:: PlatformFlags
|
|
.. drgndoc:: Register
|
|
.. drgndoc:: host_platform
|
|
|
|
Languages
|
|
^^^^^^^^^
|
|
|
|
.. drgndoc:: Language
|
|
|
|
Objects
|
|
-------
|
|
|
|
.. drgndoc:: Object
|
|
.. drgndoc:: NULL
|
|
.. drgndoc:: cast
|
|
.. drgndoc:: reinterpret
|
|
.. drgndoc:: container_of
|
|
|
|
Symbols
|
|
-------
|
|
|
|
.. drgndoc:: Symbol
|
|
.. drgndoc:: SymbolBinding
|
|
.. drgndoc:: SymbolKind
|
|
|
|
Stack Traces
|
|
------------
|
|
|
|
Stack traces are retrieved with :meth:`Program.stack_trace()`.
|
|
|
|
.. drgndoc:: StackTrace
|
|
.. drgndoc:: StackFrame
|
|
|
|
.. _api-reference-types:
|
|
|
|
Types
|
|
-----
|
|
|
|
.. drgndoc:: Type
|
|
.. drgndoc:: TypeMember
|
|
.. drgndoc:: TypeEnumerator
|
|
.. drgndoc:: TypeParameter
|
|
.. drgndoc:: TypeTemplateParameter
|
|
.. drgndoc:: TypeKind
|
|
.. drgndoc:: PrimitiveType
|
|
.. drgndoc:: Qualifiers
|
|
.. drgndoc:: offsetof
|
|
|
|
.. _api-type-constructors:
|
|
|
|
Type Constructors
|
|
^^^^^^^^^^^^^^^^^
|
|
|
|
Custom drgn types can be created with the following factory functions. These
|
|
can be used just like types obtained from :meth:`Program.type()`.
|
|
|
|
.. drgndoc:: Program.void_type
|
|
.. drgndoc:: Program.int_type
|
|
.. drgndoc:: Program.bool_type
|
|
.. drgndoc:: Program.float_type
|
|
.. drgndoc:: Program.struct_type
|
|
.. drgndoc:: Program.union_type
|
|
.. drgndoc:: Program.class_type
|
|
.. drgndoc:: Program.enum_type
|
|
.. drgndoc:: Program.typedef_type
|
|
.. drgndoc:: Program.pointer_type
|
|
.. drgndoc:: Program.array_type
|
|
.. drgndoc:: Program.function_type
|
|
|
|
Miscellaneous
|
|
-------------
|
|
|
|
.. drgndoc:: sizeof
|
|
.. drgndoc:: execscript
|
|
.. drgndoc:: IntegerLike
|
|
.. drgndoc:: Path
|
|
|
|
Exceptions
|
|
----------
|
|
|
|
.. drgndoc:: FaultError
|
|
.. drgndoc:: MissingDebugInfoError
|
|
.. drgndoc:: ObjectAbsentError
|
|
.. drgndoc:: OutOfBoundsError
|
|
|
|
CLI
|
|
---
|
|
|
|
.. drgndoc:: cli
|