Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Delphix Engineering committed Sep 1, 2024
2 parents a4f9618 + 6c56bd2 commit 22b3907
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 310 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ First, install dependencies:
<https://aur.archlinux.org/packages/libkdumpfile/>`__ from the AUR or from
source if you want support for the makedumpfile format.

* Gentoo

.. code-block:: console
$ sudo emerge --noreplace --oneshot dev-build/autoconf dev-build/automake dev-libs/check dev-libs/elfutils sys-devel/gcc dev-vcs/git dev-libs/libkdumpfile dev-build/libtool dev-build/make dev-python/pip virtual/pkgconfig dev-lang/python dev-python/setuptools
* openSUSE

.. code-block:: console
Expand Down
10 changes: 9 additions & 1 deletion _drgn.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ if sys.version_info < (3, 10):
else:
from typing import TypeAlias

if sys.version_info < (3, 12):
from typing_extensions import Buffer
else:
from collections.abc import Buffer

# This is effectively typing.SupportsIndex without @typing.runtime_checkable
# (both of which are only available since Python 3.8), with a more
# self-explanatory name.
Expand Down Expand Up @@ -1534,14 +1539,17 @@ class Object:
cls,
prog: Program,
type: Union[str, Type],
bytes: bytes,
bytes: Buffer,
*,
bit_offset: IntegerLike = 0,
bit_field_size: Optional[IntegerLike] = None,
) -> Object:
"""
Return a value object from its binary representation.
>>> print(Object.from_bytes_(prog, "int", b"\x10\x00\x00\x00"))
(int)16
:param prog: Program to create the object in.
:param type: Type of the object.
:param bytes: Buffer containing value of the object.
Expand Down
37 changes: 35 additions & 2 deletions libdrgn/dwarf_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
enum { DW_ACCESS_DEFINITIONS };

#define DW_ADDR_DEFINITIONS \
X(DW_ADDR_none, 0x0)
X(DW_ADDR_none, 0x0) \
X(DW_ADDR_TI_PTR8, 0x8) \
X(DW_ADDR_TI_PTR16, 0x10) \
X(DW_ADDR_TI_PTR22, 0x16) \
X(DW_ADDR_TI_PTR23, 0x17) \
X(DW_ADDR_TI_PTR24, 0x18) \
X(DW_ADDR_TI_PTR32, 0x20)
enum { DW_ADDR_DEFINITIONS };

#define DW_AT_DEFINITIONS \
Expand Down Expand Up @@ -163,7 +169,9 @@ enum { DW_ADDR_DEFINITIONS };
X(DW_AT_ghs_using_declaration, 0x808) \
X(DW_AT_HP_block_index, 0x2000) \
X(DW_AT_lo_user, 0x2000) \
X(DW_AT_TI_veneer, 0x2000) \
X(DW_AT_MIPS_fde, 0x2001) \
X(DW_AT_TI_symbol_name, 0x2001) \
X(DW_AT_MIPS_loop_begin, 0x2002) \
X(DW_AT_MIPS_tail_loop_begin, 0x2003) \
X(DW_AT_MIPS_epilog_begin, 0x2004) \
Expand All @@ -174,12 +182,16 @@ enum { DW_ADDR_DEFINITIONS };
X(DW_AT_MIPS_abstract_name, 0x2009) \
X(DW_AT_MIPS_clone_origin, 0x200a) \
X(DW_AT_MIPS_has_inlines, 0x200b) \
X(DW_AT_TI_version, 0x200b) \
X(DW_AT_MIPS_stride_byte, 0x200c) \
X(DW_AT_TI_asm, 0x200c) \
X(DW_AT_MIPS_stride_elem, 0x200d) \
X(DW_AT_MIPS_ptr_dopetype, 0x200e) \
X(DW_AT_TI_skeletal, 0x200e) \
X(DW_AT_MIPS_allocatable_dopetype, 0x200f) \
X(DW_AT_MIPS_assumed_shape_dopetype, 0x2010) \
X(DW_AT_MIPS_assumed_size, 0x2011) \
X(DW_AT_TI_interrupt, 0x2011) \
X(DW_AT_HP_unmodifiable, 0x2001) \
X(DW_AT_HP_prologue, 0x2005) \
X(DW_AT_HP_epilogue, 0x2008) \
Expand Down Expand Up @@ -355,6 +367,7 @@ enum { DW_ADDR_DEFINITIONS };
X(DW_AT_APPLE_property, 0x3fed) \
X(DW_AT_APPLE_objc_direct, 0x3fee) \
X(DW_AT_APPLE_sdk, 0x3fef) \
X(DW_AT_APPLE_origin, 0x3ff0) \
X(DW_AT_hi_user, 0x3fff)
enum { DW_AT_DEFINITIONS };

Expand Down Expand Up @@ -407,8 +420,8 @@ enum { DW_ATE_DEFINITIONS };
X(DW_CC_nocall, 0x3) \
X(DW_CC_pass_by_reference, 0x4) \
X(DW_CC_pass_by_value, 0x5) \
X(DW_CC_lo_user, 0x40) \
X(DW_CC_GNU_renesas_sh, 0x40) \
X(DW_CC_lo_user, 0x40) \
X(DW_CC_GNU_borland_fastcall_i386, 0x41) \
X(DW_CC_ALTIUM_interrupt, 0x65) \
X(DW_CC_ALTIUM_near_system_stack, 0x66) \
Expand Down Expand Up @@ -464,8 +477,10 @@ enum { DW_CC_DEFINITIONS };
X(DW_CFA_val_offset, 0x14) \
X(DW_CFA_val_offset_sf, 0x15) \
X(DW_CFA_val_expression, 0x16) \
X(DW_CFA_TI_soffset_extended, 0x1c) \
X(DW_CFA_lo_user, 0x1c) \
X(DW_CFA_MIPS_advance_loc8, 0x1d) \
X(DW_CFA_TI_def_cfa_soffset, 0x1d) \
X(DW_CFA_GNU_window_save, 0x2d) \
X(DW_CFA_AARCH64_negate_ra_state, 0x2d) \
X(DW_CFA_GNU_args_size, 0x2e) \
Expand Down Expand Up @@ -595,6 +610,9 @@ enum { DW_ID_DEFINITIONS };
X(DW_IDX_GNU_internal, 0x2000) \
X(DW_IDX_lo_user, 0x2000) \
X(DW_IDX_GNU_external, 0x2001) \
X(DW_IDX_GNU_main, 0x2002) \
X(DW_IDX_GNU_language, 0x2003) \
X(DW_IDX_GNU_linkage_name, 0x2004) \
X(DW_IDX_hi_user, 0x3fff)
enum { DW_IDX_DEFINITIONS };

Expand Down Expand Up @@ -656,6 +674,15 @@ enum { DW_INL_DEFINITIONS };
X(DW_LANG_Assembly, 0x31) \
X(DW_LANG_C_sharp, 0x32) \
X(DW_LANG_Mojo, 0x33) \
X(DW_LANG_GLSL, 0x34) \
X(DW_LANG_GLSL_ES, 0x35) \
X(DW_LANG_HLSL, 0x36) \
X(DW_LANG_OpenCL_CPP, 0x37) \
X(DW_LANG_CPP_for_OpenCL, 0x38) \
X(DW_LANG_SYCL, 0x39) \
X(DW_LANG_Ruby, 0x40) \
X(DW_LANG_Move, 0x41) \
X(DW_LANG_Hylo, 0x42) \
X(DW_LANG_lo_user, 0x8000) \
X(DW_LANG_Mips_Assembler, 0x8001) \
X(DW_LANG_Upc, 0x8765) \
Expand Down Expand Up @@ -1070,8 +1097,14 @@ enum { DW_SECT_DEFINITIONS };
X(DW_TAG_call_site_parameter, 0x49) \
X(DW_TAG_skeleton_unit, 0x4a) \
X(DW_TAG_immutable_type, 0x4b) \
X(DW_TAG_TI_far_type, 0x4080) \
X(DW_TAG_lo_user, 0x4080) \
X(DW_TAG_MIPS_loop, 0x4081) \
X(DW_TAG_TI_near_type, 0x4081) \
X(DW_TAG_TI_assign_register, 0x4082) \
X(DW_TAG_TI_ioport_type, 0x4083) \
X(DW_TAG_TI_restrict_type, 0x4084) \
X(DW_TAG_TI_onchip_type, 0x4085) \
X(DW_TAG_HP_array_descriptor, 0x4090) \
X(DW_TAG_format_label, 0x4101) \
X(DW_TAG_function_template, 0x4102) \
Expand Down
9 changes: 3 additions & 6 deletions libdrgn/language_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,11 +1530,6 @@ c_format_object_impl(const struct drgn_object *obj, size_t indent,
struct drgn_error *err;
struct drgn_type *underlying_type = drgn_underlying_type(obj->type);

if (drgn_type_kind(underlying_type) == DRGN_TYPE_VOID) {
return drgn_error_create(DRGN_ERROR_TYPE,
"cannot format void object");
}

/*
* Pointers are special because they can have an asterisk prefix if
* we're dereferencing them.
Expand Down Expand Up @@ -1570,6 +1565,9 @@ c_format_object_impl(const struct drgn_object *obj, size_t indent,
}

SWITCH_ENUM(drgn_type_kind(underlying_type),
case DRGN_TYPE_VOID:
return drgn_error_create(DRGN_ERROR_TYPE,
"cannot format void object");
case DRGN_TYPE_INT:
case DRGN_TYPE_BOOL:
return c_format_int_object(obj, flags, sb);
Expand All @@ -1589,7 +1587,6 @@ c_format_object_impl(const struct drgn_object *obj, size_t indent,
multi_line_columns, flags, sb);
case DRGN_TYPE_FUNCTION:
return c_format_function_object(obj, sb);
case DRGN_TYPE_VOID:
case DRGN_TYPE_TYPEDEF:
case DRGN_TYPE_POINTER:
)
Expand Down
2 changes: 1 addition & 1 deletion libdrgn/python/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ static DrgnObject *DrgnObject_from_bytes(PyTypeObject *type, PyObject *args,
Py_buffer bytes;
struct index_arg bit_offset = {};
struct index_arg bit_field_size = { .allow_none = true, .is_none = true };
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!Oy*|O&O&:from_bytes_",
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!Oy*|$O&O&:from_bytes_",
keywords, &Program_type, &prog,
&type_obj, &bytes, index_converter,
&bit_offset, index_converter,
Expand Down
11 changes: 0 additions & 11 deletions scripts/gen_dwarf_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def gen_tests_dwarf_py(dwarf_constants: Sequence[DwarfConstantType], f: TextIO)
# Generated by scripts/gen_dwarf_constants.py.
import enum
from typing import Text
"""
)
for constant_type in dwarf_constants:
Expand All @@ -246,16 +245,6 @@ def gen_tests_dwarf_py(dwarf_constants: Sequence[DwarfConstantType], f: TextIO)
if name == "name":
f.write(" # type: ignore")
f.write("\n")
f.write(
f"""
@classmethod
def str(cls, value: int) -> Text:
try:
return f"{constant_type.name}_{{cls(value).name}}"
except ValueError:
return hex(value)
"""
)


def main() -> None:
Expand Down
11 changes: 0 additions & 11 deletions scripts/gen_tests_elf_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def main() -> None:
# Generated by scripts/gen_tests_elf_py.py.
import enum
from typing import Text
"""
)
for type_name, constants in enums.items():
Expand All @@ -62,16 +61,6 @@ def main() -> None:
f.write(f"\n\nclass {type_name}(enum.{enum_class}):\n")
for name, value in constants:
f.write(f" {name} = 0x{value:X}\n")
f.write(
f"""
@classmethod
def str(cls, value: int) -> Text:
try:
return f"{type_name}_{{cls(value).name}}"
except ValueError:
return hex(value)
"""
)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 22b3907

Please sign in to comment.