From c24b900cc9cf225e98372253cb02c77342634b6e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 21 Jul 2017 21:23:07 +0200 Subject: libdw: Add dwarf_line_file. Signed-off-by: Mark Wielaard --- libdw/libdw.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libdw/libdw.h') diff --git a/libdw/libdw.h b/libdw/libdw.h index 9ae80ebb..4903b55f 100644 --- a/libdw/libdw.h +++ b/libdw/libdw.h @@ -640,6 +640,11 @@ extern const char *dwarf_linesrc (Dwarf_Line *line, extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx, Dwarf_Word *mtime, Dwarf_Word *length); +/* Return the Dwarf_Files and index associated with the given Dwarf_Line. */ +extern int dwarf_line_file (Dwarf_Line *line, + Dwarf_Files **files, size_t *idx) + __nonnull_attribute__ (2, 3); + /* Return the directory list used in the file information extracted. (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null. (*RESULT)[0..*NDIRS-1] are the compile-time include directory path -- cgit v1.2.3 From 2eb1e3485614f5a4d3cbe8f28efd0d0de980911f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 26 Jul 2017 18:06:21 +0200 Subject: libdw: Add dwarf_default_lower_bound. Add dwarf_default_lower_bound to get the default lower bound for a language when not given as attribute for an subrange type. Implementation extracted from dwarf_aggregate_size. Add a test to check all known language codes are handled. Signed-off-by: Mark Wielaard --- libdw/libdw.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libdw/libdw.h') diff --git a/libdw/libdw.h b/libdw/libdw.h index 4903b55f..49c4ebb9 100644 --- a/libdw/libdw.h +++ b/libdw/libdw.h @@ -733,6 +733,12 @@ extern int dwarf_getlocation_attr (Dwarf_Attribute *attr, For DW_TAG_array_type it can apply much more complex rules. */ extern int dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size); +/* Given a language code, as returned by dwarf_srclan, get the default + lower bound for a subrange type without a lower bound attribute. + Returns zero on success or -1 on failure when the given language + wasn't recognized. */ +extern int dwarf_default_lower_bound (int lang, Dwarf_Sword *result) + __nonnull_attribute__ (2); /* Return scope DIEs containing PC address. Sets *SCOPES to a malloc'd array of Dwarf_Die structures, -- cgit v1.2.3 From 274f28ce24955b2e6a17e9ff2eb0c7c2e5751f97 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 26 Jul 2017 22:54:59 +0200 Subject: libdw: Handle DWARF5 immutable, packed and shared in dwarf_peel_type. Also update the documentation to explain that any type alias or modifier that doesn't modify, change the structural layout or the way to access the underlying type is peeled. Explicitly mention pointer and reference types as examples of modifiers that don't obey that rule and so aren't peeled. Signed-off-by: Mark Wielaard --- libdw/libdw.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'libdw/libdw.h') diff --git a/libdw/libdw.h b/libdw/libdw.h index 49c4ebb9..63a38ff9 100644 --- a/libdw/libdw.h +++ b/libdw/libdw.h @@ -1,5 +1,5 @@ /* Interfaces for libdw. - Copyright (C) 2002-2010, 2013, 2014 Red Hat, Inc. + Copyright (C) 2002-2010, 2013, 2014, 2016 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -378,8 +378,11 @@ extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result) extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result) __nonnull_attribute__ (2); -/* For type aliases and qualifier type DIEs follow the DW_AT_type - attribute (recursively) and return the underlying type Dwarf_Die. +/* For type aliases and qualifier type DIEs, which don't modify or + change the structural layout of the underlying type, follow the + DW_AT_type attribute (recursively) and return the underlying type + Dwarf_Die. + Returns 0 when RESULT contains a Dwarf_Die (possibly equal to the given DIE) that isn't a type alias or qualifier type. Returns 1 when RESULT contains a type alias or qualifier Dwarf_Die that @@ -387,13 +390,18 @@ extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result) attribute). Returns -1 when an error occured. The current DWARF specification defines one type alias tag - (DW_TAG_typedef) and three qualifier type tags (DW_TAG_const_type, - DW_TAG_volatile_type, DW_TAG_restrict_type). DWARF5 defines one - other qualifier type tag (DW_TAG_atomic_type). A future version of - this function might peel other alias or qualifier type tags if a - future DWARF version or GNU extension defines other type aliases or - qualifier type tags that don't modify or change the structural - layout of the underlying type. */ + (DW_TAG_typedef) and seven modifier/qualifier type tags + (DW_TAG_const_type, DW_TAG_volatile_type, DW_TAG_restrict_type, + DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_packed_type and + DW_TAG_shared_type). This function won't peel modifier type + tags that change the way the underlying type is accessed such + as the pointer or reference type tags (DW_TAG_pointer_type, + DW_TAG_reference_type or DW_TAG_rvalue_reference_type). + + A future version of this function might peel other alias or + qualifier type tags if a future DWARF version or GNU extension + defines other type aliases or qualifier type tags that don't modify, + change the structural layout or the way to access the underlying type. */ extern int dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result) __nonnull_attribute__ (2); -- cgit v1.2.3