Debian Codegraph @

src/bin/dwarfdump/print_sections.c

raw
1 /*
2 Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
3 Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
4 Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved.
5 Portions Copyright 2008-2011 David Anderson. All rights reserved.
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of version 2 of the GNU General
9 Public License as published by the Free Software Foundation.
10
11 This program is distributed in the hope that it would be
12 useful, but WITHOUT ANY WARRANTY; without even the implied
13 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE.
15
16 Further, this software is distributed without any warranty
17 that it is free of the rightful claim of any third person
18 regarding infringement or the like. Any license provided
19 herein, whether implied or otherwise, applies only to this
20 software file. Patent licenses, if any, provided herein
21 do not apply to combinations of this program with other
22 software, or any other product whatsoever.
23
24 You should have received a copy of the GNU General Public
25 License along with this program; if not, write the Free
26 Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
27 Boston MA 02110-1301, USA.
28
29 */
30
31 #include <config.h>
32 #include <stdio.h> /* FILE decl for dd_esb.h, printf etc */
33
34 #include "dwarf.h"
35 #include "libdwarf.h"
36 #include "dd_defined_types.h"
37 #include "dd_checkutil.h"
38 #include "dd_glflags.h"
39 #include "dd_globals.h"
40 #include "dd_naming.h"
41 #include "dd_esb.h"
42 #include "print_sections.h"
43 #include "print_frames.h"
44
45 int dwarf_names_print_on_error = 1;
46
47 /* The April 2005 dwarf_get_section_max_offsets()
48 in libdwarf returns all max-offsets, but we only
49 want one of those offsets. This function returns
50 the one we want from that set,
51 making functions needing this offset as readable as possible.
52 (avoiding code duplication).
53 In case of error or missing section it returns a zero
54 size, which seems appropriate.
55 */
56 Dwarf_Unsigned
57 get_info_max_offset(Dwarf_Debug dbg)
58 {
59 Dwarf_Unsigned debug_info_size = 0;
60 int res = 0;
61
62 res = dwarf_get_section_max_offsets_d(dbg,
63 &debug_info_size,0,0,0,0, 0,0,0,0,0,
64 0,0,0,0,0, 0,0,0,0,0);
65 if (res != DW_DLV_OK) {
66 return 0;
67 }
68 return debug_info_size;
69 }
70
71 /* Dumping a dwarf-expression as a byte stream. */
72 void
73 dump_block(char *prefix, char *data, Dwarf_Signed len)
74 {
75 char *end_data = data + len;
76 char *cur = data;
77 int i = 0;
78
79 printf("%s", prefix);
80 for (; cur < end_data; ++cur, ++i) {
81 if (i > 0 && i % 4 == 0)
82 printf(" ");
83 printf("%02x", 0xff & *cur);
84
85 }
86 }