2019-04-04 09:27:23 +01:00
|
|
|
API Reference
|
|
|
|
=============
|
|
|
|
|
|
|
|
.. module:: drgn
|
|
|
|
|
|
|
|
Programs
|
|
|
|
--------
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: Program
|
Associate types with program
I originally envisioned types as dumb descriptors. This mostly works for
C because in C, types are fairly simple. However, even then the
drgn_program_member_info() API is awkward. You should be able to look up
a member directly from a type, but we need the program for caching
purposes. This has also held me back from adding offsetof() or
has_member() APIs.
Things get even messier with C++. C++ template parameters can be objects
(e.g., template <int N>). Such parameters would best be represented by a
drgn object, which we need a drgn program for. Static members are a
similar case.
So, let's reimagine types as being owned by a program. This has a few
parts:
1. In libdrgn, simple types are now created by factory functions,
drgn_foo_type_create().
2. To handle their variable length fields, compound types, enum types,
and function types are constructed with a "builder" API.
3. Simple types are deduplicated.
4. The Python type factory functions are replaced by methods of the
Program class.
5. While we're changing the API, the parameters to pointer_type() and
array_type() are reordered to be more logical (and to allow
pointer_type() to take a default size of None for the program's
default pointer size).
6. Likewise, the type factory methods take qualifiers as a keyword
argument only.
A big part of this change is updating the tests and splitting up large
test cases into smaller ones in a few places.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2020-07-16 00:34:56 +01:00
|
|
|
:exclude: (void|int|bool|float|complex|struct|union|class|enum|typedef|pointer|array|function)_type
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: ProgramFlags
|
|
|
|
.. drgndoc:: FindObjectFlags
|
2019-04-29 02:07:21 +01:00
|
|
|
|
2019-04-04 09:27:23 +01:00
|
|
|
.. _api-filenames:
|
|
|
|
|
|
|
|
Filenames
|
|
|
|
^^^^^^^^^
|
|
|
|
|
2019-04-29 02:07:21 +01:00
|
|
|
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
|
2019-05-10 07:53:16 +01:00
|
|
|
refers to the source code file that contains the definition. It is matched with
|
|
|
|
:func:`filename_matches()`. If multiple definitions match, one is returned
|
2019-04-04 09:27:23 +01:00
|
|
|
arbitrarily.
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: filename_matches
|
2019-05-10 07:53:16 +01:00
|
|
|
|
2019-04-04 09:27:23 +01:00
|
|
|
.. _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.
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: program_from_core_dump
|
|
|
|
.. drgndoc:: program_from_kernel
|
|
|
|
.. drgndoc:: program_from_pid
|
2019-04-04 09:27:23 +01:00
|
|
|
|
2019-07-29 08:57:28 +01:00
|
|
|
Platforms
|
|
|
|
^^^^^^^^^
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: Platform
|
|
|
|
.. drgndoc:: Architecture
|
|
|
|
.. drgndoc:: PlatformFlags
|
|
|
|
.. drgndoc:: Register
|
|
|
|
.. drgndoc:: host_platform
|
2019-07-29 08:57:28 +01:00
|
|
|
|
2020-02-21 23:08:37 +00:00
|
|
|
Languages
|
|
|
|
^^^^^^^^^
|
|
|
|
|
|
|
|
.. drgndoc:: Language
|
|
|
|
|
2019-04-04 09:27:23 +01:00
|
|
|
Objects
|
|
|
|
-------
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: Object
|
|
|
|
.. drgndoc:: NULL
|
|
|
|
.. drgndoc:: cast
|
|
|
|
.. drgndoc:: reinterpret
|
|
|
|
.. drgndoc:: container_of
|
2019-04-04 09:27:23 +01:00
|
|
|
|
2019-07-25 08:47:13 +01:00
|
|
|
Symbols
|
|
|
|
-------
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: Symbol
|
2019-07-25 08:47:13 +01:00
|
|
|
|
2019-07-29 22:41:33 +01:00
|
|
|
Stack Traces
|
|
|
|
------------
|
|
|
|
|
2019-10-26 00:11:14 +01:00
|
|
|
Stack traces are retrieved with :meth:`Program.stack_trace()`.
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: StackTrace
|
|
|
|
.. drgndoc:: StackFrame
|
2019-10-18 10:42:51 +01:00
|
|
|
|
2019-04-04 09:27:23 +01:00
|
|
|
.. _api-reference-types:
|
|
|
|
|
|
|
|
Types
|
|
|
|
-----
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: Type
|
|
|
|
.. drgndoc:: TypeMember
|
|
|
|
.. drgndoc:: TypeEnumerator
|
|
|
|
.. drgndoc:: TypeParameter
|
|
|
|
.. drgndoc:: TypeKind
|
|
|
|
.. drgndoc:: PrimitiveType
|
|
|
|
.. drgndoc:: Qualifiers
|
2019-04-04 09:27:23 +01:00
|
|
|
|
|
|
|
.. _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()`.
|
|
|
|
|
Associate types with program
I originally envisioned types as dumb descriptors. This mostly works for
C because in C, types are fairly simple. However, even then the
drgn_program_member_info() API is awkward. You should be able to look up
a member directly from a type, but we need the program for caching
purposes. This has also held me back from adding offsetof() or
has_member() APIs.
Things get even messier with C++. C++ template parameters can be objects
(e.g., template <int N>). Such parameters would best be represented by a
drgn object, which we need a drgn program for. Static members are a
similar case.
So, let's reimagine types as being owned by a program. This has a few
parts:
1. In libdrgn, simple types are now created by factory functions,
drgn_foo_type_create().
2. To handle their variable length fields, compound types, enum types,
and function types are constructed with a "builder" API.
3. Simple types are deduplicated.
4. The Python type factory functions are replaced by methods of the
Program class.
5. While we're changing the API, the parameters to pointer_type() and
array_type() are reordered to be more logical (and to allow
pointer_type() to take a default size of None for the program's
default pointer size).
6. Likewise, the type factory methods take qualifiers as a keyword
argument only.
A big part of this change is updating the tests and splitting up large
test cases into smaller ones in a few places.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2020-07-16 00:34:56 +01:00
|
|
|
.. drgndoc:: Program.void_type
|
|
|
|
.. drgndoc:: Program.int_type
|
|
|
|
.. drgndoc:: Program.bool_type
|
|
|
|
.. drgndoc:: Program.float_type
|
|
|
|
.. drgndoc:: Program.complex_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
|
2019-04-04 09:27:23 +01:00
|
|
|
|
2019-06-28 20:48:45 +01:00
|
|
|
Miscellaneous
|
|
|
|
-------------
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: sizeof
|
|
|
|
.. drgndoc:: execscript
|
2020-08-13 22:47:59 +01:00
|
|
|
.. drgndoc:: IntegerLike
|
2020-08-13 23:27:20 +01:00
|
|
|
.. drgndoc:: Path
|
2019-06-28 20:48:45 +01:00
|
|
|
|
2019-04-04 09:27:23 +01:00
|
|
|
Exceptions
|
|
|
|
----------
|
|
|
|
|
2020-02-25 19:43:01 +00:00
|
|
|
.. drgndoc:: FaultError
|
|
|
|
.. drgndoc:: MissingDebugInfoError
|
|
|
|
.. drgndoc:: OutOfBoundsError
|