1 /* DWARF 2 debugging format support for GDB.
3 Copyright (C) 1994-2020 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "dwarf2/line-header.h"
22 #include "dwarf2/read.h"
23 #include "complaints.h"
24 #include "filenames.h"
27 line_header::add_include_dir (const char *include_dir
)
29 if (dwarf_line_debug
>= 2)
33 new_size
= m_include_dirs
.size ();
35 new_size
= m_include_dirs
.size () + 1;
36 fprintf_unfiltered (gdb_stdlog
, "Adding dir %zu: %s\n",
37 new_size
, include_dir
);
39 m_include_dirs
.push_back (include_dir
);
43 line_header::add_file_name (const char *name
,
45 unsigned int mod_time
,
48 if (dwarf_line_debug
>= 2)
52 new_size
= file_names_size ();
54 new_size
= file_names_size () + 1;
55 fprintf_unfiltered (gdb_stdlog
, "Adding file %zu: %s\n",
58 m_file_names
.emplace_back (name
, d_index
, mod_time
, length
);
61 gdb::unique_xmalloc_ptr
<char>
62 line_header::file_file_name (int file
)
64 /* Is the file number a valid index into the line header's file name
65 table? Remember that file numbers start with one, not zero. */
66 if (is_valid_file_index (file
))
68 const file_entry
*fe
= file_name_at (file
);
70 if (!IS_ABSOLUTE_PATH (fe
->name
))
72 const char *dir
= fe
->include_dir (this);
74 return gdb::unique_xmalloc_ptr
<char> (concat (dir
, SLASH_STRING
,
78 return make_unique_xstrdup (fe
->name
);
82 /* The compiler produced a bogus file number. We can at least
83 record the macro definitions made in the file, even if we
84 won't be able to find the file by name. */
87 xsnprintf (fake_name
, sizeof (fake_name
),
88 "<bad macro file number %d>", file
);
90 complaint (_("bad file number in macro information (%d)"),
93 return make_unique_xstrdup (fake_name
);
97 gdb::unique_xmalloc_ptr
<char>
98 line_header::file_full_name (int file
, const char *comp_dir
)
100 /* Is the file number a valid index into the line header's file name
101 table? Remember that file numbers start with one, not zero. */
102 if (is_valid_file_index (file
))
104 gdb::unique_xmalloc_ptr
<char> relative
= file_file_name (file
);
106 if (IS_ABSOLUTE_PATH (relative
.get ()) || comp_dir
== NULL
)
108 return gdb::unique_xmalloc_ptr
<char> (concat (comp_dir
, SLASH_STRING
,
113 return file_file_name (file
);
This page took 0.031804 seconds and 4 git commands to generate.