]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-gcc3.1-jelinek.patch
- converted to UTF-8
[packages/gdb.git] / gdb-gcc3.1-jelinek.patch
CommitLineData
68eb7483
AM
1--- gdb-5.0.93/gdb/dwarf2read.c.dwarfpatch Thu Jul 5 12:45:48 2001
2+++ gdb-5.0.93/gdb/dwarf2read.c Mon Nov 12 14:43:15 2001
3@@ -43,6 +43,7 @@
4 #include "bcache.h"
5 #include <fcntl.h>
6 #include "gdb_string.h"
7+#include "gdb_assert.h"
8 #include <sys/types.h>
9
10 #ifndef DWARF2_REG_TO_REGNUM
11@@ -302,6 +303,7 @@
12 static char *dwarf_info_buffer;
13 static char *dwarf_abbrev_buffer;
14 static char *dwarf_line_buffer;
15+static char *dwarf_str_buffer;
16
17 /* A zeroed version of a partial die for initialization purposes. */
18 static struct partial_die_info zeroed_partial_die;
19@@ -383,6 +385,14 @@
20 /* Pointer to start of dwarf line buffer for the objfile. */
21
22 char *dwarf_line_buffer;
23+
24+ /* Pointer to start of dwarf string buffer for the objfile. */
25+
26+ char *dwarf_str_buffer;
27+
28+ /* Size of dwarf string section for the objfile. */
29+
30+ unsigned int dwarf_str_size;
31 };
32
33 #define PST_PRIVATE(p) ((struct dwarf2_pinfo *)(p)->read_symtab_private)
34@@ -391,6 +401,8 @@
35 #define DWARF_ABBREV_BUFFER(p) (PST_PRIVATE(p)->dwarf_abbrev_buffer)
36 #define DWARF_ABBREV_SIZE(p) (PST_PRIVATE(p)->dwarf_abbrev_size)
37 #define DWARF_LINE_BUFFER(p) (PST_PRIVATE(p)->dwarf_line_buffer)
38+#define DWARF_STR_BUFFER(p) (PST_PRIVATE(p)->dwarf_str_buffer)
39+#define DWARF_STR_SIZE(p) (PST_PRIVATE(p)->dwarf_str_size)
40
41 /* Maintain an array of referenced fundamental types for the current
42 compilation unit being read. For DWARF version 1, we have to construct
43@@ -619,6 +631,9 @@
44
45 static char *read_string (bfd *, char *, unsigned int *);
46
47+static char *read_indirect_string (bfd *, char *, const struct comp_unit_head *,
48+ unsigned int *);
49+
50 static unsigned long read_unsigned_leb128 (bfd *, char *, unsigned int *);
51
52 static long read_signed_leb128 (bfd *, char *, unsigned int *);
53@@ -791,6 +806,7 @@
54 dwarf2_has_info (bfd *abfd)
55 {
56 dwarf_info_offset = dwarf_abbrev_offset = dwarf_line_offset = 0;
57+ dwarf_str_offset = 0;
58 bfd_map_over_sections (abfd, dwarf2_locate_sections, NULL);
59 if (dwarf_info_offset && dwarf_abbrev_offset)
60 {
61@@ -869,6 +885,13 @@
62 dwarf_line_offset,
63 dwarf_line_size);
64
65+ if (dwarf_str_offset)
66+ dwarf_str_buffer = dwarf2_read_section (objfile,
67+ dwarf_str_offset,
68+ dwarf_str_size);
69+ else
70+ dwarf_str_buffer = NULL;
71+
72 if (mainline || objfile->global_psymbols.size == 0 ||
73 objfile->static_psymbols.size == 0)
74 {
75@@ -1045,6 +1068,8 @@
76 DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer;
77 DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size;
78 DWARF_LINE_BUFFER (pst) = dwarf_line_buffer;
79+ DWARF_STR_BUFFER (pst) = dwarf_str_buffer;
80+ DWARF_STR_SIZE (pst) = dwarf_str_size;
81 baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
82
83 /* Store the function that reads in the rest of the symbol table */
84@@ -1344,6 +1369,8 @@
85 dwarf_abbrev_buffer = DWARF_ABBREV_BUFFER (pst);
86 dwarf_abbrev_size = DWARF_ABBREV_SIZE (pst);
87 dwarf_line_buffer = DWARF_LINE_BUFFER (pst);
88+ dwarf_str_buffer = DWARF_STR_BUFFER (pst);
89+ dwarf_str_size = DWARF_STR_SIZE (pst);
90 baseaddr = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile));
91 cu_header_offset = offset;
92 info_ptr = dwarf_info_buffer + offset;
93@@ -3358,6 +3385,11 @@
94 DW_STRING (attr) = read_string (abfd, info_ptr, &bytes_read);
95 info_ptr += bytes_read;
96 break;
97+ case DW_FORM_strp:
98+ DW_STRING (attr) = read_indirect_string (abfd, info_ptr, cu_header,
99+ &bytes_read);
100+ info_ptr += bytes_read;
101+ break;
102 case DW_FORM_block:
103 blk = dwarf_alloc_block ();
104 blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
105@@ -3410,7 +3442,6 @@
106 DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
107 info_ptr += bytes_read;
108 break;
109- case DW_FORM_strp:
110 case DW_FORM_indirect:
111 default:
112 error ("Dwarf Error: Cannot handle %s in DWARF reader.",
113@@ -3600,20 +3631,8 @@
114 /* If the size of a host char is 8 bits, we can return a pointer
115 to the buffer, otherwise we have to copy the data to a buffer
116 allocated on the temporary obstack. */
117-#if HOST_CHAR_BIT == 8
118+ gdb_assert (HOST_CHAR_BIT == 8);
119 return buf;
120-#else
121- char *ret;
122- unsigned int i;
123-
124- ret = obstack_alloc (&dwarf2_tmp_obstack, size);
125- for (i = 0; i < size; ++i)
126- {
127- ret[i] = bfd_get_8 (abfd, (bfd_byte *) buf);
128- buf++;
129- }
130- return ret;
131-#endif
132 }
133
134 static char *
135@@ -3622,7 +3641,7 @@
136 /* If the size of a host char is 8 bits, we can return a pointer
137 to the string, otherwise we have to copy the string to a buffer
138 allocated on the temporary obstack. */
139-#if HOST_CHAR_BIT == 8
140+ gdb_assert (HOST_CHAR_BIT == 8);
141 if (*buf == '\0')
142 {
143 *bytes_read_ptr = 1;
144@@ -3630,25 +3649,30 @@
145 }
146 *bytes_read_ptr = strlen (buf) + 1;
147 return buf;
148-#else
149- int byte;
150- unsigned int i = 0;
151+}
152+
153+static char *
154+read_indirect_string (bfd *abfd, char *buf,
155+ const struct comp_unit_head *cu_header,
156+ unsigned int *bytes_read_ptr)
157+{
158+ LONGEST str_offset = read_offset (abfd, buf, cu_header,
159+ (int *) bytes_read_ptr);
160
161- while ((byte = bfd_get_8 (abfd, (bfd_byte *) buf)) != 0)
162+ if (dwarf_str_buffer == NULL)
163 {
164- obstack_1grow (&dwarf2_tmp_obstack, byte);
165- i++;
166- buf++;
167+ error ("DW_FORM_strp used without .debug_str section");
168+ return NULL;
169 }
170- if (i == 0)
171+ if (str_offset >= dwarf_str_size)
172 {
173- *bytes_read_ptr = 1;
174+ error ("DW_FORM_strp pointing outside of .debug_str section");
175 return NULL;
176 }
177- obstack_1grow (&dwarf2_tmp_obstack, '\0');
178- *bytes_read_ptr = i + 1;
179- return obstack_finish (&dwarf2_tmp_obstack);
180-#endif
181+ gdb_assert (HOST_CHAR_BIT == 8);
182+ if (dwarf_str_buffer[str_offset] == '\0')
183+ return NULL;
184+ return dwarf_str_buffer + str_offset;
185 }
186
187 static unsigned long
188@@ -5552,6 +5576,7 @@
189 fprintf (stderr, "constant: %ld", DW_UNSND (&die->attrs[i]));
190 break;
191 case DW_FORM_string:
192+ case DW_FORM_strp:
193 fprintf (stderr, "string: \"%s\"",
194 DW_STRING (&die->attrs[i])
195 ? DW_STRING (&die->attrs[i]) : "");
196@@ -5562,8 +5587,6 @@
197 else
198 fprintf (stderr, "flag: FALSE");
199 break;
200- case DW_FORM_strp: /* we do not support separate string
201- section yet */
202 case DW_FORM_indirect: /* we do not handle indirect yet */
203 default:
204 fprintf (stderr, "unsupported attribute form: %d.",
This page took 0.050371 seconds and 4 git commands to generate.