Blame dwarfdump/print_static_vars.c

Packit cdaae3
/*
Packit cdaae3
    Copyright (C) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
Packit cdaae3
    Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
Packit cdaae3
    Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved.
Packit cdaae3
    Portions Copyright 2008-2011 David Anderson. All rights reserved.
Packit cdaae3
Packit cdaae3
    This program is free software; you can redistribute it and/or modify it
Packit cdaae3
    under the terms of version 2 of the GNU General Public License as
Packit cdaae3
    published by the Free Software Foundation.
Packit cdaae3
Packit cdaae3
    This program is distributed in the hope that it would be useful, but
Packit cdaae3
    WITHOUT ANY WARRANTY; without even the implied warranty of
Packit cdaae3
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit cdaae3
Packit cdaae3
    Further, this software is distributed without any warranty that it is
Packit cdaae3
    free of the rightful claim of any third person regarding infringement
Packit cdaae3
    or the like.  Any license provided herein, whether implied or
Packit cdaae3
    otherwise, applies only to this software file.  Patent licenses, if
Packit cdaae3
    any, provided herein do not apply to combinations of this program with
Packit cdaae3
    other software, or any other product whatsoever.
Packit cdaae3
Packit cdaae3
    You should have received a copy of the GNU General Public License along
Packit cdaae3
    with this program; if not, write the Free Software Foundation, Inc., 51
Packit cdaae3
    Franklin Street - Fifth Floor, Boston MA 02110-1301, USA.
Packit cdaae3
Packit cdaae3
*/
Packit cdaae3
Packit cdaae3
#include "globals.h"
Packit cdaae3
#include "naming.h"
Packit cdaae3
#include "dwconf.h"
Packit cdaae3
#include "esb.h"
Packit cdaae3
Packit cdaae3
#include "print_sections.h"
Packit cdaae3
#include "print_frames.h"
Packit cdaae3
Packit cdaae3
/* Get all the data in .debug_static_vars */
Packit cdaae3
extern void
Packit cdaae3
print_static_vars(Dwarf_Debug dbg)
Packit cdaae3
{
Packit cdaae3
    Dwarf_Var *varbuf = NULL;
Packit cdaae3
    Dwarf_Signed count = 0;
Packit cdaae3
    Dwarf_Signed i = 0;
Packit cdaae3
    Dwarf_Off die_off = 0;
Packit cdaae3
    Dwarf_Off cu_off = 0;
Packit cdaae3
    char *name = 0;
Packit cdaae3
    int gvres = 0;
Packit cdaae3
    Dwarf_Error err = 0;
Packit cdaae3
Packit cdaae3
    current_section_id = DEBUG_STATIC_VARS;
Packit cdaae3
Packit cdaae3
    if (!glflags.gf_do_print_dwarf) {
Packit cdaae3
        return;
Packit cdaae3
    }
Packit cdaae3
    /*  No need to get the real section name, this
Packit cdaae3
        section not used in modern compilers. */
Packit cdaae3
    printf("\n.debug_static_vars\n");
Packit cdaae3
    gvres = dwarf_get_vars(dbg, &varbuf, &count, &err;;
Packit cdaae3
    if (gvres == DW_DLV_ERROR) {
Packit cdaae3
        print_error(dbg, "dwarf_get_vars", gvres, err);
Packit cdaae3
    } else if (gvres == DW_DLV_NO_ENTRY) {
Packit cdaae3
        /* no static vars */
Packit cdaae3
    } else {
Packit cdaae3
        Dwarf_Unsigned maxoff = get_info_max_offset(dbg);
Packit cdaae3
Packit cdaae3
        for (i = 0; i < count; i++) {
Packit cdaae3
            int vnres = 0;
Packit cdaae3
            int cures3 = 0;
Packit cdaae3
            Dwarf_Off global_cu_off = 0;
Packit cdaae3
Packit cdaae3
            vnres = dwarf_var_name_offsets(varbuf[i], &name, &die_off,
Packit cdaae3
                &cu_off, &err;;
Packit cdaae3
            deal_with_name_offset_err(dbg,
Packit cdaae3
                "dwarf_var_name_offsets",
Packit cdaae3
                name, die_off, vnres, err);
Packit cdaae3
            cures3 = dwarf_var_cu_offset(varbuf[i],
Packit cdaae3
                &global_cu_off, &err;;
Packit cdaae3
            if (cures3 != DW_DLV_OK) {
Packit cdaae3
                print_error(dbg, "dwarf_global_cu_offset", cures3, err);
Packit cdaae3
            }
Packit cdaae3
Packit cdaae3
            print_pubname_style_entry(dbg,
Packit cdaae3
                "static-var",
Packit cdaae3
                name, die_off, cu_off,
Packit cdaae3
                global_cu_off, maxoff);
Packit cdaae3
Packit cdaae3
            /* print associated die too? */
Packit cdaae3
        }
Packit cdaae3
        dwarf_vars_dealloc(dbg, varbuf, count);
Packit cdaae3
    }
Packit cdaae3
}                               /* print_static_vars */
Packit cdaae3