Debian Codegraph @

src/lib/libdwarfp/dwarf_pro_finish.c

raw
1 /*
2 Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
3 Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
4 Portions Copyright 2011-2020 David Anderson. All rights reserved.
5
6 This program is free software; you can redistribute it
7 and/or modify it under the terms of version 2.1 of the
8 GNU Lesser General Public License as published by the Free
9 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 Lesser General
25 Public License along with this program; if not, write the
26 Free Software Foundation, Inc., 51 Franklin Street - Fifth
27 Floor, Boston MA 02110-1301, USA.
28
29 */
30
31 #include <config.h>
32
33 #include <stdlib.h> /* free() */
34
35 #include "dwarf.h"
36 #include "libdwarf.h"
37 #include "dwarf_base_types.h"
38 #include "libdwarfp.h"
39 #include "dwarf_pro_incl.h"
40 #include "dwarf_pro_opaque.h"
41 #include "dwarf_pro_error.h"
42 #include "dwarf_pro_alloc.h"
43
44 /* This routine deallocates all memory, and does some
45 finishing up. New September 2016. */
46 int
47 dwarf_producer_finish_a(Dwarf_P_Debug dbg, Dwarf_Error * error)
48 {
49 if (dbg->de_version_magic_number != PRO_VERSION_MAGIC) {
50 DWARF_P_DBG_ERROR(dbg, DW_DLE_IA, DW_DLV_ERROR);
51 }
52
53 /* this frees all blocks, then frees dbg. */
54 free(dbg->de_debug_sup.ds_filename);
55 dbg->de_debug_sup.ds_filename = 0;
56 dbg->de_debug_sup.ds_version = 0;
57 free(dbg->de_debug_sup.ds_checksum);
58 dbg->de_debug_sup.ds_checksum = 0;
59 dbg->de_debug_sup.ds_checksum_len = 0;
60 _dwarf_p_dealloc_all(dbg);
61 return DW_DLV_OK ;
62 }
63
64 /* FIXME: Add stats for debug_line_str. */
65 int
66 dwarf_pro_get_string_stats(Dwarf_P_Debug dbg,
67 Dwarf_Unsigned * str_count,
68 Dwarf_Unsigned * str_total_length,
69 Dwarf_Unsigned * strp_count_debug_str,
70 Dwarf_Unsigned * strp_len_debug_str,
71 Dwarf_Unsigned * strp_reused_count,
72 Dwarf_Unsigned * strp_reused_len,
73 Dwarf_Error * error)
74 {
75 struct Dwarf_P_Str_stats_s* ps = 0;
76 if (!dbg) {
77 _dwarf_p_error(dbg, error, DW_DLE_IA);
78 return DW_DLV_ERROR;
79 }
80 if (dbg->de_version_magic_number !=PRO_VERSION_MAGIC ) {
81 _dwarf_p_error(dbg, error, DW_DLE_VMM);
82 return DW_DLV_ERROR;
83 }
84 *str_count = dbg->de_stats.ps_str_count;
85 *str_total_length = dbg->de_stats.ps_str_total_length;
86 ps = &dbg->de_stats.ps_strp;
87 *strp_count_debug_str = ps->ps_strp_count_debug_str;
88 *strp_len_debug_str = ps->ps_strp_len_debug_str;
89 *strp_reused_count = ps->ps_strp_reused_count;
90 *strp_reused_len = ps->ps_strp_reused_len;
91 return DW_DLV_OK;
92 }