XS-libdwarf

 view release on metacpan or  search on metacpan

libdwarf-code-0.11.1/src/lib/libdwarf/dwarf_die_deliv.c  view on Meta::CPAN

dwarf_die_abbrev_global_offset(Dwarf_Die die,
    Dwarf_Off       * abbrev_goffset,
    Dwarf_Unsigned  * abbrev_count,
    Dwarf_Error*      error)
{
    Dwarf_Abbrev_List dal = 0;
    Dwarf_Debug dbg = 0;

    CHECK_DIE(die, DW_DLV_ERROR);
    dbg = die->di_cu_context->cc_dbg;
    dal = die->di_abbrev_list;
    if (!dal) {
        _dwarf_error(dbg,error,DW_DLE_DWARF_ABBREV_NULL);
        return DW_DLV_ERROR;
    }
    *abbrev_goffset = dal->abl_goffset;
    *abbrev_count = dal->abl_abbrev_count;
    return DW_DLV_OK;
}

/*  New August 2018.
    Because some real compressed sections
    have .zdebug instead
    of .debug as the leading characters.
    actual_sec_name_out points to a static
    string so so not free it. */
int
dwarf_get_real_section_name(Dwarf_Debug dbg,
    const char  *std_section_name,
    const char **actual_sec_name_out,
    Dwarf_Small *marked_zcompressed, /* zdebug */
    Dwarf_Small *marked_zlib_compressed, /* ZLIB string */
    Dwarf_Small *marked_shf_compressed, /* SHF_COMPRESSED */
    Dwarf_Unsigned *compressed_length,
    Dwarf_Unsigned *uncompressed_length,
    Dwarf_Error *error)
{
    unsigned i = 0;
    char tbuf[100] = {0};
    size_t std_sec_name_len = 0;

    CHECK_DBG(dbg,error,"dwarf_get_real_section_name()");
    if (!std_section_name || 0 == std_section_name[0]) {
        _dwarf_error_string(dbg,error,DW_DLE_SECTION_NAME_BIG,
            "DW_DLE_SECTION_NAME_BIG: Actually the "
            "section name is empty, not big.");
        return DW_DLV_ERROR;
    }
    std_sec_name_len = strlen(std_section_name);
    /*  std_section_name never has the .dwo on the end,
        so allow for that and allow one (arbitrarily) more. */
    if ((std_sec_name_len + 5) < sizeof(tbuf)) {
        _dwarf_safe_strcpy(tbuf,sizeof(tbuf),
            std_section_name,std_sec_name_len);
        _dwarf_safe_strcpy(tbuf+std_sec_name_len,
            sizeof(tbuf)-std_sec_name_len,
            ".dwo",4);
    }
    for (i=0; i < dbg->de_debug_sections_total_entries; i++) {
        struct Dwarf_dbg_sect_s *sdata = &dbg->de_debug_sections[i];
        struct Dwarf_Section_s *section = sdata->ds_secdata;
        const char *std = section->dss_standard_name;

        if (!strcmp(std,std_section_name) ||
            !strcmp(std,tbuf)) {
            const char *used = section->dss_name;
            *actual_sec_name_out = used;
            if (sdata->ds_have_zdebug) {
                *marked_zcompressed = TRUE;
            }
            if (section->dss_ZLIB_compressed) {
                *marked_zlib_compressed = TRUE;
                if (uncompressed_length) {
                    *uncompressed_length =
                        section->dss_uncompressed_length;
                }
                if (compressed_length) {
                    *compressed_length =
                        section->dss_compressed_length;
                }
            }
            if (section->dss_shf_compressed) {
                *marked_shf_compressed = TRUE;
                if (uncompressed_length) {
                    *uncompressed_length =
                        section->dss_uncompressed_length;
                }
                if (compressed_length) {
                    *compressed_length =
                        section->dss_compressed_length;
                }
            }
            return DW_DLV_OK;
        }
    }
    return DW_DLV_NO_ENTRY;
}
/*  This is useful when printing DIE data.
    The string pointer returned must not be freed.
    With non-elf objects it is possible the
    string returned might be empty or NULL,
    so callers should be prepared for that kind
    of return. */
int
dwarf_get_die_section_name(Dwarf_Debug dbg,
    Dwarf_Bool    is_info,
    const char ** sec_name,
    Dwarf_Error * error)
{
    struct Dwarf_Section_s *sec = 0;

    CHECK_DBG(dbg,error,"dwarf_get_die_section_name()");
    if (is_info) {
        sec = &dbg->de_debug_info;
    } else {
        sec = &dbg->de_debug_types;
    }
    if (sec->dss_size == 0) {
        /* We don't have such a  section at all. */
        return DW_DLV_NO_ENTRY;
    }



( run in 1.626 second using v1.01-cache-2.11-cpan-39bf76dae61 )