]> git.ipfire.org Git - people/pmueller/ipfire-3.x.git/blame - gdb/patches/gdb-upstream.patch
gdb: Update to 7.3.50.20110722.
[people/pmueller/ipfire-3.x.git] / gdb / patches / gdb-upstream.patch
CommitLineData
5a03b7c3
MT
1http://sourceware.org/ml/binutils-cvs/2011-07/msg00116.html
2
3### src/include/ChangeLog 2011/07/22 14:37:50 1.546
4### src/include/ChangeLog 2011/07/22 20:37:50 1.547
5## -1,5 +1,8 @@
6 2011-07-22 Jakub Jelinek <jakub@redhat.com>
7
8+ * dwarf2.h (DW_AT_GNU_macros): New.
9+ (enum dwarf_macro_record_type): New enum. Add DW_MACRO_GNU_*.
10+
11 PR c++/49756
12 * libiberty.h (stack_limit_increase): New prototype.
13
14--- src/include/dwarf2.h 2011/06/22 15:03:19 1.26
15+++ src/include/dwarf2.h 2011/07/22 20:37:50 1.27
16@@ -366,6 +366,8 @@
17 DW_AT_GNU_all_tail_call_sites = 0x2116,
18 DW_AT_GNU_all_call_sites = 0x2117,
19 DW_AT_GNU_all_source_call_sites = 0x2118,
20+ /* Section offset into .debug_macro section. */
21+ DW_AT_GNU_macros = 0x2119,
22 /* VMS extensions. */
23 DW_AT_VMS_rtnbeg_pd_address = 0x2201,
24 /* GNAT extensions. */
25@@ -879,6 +881,20 @@
26 DW_MACINFO_end_file = 4,
27 DW_MACINFO_vendor_ext = 255
28 };
29+
30+/* Names and codes for new style macro information. */
31+enum dwarf_macro_record_type
32+ {
33+ DW_MACRO_GNU_define = 1,
34+ DW_MACRO_GNU_undef = 2,
35+ DW_MACRO_GNU_start_file = 3,
36+ DW_MACRO_GNU_end_file = 4,
37+ DW_MACRO_GNU_define_indirect = 5,
38+ DW_MACRO_GNU_undef_indirect = 6,
39+ DW_MACRO_GNU_transparent_include = 7,
40+ DW_MACRO_GNU_lo_user = 0xe0,
41+ DW_MACRO_GNU_hi_user = 0xff
42+ };
43 \f
44 /* @@@ For use with GNU frame unwind information. */
45
46
47
48
49FYI: implement new DWARF macro proposal
50http://sourceware.org/ml/gdb-patches/2011-07/msg00732.html
51http://sourceware.org/ml/gdb-cvs/2011-07/msg00212.html
52
53### src/gdb/ChangeLog 2011/07/26 15:24:01 1.13224
54### src/gdb/ChangeLog 2011/07/26 17:04:21 1.13225
55## -1,3 +1,20 @@
56+2011-07-26 Tom Tromey <tromey@redhat.com>
57+
58+ * symfile.h (struct dwarf2_debug_sections) <macro>: New field.
59+ * dwarf2read.c (read_indirect_string_at_offset): New function.
60+ (read_indirect_string): Use it.
61+ (dwarf_decode_macro_bytes): New function, taken from
62+ dwarf_decode_macros. Handle DW_MACRO_GNU_*.
63+ (dwarf_decode_macros): Use it. handle DW_MACRO_GNU_*.
64+ (dwarf_parse_macro_header, skip_form_bytes, skip_unknown_opcode):
65+ New functions.
66+ (struct dwarf2_per_objfile) <macro>: New field.
67+ (dwarf2_elf_names): Add .debug_macro.
68+ (dwarf2_macros_too_long_complaint): Add 'section' argument.
69+ (dwarf2_locate_sections): Handle new section.
70+ (read_file_scope): Handle DW_AT_GNU_macros.
71+ (dwarf2_per_objfile_free): Unmap the .debug_macro section.
72+
73 2011-07-26 Paul Pluzhnikov <ppluzhnikov@google.com>
74
75 * NEWS: Mention dcache configuration.
76--- src/gdb/dwarf2read.c 2011/07/20 15:13:49 1.554
77+++ src/gdb/dwarf2read.c 2011/07/26 17:04:23 1.555
78@@ -187,6 +187,7 @@
79 struct dwarf2_section_info line;
80 struct dwarf2_section_info loc;
81 struct dwarf2_section_info macinfo;
82+ struct dwarf2_section_info macro;
83 struct dwarf2_section_info str;
84 struct dwarf2_section_info ranges;
85 struct dwarf2_section_info frame;
86@@ -264,6 +265,7 @@
87 { ".debug_line", ".zdebug_line" },
88 { ".debug_loc", ".zdebug_loc" },
89 { ".debug_macinfo", ".zdebug_macinfo" },
90+ { ".debug_macro", ".zdebug_macro" },
91 { ".debug_str", ".zdebug_str" },
92 { ".debug_ranges", ".zdebug_ranges" },
93 { ".debug_types", ".zdebug_types" },
94@@ -858,10 +860,11 @@
95 }
96
97 static void
98-dwarf2_macros_too_long_complaint (void)
99+dwarf2_macros_too_long_complaint (struct dwarf2_section_info *section)
100 {
101 complaint (&symfile_complaints,
102- _("macro info runs off end of `.debug_macinfo' section"));
103+ _("macro info runs off end of `%s' section"),
104+ section->asection->name);
105 }
106
107 static void
108@@ -1233,7 +1236,9 @@
109 struct dwarf2_cu *);
110
111 static void dwarf_decode_macros (struct line_header *, unsigned int,
112- char *, bfd *, struct dwarf2_cu *);
113+ char *, bfd *, struct dwarf2_cu *,
114+ struct dwarf2_section_info *,
115+ int);
116
117 static int attr_form_is_block (struct attribute *);
118
119@@ -1438,6 +1443,11 @@
120 dwarf2_per_objfile->macinfo.asection = sectp;
121 dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp);
122 }
123+ else if (section_is_p (sectp->name, &names->macro))
124+ {
125+ dwarf2_per_objfile->macro.asection = sectp;
126+ dwarf2_per_objfile->macro.size = bfd_get_section_size (sectp);
127+ }
128 else if (section_is_p (sectp->name, &names->str))
129 {
130 dwarf2_per_objfile->str.asection = sectp;
131@@ -5641,13 +5651,28 @@
132 refers to information in the line number info statement program
133 header, so we can only read it if we've read the header
134 successfully. */
135- attr = dwarf2_attr (die, DW_AT_macro_info, cu);
136+ attr = dwarf2_attr (die, DW_AT_GNU_macros, cu);
137 if (attr && cu->line_header)
138 {
139- unsigned int macro_offset = DW_UNSND (attr);
140+ if (dwarf2_attr (die, DW_AT_macro_info, cu))
141+ complaint (&symfile_complaints,
142+ _("CU refers to both DW_AT_GNU_macros and DW_AT_macro_info"));
143+
144+ dwarf_decode_macros (cu->line_header, DW_UNSND (attr),
145+ comp_dir, abfd, cu,
146+ &dwarf2_per_objfile->macro, 1);
147+ }
148+ else
149+ {
150+ attr = dwarf2_attr (die, DW_AT_macro_info, cu);
151+ if (attr && cu->line_header)
152+ {
153+ unsigned int macro_offset = DW_UNSND (attr);
154
155- dwarf_decode_macros (cu->line_header, macro_offset,
156- comp_dir, abfd, cu);
157+ dwarf_decode_macros (cu->line_header, macro_offset,
158+ comp_dir, abfd, cu,
159+ &dwarf2_per_objfile->macinfo, 0);
160+ }
161 }
162 do_cleanups (back_to);
163 }
164@@ -10262,32 +10287,32 @@
165 }
166
167 static char *
168-read_indirect_string (bfd *abfd, gdb_byte *buf,
169- const struct comp_unit_head *cu_header,
170- unsigned int *bytes_read_ptr)
171+read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset)
172 {
173- LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
174-
175 dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->str);
176 if (dwarf2_per_objfile->str.buffer == NULL)
177- {
178- error (_("DW_FORM_strp used without .debug_str section [in module %s]"),
179- bfd_get_filename (abfd));
180- return NULL;
181- }
182+ error (_("DW_FORM_strp used without .debug_str section [in module %s]"),
183+ bfd_get_filename (abfd));
184 if (str_offset >= dwarf2_per_objfile->str.size)
185- {
186- error (_("DW_FORM_strp pointing outside of "
187- ".debug_str section [in module %s]"),
188- bfd_get_filename (abfd));
189- return NULL;
190- }
191+ error (_("DW_FORM_strp pointing outside of "
192+ ".debug_str section [in module %s]"),
193+ bfd_get_filename (abfd));
194 gdb_assert (HOST_CHAR_BIT == 8);
195 if (dwarf2_per_objfile->str.buffer[str_offset] == '\0')
196 return NULL;
197 return (char *) (dwarf2_per_objfile->str.buffer + str_offset);
198 }
199
200+static char *
201+read_indirect_string (bfd *abfd, gdb_byte *buf,
202+ const struct comp_unit_head *cu_header,
203+ unsigned int *bytes_read_ptr)
204+{
205+ LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
206+
207+ return read_indirect_string_at_offset (abfd, str_offset);
208+}
209+
210 static unsigned long
211 read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
212 {
213@@ -14669,117 +14694,205 @@
214 dwarf2_macro_malformed_definition_complaint (body);
215 }
216
217+/* Skip some bytes from BYTES according to the form given in FORM.
218+ Returns the new pointer. */
219
220-static void
221-dwarf_decode_macros (struct line_header *lh, unsigned int offset,
222- char *comp_dir, bfd *abfd,
223- struct dwarf2_cu *cu)
224+static gdb_byte *
225+skip_form_bytes (bfd *abfd, gdb_byte *bytes,
226+ enum dwarf_form form,
227+ unsigned int offset_size,
228+ struct dwarf2_section_info *section)
229 {
230- gdb_byte *mac_ptr, *mac_end;
231- struct macro_source_file *current_file = 0;
232- enum dwarf_macinfo_record_type macinfo_type;
233- int at_commandline;
234+ unsigned int bytes_read;
235
236- dwarf2_read_section (dwarf2_per_objfile->objfile,
237- &dwarf2_per_objfile->macinfo);
238- if (dwarf2_per_objfile->macinfo.buffer == NULL)
239+ switch (form)
240 {
241- complaint (&symfile_complaints, _("missing .debug_macinfo section"));
242- return;
243+ case DW_FORM_data1:
244+ case DW_FORM_flag:
245+ ++bytes;
246+ break;
247+
248+ case DW_FORM_data2:
249+ bytes += 2;
250+ break;
251+
252+ case DW_FORM_data4:
253+ bytes += 4;
254+ break;
255+
256+ case DW_FORM_data8:
257+ bytes += 8;
258+ break;
259+
260+ case DW_FORM_string:
261+ read_direct_string (abfd, bytes, &bytes_read);
262+ bytes += bytes_read;
263+ break;
264+
265+ case DW_FORM_sec_offset:
266+ case DW_FORM_strp:
267+ bytes += offset_size;
268+ break;
269+
270+ case DW_FORM_block:
271+ bytes += read_unsigned_leb128 (abfd, bytes, &bytes_read);
272+ bytes += bytes_read;
273+ break;
274+
275+ case DW_FORM_block1:
276+ bytes += 1 + read_1_byte (abfd, bytes);
277+ break;
278+ case DW_FORM_block2:
279+ bytes += 2 + read_2_bytes (abfd, bytes);
280+ break;
281+ case DW_FORM_block4:
282+ bytes += 4 + read_4_bytes (abfd, bytes);
283+ break;
284+
285+ case DW_FORM_sdata:
286+ case DW_FORM_udata:
287+ bytes = skip_leb128 (abfd, bytes);
288+ break;
289+
290+ default:
291+ {
292+ complain:
293+ complaint (&symfile_complaints,
294+ _("invalid form 0x%x in `%s'"),
295+ form,
296+ section->asection->name);
297+ return NULL;
298+ }
299 }
300
301- /* First pass: Find the name of the base filename.
302- This filename is needed in order to process all macros whose definition
303- (or undefinition) comes from the command line. These macros are defined
304- before the first DW_MACINFO_start_file entry, and yet still need to be
305- associated to the base file.
306+ return bytes;
307+}
308
309- To determine the base file name, we scan the macro definitions until we
310- reach the first DW_MACINFO_start_file entry. We then initialize
311- CURRENT_FILE accordingly so that any macro definition found before the
312- first DW_MACINFO_start_file can still be associated to the base file. */
313+/* A helper for dwarf_decode_macros that handles skipping an unknown
314+ opcode. Returns an updated pointer to the macro data buffer; or,
315+ on error, issues a complaint and returns NULL. */
316
317- mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset;
318- mac_end = dwarf2_per_objfile->macinfo.buffer
319- + dwarf2_per_objfile->macinfo.size;
320+static gdb_byte *
321+skip_unknown_opcode (unsigned int opcode,
322+ gdb_byte **opcode_definitions,
323+ gdb_byte *mac_ptr,
324+ bfd *abfd,
325+ unsigned int offset_size,
326+ struct dwarf2_section_info *section)
327+{
328+ unsigned int bytes_read, i;
329+ unsigned long arg;
330+ gdb_byte *defn;
331
332- do
333+ if (opcode_definitions[opcode] == NULL)
334 {
335- /* Do we at least have room for a macinfo type byte? */
336- if (mac_ptr >= mac_end)
337- {
338- /* Complaint is printed during the second pass as GDB will probably
339- stop the first pass earlier upon finding
340- DW_MACINFO_start_file. */
341- break;
342- }
343+ complaint (&symfile_complaints,
344+ _("unrecognized DW_MACFINO opcode 0x%x"),
345+ opcode);
346+ return NULL;
347+ }
348
349- macinfo_type = read_1_byte (abfd, mac_ptr);
350- mac_ptr++;
351+ defn = opcode_definitions[opcode];
352+ arg = read_unsigned_leb128 (abfd, defn, &bytes_read);
353+ defn += bytes_read;
354
355- switch (macinfo_type)
356- {
357- /* A zero macinfo type indicates the end of the macro
358- information. */
359- case 0:
360- break;
361+ for (i = 0; i < arg; ++i)
362+ {
363+ mac_ptr = skip_form_bytes (abfd, mac_ptr, defn[i], offset_size, section);
364+ if (mac_ptr == NULL)
365+ {
366+ /* skip_form_bytes already issued the complaint. */
367+ return NULL;
368+ }
369+ }
370
371- case DW_MACINFO_define:
372- case DW_MACINFO_undef:
373- /* Only skip the data by MAC_PTR. */
374- {
375- unsigned int bytes_read;
376+ return mac_ptr;
377+}
378
379- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
380- mac_ptr += bytes_read;
381- read_direct_string (abfd, mac_ptr, &bytes_read);
382- mac_ptr += bytes_read;
383- }
384- break;
385+/* A helper function which parses the header of a macro section.
386+ If the macro section is the extended (for now called "GNU") type,
387+ then this updates *OFFSET_SIZE. Returns a pointer to just after
388+ the header, or issues a complaint and returns NULL on error. */
389
390- case DW_MACINFO_start_file:
391- {
392- unsigned int bytes_read;
393- int line, file;
394+static gdb_byte *
395+dwarf_parse_macro_header (gdb_byte **opcode_definitions,
396+ bfd *abfd,
397+ gdb_byte *mac_ptr,
398+ unsigned int *offset_size,
399+ int section_is_gnu)
400+{
401+ memset (opcode_definitions, 0, 256 * sizeof (gdb_byte *));
402
403- line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
404- mac_ptr += bytes_read;
405- file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
406- mac_ptr += bytes_read;
407+ if (section_is_gnu)
408+ {
409+ unsigned int version, flags;
410
411- current_file = macro_start_file (file, line, current_file,
412- comp_dir, lh, cu->objfile);
413- }
414- break;
415+ version = read_2_bytes (abfd, mac_ptr);
416+ if (version != 4)
417+ {
418+ complaint (&symfile_complaints,
419+ _("unrecognized version `%d' in .debug_macro section"),
420+ version);
421+ return NULL;
422+ }
423+ mac_ptr += 2;
424
425- case DW_MACINFO_end_file:
426- /* No data to skip by MAC_PTR. */
427- break;
428+ flags = read_1_byte (abfd, mac_ptr);
429+ ++mac_ptr;
430+ *offset_size = (flags & 1) ? 8 : 4;
431
432- case DW_MACINFO_vendor_ext:
433- /* Only skip the data by MAC_PTR. */
434- {
435- unsigned int bytes_read;
436+ if ((flags & 2) != 0)
437+ /* We don't need the line table offset. */
438+ mac_ptr += *offset_size;
439
440- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
441- mac_ptr += bytes_read;
442- read_direct_string (abfd, mac_ptr, &bytes_read);
443- mac_ptr += bytes_read;
444- }
445- break;
446+ /* Vendor opcode descriptions. */
447+ if ((flags & 4) != 0)
448+ {
449+ unsigned int i, count;
450
451- default:
452- break;
453+ count = read_1_byte (abfd, mac_ptr);
454+ ++mac_ptr;
455+ for (i = 0; i < count; ++i)
456+ {
457+ unsigned int opcode, bytes_read;
458+ unsigned long arg;
459+
460+ opcode = read_1_byte (abfd, mac_ptr);
461+ ++mac_ptr;
462+ opcode_definitions[opcode] = mac_ptr;
463+ arg = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
464+ mac_ptr += bytes_read;
465+ mac_ptr += arg;
466+ }
467 }
468- } while (macinfo_type != 0 && current_file == NULL);
469+ }
470
471- /* Second pass: Process all entries.
472+ return mac_ptr;
473+}
474
475- Use the AT_COMMAND_LINE flag to determine whether we are still processing
476- command-line macro definitions/undefinitions. This flag is unset when we
477- reach the first DW_MACINFO_start_file entry. */
478+/* A helper for dwarf_decode_macros that handles the GNU extensions,
479+ including DW_GNU_MACINFO_transparent_include. */
480+
481+static void
482+dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end,
483+ struct macro_source_file *current_file,
484+ struct line_header *lh, char *comp_dir,
485+ struct dwarf2_section_info *section,
486+ int section_is_gnu,
487+ unsigned int offset_size,
488+ struct objfile *objfile)
489+{
490+ enum dwarf_macro_record_type macinfo_type;
491+ int at_commandline;
492+ gdb_byte *opcode_definitions[256];
493
494- mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset;
495+ mac_ptr = dwarf_parse_macro_header (opcode_definitions, abfd, mac_ptr,
496+ &offset_size, section_is_gnu);
497+ if (mac_ptr == NULL)
498+ {
499+ /* We already issued a complaint. */
500+ return;
501+ }
502
503 /* Determines if GDB is still before first DW_MACINFO_start_file. If true
504 GDB is still reading the definitions from command line. First
505@@ -14795,13 +14908,15 @@
506 /* Do we at least have room for a macinfo type byte? */
507 if (mac_ptr >= mac_end)
508 {
509- dwarf2_macros_too_long_complaint ();
510+ dwarf2_macros_too_long_complaint (section);
511 break;
512 }
513
514 macinfo_type = read_1_byte (abfd, mac_ptr);
515 mac_ptr++;
516
517+ /* Note that we rely on the fact that the corresponding GNU and
518+ DWARF constants are the same. */
519 switch (macinfo_type)
520 {
521 /* A zero macinfo type indicates the end of the macro
522@@ -14809,29 +14924,45 @@
523 case 0:
524 break;
525
526- case DW_MACINFO_define:
527- case DW_MACINFO_undef:
528+ case DW_MACRO_GNU_define:
529+ case DW_MACRO_GNU_undef:
530+ case DW_MACRO_GNU_define_indirect:
531+ case DW_MACRO_GNU_undef_indirect:
532 {
533 unsigned int bytes_read;
534 int line;
535 char *body;
536+ int is_define;
537
538- line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
539- mac_ptr += bytes_read;
540- body = read_direct_string (abfd, mac_ptr, &bytes_read);
541- mac_ptr += bytes_read;
542+ line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
543+ mac_ptr += bytes_read;
544+
545+ if (macinfo_type == DW_MACRO_GNU_define
546+ || macinfo_type == DW_MACRO_GNU_undef)
547+ {
548+ body = read_direct_string (abfd, mac_ptr, &bytes_read);
549+ mac_ptr += bytes_read;
550+ }
551+ else
552+ {
553+ LONGEST str_offset;
554+
555+ str_offset = read_offset_1 (abfd, mac_ptr, offset_size);
556+ mac_ptr += offset_size;
557
558+ body = read_indirect_string_at_offset (abfd, str_offset);
559+ }
560+
561+ is_define = (macinfo_type == DW_MACRO_GNU_define
562+ || macinfo_type == DW_MACRO_GNU_define_indirect);
563 if (! current_file)
564 {
565 /* DWARF violation as no main source is present. */
566 complaint (&symfile_complaints,
567 _("debug info with no main source gives macro %s "
568 "on line %d: %s"),
569- macinfo_type == DW_MACINFO_define ?
570- _("definition") :
571- macinfo_type == DW_MACINFO_undef ?
572- _("undefinition") :
573- _("something-or-other"), line, body);
574+ is_define ? _("definition") : _("undefinition"),
575+ line, body);
576 break;
577 }
578 if ((line == 0 && !at_commandline)
579@@ -14839,21 +14970,21 @@
580 complaint (&symfile_complaints,
581 _("debug info gives %s macro %s with %s line %d: %s"),
582 at_commandline ? _("command-line") : _("in-file"),
583- macinfo_type == DW_MACINFO_define ?
584- _("definition") :
585- macinfo_type == DW_MACINFO_undef ?
586- _("undefinition") :
587- _("something-or-other"),
588+ is_define ? _("definition") : _("undefinition"),
589 line == 0 ? _("zero") : _("non-zero"), line, body);
590
591- if (macinfo_type == DW_MACINFO_define)
592+ if (is_define)
593 parse_macro_definition (current_file, line, body);
594- else if (macinfo_type == DW_MACINFO_undef)
595- macro_undef (current_file, line, body);
596+ else
597+ {
598+ gdb_assert (macinfo_type == DW_MACRO_GNU_undef
599+ || macinfo_type == DW_MACRO_GNU_undef_indirect);
600+ macro_undef (current_file, line, body);
601+ }
602 }
603 break;
604
605- case DW_MACINFO_start_file:
606+ case DW_MACRO_GNU_start_file:
607 {
608 unsigned int bytes_read;
609 int line, file;
610@@ -14873,17 +15004,18 @@
611
612 if (at_commandline)
613 {
614- /* This DW_MACINFO_start_file was executed in the pass one. */
615+ /* This DW_MACRO_GNU_start_file was executed in the
616+ pass one. */
617 at_commandline = 0;
618 }
619 else
620 current_file = macro_start_file (file, line,
621 current_file, comp_dir,
622- lh, cu->objfile);
623+ lh, objfile);
624 }
625 break;
626
627- case DW_MACINFO_end_file:
628+ case DW_MACRO_GNU_end_file:
629 if (! current_file)
630 complaint (&symfile_complaints,
631 _("macro debug info has an unmatched "
632@@ -14893,7 +15025,7 @@
633 current_file = current_file->included_by;
634 if (! current_file)
635 {
636- enum dwarf_macinfo_record_type next_type;
637+ enum dwarf_macro_record_type next_type;
638
639 /* GCC circa March 2002 doesn't produce the zero
640 type byte marking the end of the compilation
641@@ -14903,7 +15035,7 @@
642 /* Do we at least have room for a macinfo type byte? */
643 if (mac_ptr >= mac_end)
644 {
645- dwarf2_macros_too_long_complaint ();
646+ dwarf2_macros_too_long_complaint (section);
647 return;
648 }
649
650@@ -14920,23 +15052,199 @@
651 }
652 break;
653
654+ case DW_MACRO_GNU_transparent_include:
655+ {
656+ LONGEST offset;
657+
658+ offset = read_offset_1 (abfd, mac_ptr, offset_size);
659+ mac_ptr += offset_size;
660+
661+ dwarf_decode_macro_bytes (abfd,
662+ section->buffer + offset,
663+ mac_end, current_file,
664+ lh, comp_dir,
665+ section, section_is_gnu,
666+ offset_size, objfile);
667+ }
668+ break;
669+
670 case DW_MACINFO_vendor_ext:
671- {
672- unsigned int bytes_read;
673- int constant;
674+ if (!section_is_gnu)
675+ {
676+ unsigned int bytes_read;
677+ int constant;
678
679- constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
680- mac_ptr += bytes_read;
681- read_direct_string (abfd, mac_ptr, &bytes_read);
682- mac_ptr += bytes_read;
683+ constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
684+ mac_ptr += bytes_read;
685+ read_direct_string (abfd, mac_ptr, &bytes_read);
686+ mac_ptr += bytes_read;
687
688- /* We don't recognize any vendor extensions. */
689- }
690- break;
691+ /* We don't recognize any vendor extensions. */
692+ break;
693+ }
694+ /* FALLTHROUGH */
695+
696+ default:
697+ mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions,
698+ mac_ptr, abfd, offset_size,
699+ section);
700+ if (mac_ptr == NULL)
701+ return;
702+ break;
703 }
704 } while (macinfo_type != 0);
705 }
706
707+static void
708+dwarf_decode_macros (struct line_header *lh, unsigned int offset,
709+ char *comp_dir, bfd *abfd,
710+ struct dwarf2_cu *cu,
711+ struct dwarf2_section_info *section,
712+ int section_is_gnu)
713+{
714+ gdb_byte *mac_ptr, *mac_end;
715+ struct macro_source_file *current_file = 0;
716+ enum dwarf_macro_record_type macinfo_type;
717+ unsigned int offset_size = cu->header.offset_size;
718+ gdb_byte *opcode_definitions[256];
719+
720+ dwarf2_read_section (dwarf2_per_objfile->objfile, section);
721+ if (section->buffer == NULL)
722+ {
723+ complaint (&symfile_complaints, _("missing %s section"),
724+ section->asection->name);
725+ return;
726+ }
727+
728+ /* First pass: Find the name of the base filename.
729+ This filename is needed in order to process all macros whose definition
730+ (or undefinition) comes from the command line. These macros are defined
731+ before the first DW_MACINFO_start_file entry, and yet still need to be
732+ associated to the base file.
733+
734+ To determine the base file name, we scan the macro definitions until we
735+ reach the first DW_MACINFO_start_file entry. We then initialize
736+ CURRENT_FILE accordingly so that any macro definition found before the
737+ first DW_MACINFO_start_file can still be associated to the base file. */
738+
739+ mac_ptr = section->buffer + offset;
740+ mac_end = section->buffer + section->size;
741+
742+ mac_ptr = dwarf_parse_macro_header (opcode_definitions, abfd, mac_ptr,
743+ &offset_size, section_is_gnu);
744+ if (mac_ptr == NULL)
745+ {
746+ /* We already issued a complaint. */
747+ return;
748+ }
749+
750+ do
751+ {
752+ /* Do we at least have room for a macinfo type byte? */
753+ if (mac_ptr >= mac_end)
754+ {
755+ /* Complaint is printed during the second pass as GDB will probably
756+ stop the first pass earlier upon finding
757+ DW_MACINFO_start_file. */
758+ break;
759+ }
760+
761+ macinfo_type = read_1_byte (abfd, mac_ptr);
762+ mac_ptr++;
763+
764+ /* Note that we rely on the fact that the corresponding GNU and
765+ DWARF constants are the same. */
766+ switch (macinfo_type)
767+ {
768+ /* A zero macinfo type indicates the end of the macro
769+ information. */
770+ case 0:
771+ break;
772+
773+ case DW_MACRO_GNU_define:
774+ case DW_MACRO_GNU_undef:
775+ /* Only skip the data by MAC_PTR. */
776+ {
777+ unsigned int bytes_read;
778+
779+ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
780+ mac_ptr += bytes_read;
781+ read_direct_string (abfd, mac_ptr, &bytes_read);
782+ mac_ptr += bytes_read;
783+ }
784+ break;
785+
786+ case DW_MACRO_GNU_start_file:
787+ {
788+ unsigned int bytes_read;
789+ int line, file;
790+
791+ line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
792+ mac_ptr += bytes_read;
793+ file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
794+ mac_ptr += bytes_read;
795+
796+ current_file = macro_start_file (file, line, current_file,
797+ comp_dir, lh, cu->objfile);
798+ }
799+ break;
800+
801+ case DW_MACRO_GNU_end_file:
802+ /* No data to skip by MAC_PTR. */
803+ break;
804+
805+ case DW_MACRO_GNU_define_indirect:
806+ case DW_MACRO_GNU_undef_indirect:
807+ {
808+ unsigned int bytes_read;
809+
810+ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
811+ mac_ptr += bytes_read;
812+ mac_ptr += offset_size;
813+ }
814+ break;
815+
816+ case DW_MACRO_GNU_transparent_include:
817+ /* Note that, according to the spec, a transparent include
818+ chain cannot call DW_MACRO_GNU_start_file. So, we can just
819+ skip this opcode. */
820+ mac_ptr += offset_size;
821+ break;
822+
823+ case DW_MACINFO_vendor_ext:
824+ /* Only skip the data by MAC_PTR. */
825+ if (!section_is_gnu)
826+ {
827+ unsigned int bytes_read;
828+
829+ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
830+ mac_ptr += bytes_read;
831+ read_direct_string (abfd, mac_ptr, &bytes_read);
832+ mac_ptr += bytes_read;
833+ }
834+ /* FALLTHROUGH */
835+
836+ default:
837+ mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions,
838+ mac_ptr, abfd, offset_size,
839+ section);
840+ if (mac_ptr == NULL)
841+ return;
842+ break;
843+ }
844+ } while (macinfo_type != 0 && current_file == NULL);
845+
846+ /* Second pass: Process all entries.
847+
848+ Use the AT_COMMAND_LINE flag to determine whether we are still processing
849+ command-line macro definitions/undefinitions. This flag is unset when we
850+ reach the first DW_MACINFO_start_file entry. */
851+
852+ dwarf_decode_macro_bytes (abfd, section->buffer + offset, mac_end,
853+ current_file, lh, comp_dir, section, section_is_gnu,
854+ offset_size, cu->objfile);
855+}
856+
857 /* Check if the attribute's form is a DW_FORM_block*
858 if so return true else false. */
859 static int
860@@ -15663,6 +15971,7 @@
861 munmap_section_buffer (&data->line);
862 munmap_section_buffer (&data->loc);
863 munmap_section_buffer (&data->macinfo);
864+ munmap_section_buffer (&data->macro);
865 munmap_section_buffer (&data->str);
866 munmap_section_buffer (&data->ranges);
867 munmap_section_buffer (&data->frame);
868--- src/gdb/symfile.h 2011/06/10 21:48:04 1.93
869+++ src/gdb/symfile.h 2011/07/26 17:04:23 1.94
870@@ -582,6 +582,7 @@
871 struct dwarf2_section_names line;
872 struct dwarf2_section_names loc;
873 struct dwarf2_section_names macinfo;
874+ struct dwarf2_section_names macro;
875 struct dwarf2_section_names str;
876 struct dwarf2_section_names ranges;
877 struct dwarf2_section_names types;
878
879
880
881Re: FYI: implement new DWARF macro proposal
882http://sourceware.org/ml/gdb-patches/2011-07/msg00759.html
883http://sourceware.org/ml/gdb-cvs/2011-07/msg00224.html
884
885### src/gdb/ChangeLog 2011/07/26 21:09:05 1.13229
886### src/gdb/ChangeLog 2011/07/27 14:45:36 1.13230
887## -1,3 +1,10 @@
888+2011-07-27 Tom Tromey <tromey@redhat.com>
889+
890+ * xcoffread.c (dwarf2_xcoff_names): Add 'macro' and 'sentinel'
891+ entries.
892+ * symfile.h (struct dwarf2_debug_sections) <sentinel>: New field.
893+ * dwarf2read.c (dwarf2_elf_names): Add sentinel entry.
894+
895 2011-07-26 Sterling Augustine <saugustine@google.com>
896
897 * cli/cli-dump.c (dump_binary_file): Change parameter type to
898--- src/gdb/dwarf2read.c 2011/07/26 17:04:23 1.555
899+++ src/gdb/dwarf2read.c 2011/07/27 14:45:37 1.556
900@@ -271,7 +271,8 @@
901 { ".debug_types", ".zdebug_types" },
902 { ".debug_frame", ".zdebug_frame" },
903 { ".eh_frame", NULL },
904- { ".gdb_index", ".zgdb_index" }
905+ { ".gdb_index", ".zgdb_index" },
906+ 23
907 };
908
909 /* local data types */
910--- src/gdb/symfile.h 2011/07/26 17:04:23 1.94
911+++ src/gdb/symfile.h 2011/07/27 14:45:37 1.95
912@@ -589,6 +589,9 @@
913 struct dwarf2_section_names frame;
914 struct dwarf2_section_names eh_frame;
915 struct dwarf2_section_names gdb_index;
916+ /* This field has no meaning, but exists solely to catch changes to
917+ this structure which are not reflected in some instance. */
918+ int sentinel;
919 };
920
921 extern int dwarf2_has_info (struct objfile *,
922--- src/gdb/xcoffread.c 2011/06/07 12:31:07 1.89
923+++ src/gdb/xcoffread.c 2011/07/27 14:45:37 1.90
924@@ -160,12 +160,14 @@
925 { ".dwline", NULL },
926 { ".dwloc", NULL },
927 { NULL, NULL }, /* debug_macinfo */
928+ { NULL, NULL }, /* debug_macro */
929 { ".dwstr", NULL },
930 { ".dwrnges", NULL },
931 { NULL, NULL }, /* debug_types */
932 { ".dwframe", NULL },
933 { NULL, NULL }, /* eh_frame */
934- { NULL, NULL } /* gdb_index */
935+ { NULL, NULL }, /* gdb_index */
936+ 23
937 };
938
939 static void
940
941
942
943[patch][python] Fix sigsegv when a printer fails to return a value and string_print is set.
944http://sourceware.org/ml/gdb-patches/2011-07/msg00719.html
945http://sourceware.org/ml/gdb-cvs/2011-07/msg00234.html
946
947### src/gdb/ChangeLog 2011/07/27 19:31:30 1.13236
948### src/gdb/ChangeLog 2011/07/28 10:36:37 1.13237
949## -1,3 +1,8 @@
950+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
951+
952+ * varobj.c (value_get_print_value): Move hint check later into the
953+ function. Comment function. Free thevalue before reusing it.
954+
955 2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
956 Pedro Alves <pedro@codesourcery.com>
957
958--- src/gdb/varobj.c 2011/07/18 09:21:43 1.180
959+++ src/gdb/varobj.c 2011/07/28 10:36:40 1.181
960@@ -2610,25 +2610,21 @@
961
962 if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
963 {
964- char *hint;
965 struct value *replacement;
966 PyObject *output = NULL;
967
968- hint = gdbpy_get_display_hint (value_formatter);
969- if (hint)
970- {
971- if (!strcmp (hint, "string"))
972- string_print = 1;
973- xfree (hint);
974- }
975-
976 output = apply_varobj_pretty_printer (value_formatter,
977 &replacement,
978 stb);
979+
980+ /* If we have string like output ... */
981 if (output)
982 {
983 make_cleanup_py_decref (output);
984
985+ /* If this is a lazy string, extract it. For lazy
986+ strings we always print as a string, so set
987+ string_print. */
988 if (gdbpy_is_lazy_string (output))
989 {
990 gdbpy_extract_lazy_string (output, &str_addr, &type,
991@@ -2638,12 +2634,27 @@
992 }
993 else
994 {
995+ /* If it is a regular (non-lazy) string, extract
996+ it and copy the contents into THEVALUE. If the
997+ hint says to print it as a string, set
998+ string_print. Otherwise just return the extracted
999+ string as a value. */
1000+
1001 PyObject *py_str
1002 = python_string_to_target_python_string (output);
1003
1004 if (py_str)
1005 {
1006 char *s = PyString_AsString (py_str);
1007+ char *hint;
1008+
1009+ hint = gdbpy_get_display_hint (value_formatter);
1010+ if (hint)
1011+ {
1012+ if (!strcmp (hint, "string"))
1013+ string_print = 1;
1014+ xfree (hint);
1015+ }
1016
1017 len = PyString_Size (py_str);
1018 thevalue = xmemdup (s, len + 1, len + 1);
1019@@ -2662,6 +2673,9 @@
1020 gdbpy_print_stack ();
1021 }
1022 }
1023+ /* If the printer returned a replacement value, set VALUE
1024+ to REPLACEMENT. If there is not a replacement value,
1025+ just use the value passed to this function. */
1026 if (replacement)
1027 value = replacement;
1028 }
1029@@ -2672,12 +2686,18 @@
1030 get_formatted_print_options (&opts, format_code[(int) format]);
1031 opts.deref_ref = 0;
1032 opts.raw = 1;
1033+
1034+ /* If the THEVALUE has contents, it is a regular string. */
1035 if (thevalue)
1036 LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
1037 else if (string_print)
1038+ /* Otherwise, if string_print is set, and it is not a regular
1039+ string, it is a lazy string. */
1040 val_print_string (type, encoding, str_addr, len, stb, &opts);
1041 else
1042+ /* All other cases. */
1043 common_val_print (value, stb, 0, &opts, current_language);
1044+
1045 thevalue = ui_file_xstrdup (stb, NULL);
1046
1047 do_cleanups (old_chain);
1048### src/gdb/testsuite/ChangeLog 2011/07/27 21:18:39 1.2816
1049### src/gdb/testsuite/ChangeLog 2011/07/28 10:36:40 1.2817
1050## -1,3 +1,10 @@
1051+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
1052+
1053+ * gdb.python/py-mi.exp: Test printers returning string hint, and
1054+ also not returning a value.
1055+ * gdb.python/py-prettyprint.c: Add testcase for above.
1056+ * gdb.python/py-prettyprint.py: Add test printer for above.
1057+
1058 2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
1059
1060 * gdb.dwarf2/dw2-simple-locdesc.S: Change DWARF version to 3.
1061--- src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/26 18:38:55 1.13
1062+++ src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/28 10:36:40 1.14
1063@@ -284,6 +284,13 @@ mi_list_varobj_children nstype2 {
1064 { {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} }
1065 } "list children after setting exception flag"
1066
1067+mi_create_varobj me me \
1068+ "create me varobj"
1069+
1070+mi_gdb_test "-var-evaluate-expression me" \
1071+ "\\^done,value=\"<error reading variable: Cannot access memory.>.*\"" \
1072+ "evaluate me varobj"
1073+
1074 # C++ MI tests
1075 gdb_exit
1076 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
1077--- src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/04/29 12:45:46 1.12
1078+++ src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/07/28 10:36:40 1.13
1079@@ -149,6 +149,11 @@
1080
1081 typedef struct justchildren nostring_type;
1082
1083+struct memory_error
1084+{
1085+ const char *s;
1086+};
1087+
1088 struct container
1089 {
1090 string name;
1091@@ -227,6 +232,7 @@
1092 /* Clearing by being `static' could invoke an other GDB C++ bug. */
1093 struct nullstr nullstr;
1094 nostring_type nstype, nstype2;
1095+ struct memory_error me;
1096 struct ns ns, ns2;
1097 struct lazystring estring, estring2;
1098 struct hint_error hint_error;
1099@@ -234,6 +240,8 @@
1100 nstype.elements = narray;
1101 nstype.len = 0;
1102
1103+ me.s = "blah";
1104+
1105 init_ss(&ss, 1, 2);
1106 init_ss(ssa+0, 3, 4);
1107 init_ss(ssa+1, 5, 6);
1108--- src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/04/11 17:40:41 1.11
1109+++ src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/07/28 10:36:40 1.12
1110@@ -17,6 +17,7 @@
1111 # printers.
1112
1113 import re
1114+import gdb
1115
1116 # Test returning a Value from a printer.
1117 class string_print:
1118@@ -186,6 +187,18 @@
1119 yield 's', self.val['s']
1120 yield 'x', self.val['x']
1121
1122+class MemoryErrorString:
1123+ "Raise an error"
1124+
1125+ def __init__(self, val):
1126+ self.val = val
1127+
1128+ def to_string(self):
1129+ raise gdb.MemoryError ("Cannot access memory.");
1130+
1131+ def display_hint (self):
1132+ return 'string'
1133+
1134 def lookup_function (val):
1135 "Look-up and return a pretty-printer that can print val."
1136
1137@@ -261,6 +274,8 @@
1138 pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error
1139 pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error
1140
1141+ pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString
1142+
1143 pretty_printers_dict = {}
1144
1145 register_pretty_printers ()
1146
1147
1148
1149commit 84be2b4d0a55c95697c9ecc72bb31c2fbd316127
1150Author: ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
1151Date: Tue Jul 26 14:28:23 2011 +0000
1152
1153 * cp-demangle.c (d_print_init): Initialize pack_index field.
1154 (d_print_comp): Check for NULL template argument.
1155 * testsuite/demangle-expected: Add test case.
1156
1157
1158 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176791 138bc75d-0d04-0410-961f-82ee72b054a4
1159
1160### a/libiberty/ChangeLog
1161### b/libiberty/ChangeLog
1162## -1,3 +1,9 @@
1163+2011-07-26 Ian Lance Taylor <iant@google.com>
1164+
1165+ * cp-demangle.c (d_print_init): Initialize pack_index field.
1166+ (d_print_comp): Check for NULL template argument.
1167+ * testsuite/demangle-expected: Add test case.
1168+
1169 2011-07-22 Gerald Pfeifer <gerald@pfeifer.com>
1170
1171 PR target/49817
1172--- a/libiberty/cp-demangle.c
1173+++ b/libiberty/cp-demangle.c
1174@@ -1,5 +1,5 @@
1175 /* Demangler for g++ V3 ABI.
1176- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
1177+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
1178 Free Software Foundation, Inc.
1179 Written by Ian Lance Taylor <ian@wasabisystems.com>.
1180
1181@@ -3306,6 +3306,7 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
1182 dpi->last_char = '\0';
1183 dpi->templates = NULL;
1184 dpi->modifiers = NULL;
1185+ dpi->pack_index = 0;
1186 dpi->flush_count = 0;
1187
1188 dpi->callback = callback;
1189@@ -3893,6 +3894,13 @@ d_print_comp (struct d_print_info *dpi, int options,
1190 struct demangle_component *a = d_lookup_template_argument (dpi, sub);
1191 if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
1192 a = d_index_template_argument (a, dpi->pack_index);
1193+
1194+ if (a == NULL)
1195+ {
1196+ d_print_error (dpi);
1197+ return;
1198+ }
1199+
1200 sub = a;
1201 }
1202
1203--- a/libiberty/testsuite/demangle-expected
1204+++ b/libiberty/testsuite/demangle-expected
1205@@ -4010,6 +4010,12 @@ K<1, &S::m>::f()
1206 _ZN1KILi1EXadL_ZN1S1mEEEE1fEv
1207 K<1, &S::m>::f()
1208 #
1209+# Used to crash -- binutils PR 13030.
1210+--format=gnu-v3
1211+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
1212+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
1213+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
1214+#
1215 # Ada (GNAT) tests.
1216 #
1217 # Simple test.
1218
1219
1220
1221http://sourceware.org/ml/gdb-cvs/2011-08/msg00047.html
1222
1223### src/gdb/ChangeLog 2011/08/08 21:41:12 1.13259
1224### src/gdb/ChangeLog 2011/08/09 12:45:39 1.13260
1225## -1,3 +1,13 @@
1226+2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
1227+
1228+ * python/lib/gdb/__init__.py: Auto-load files in command and
1229+ function directories.
1230+ * python/python.c (finish_python_initialization): Use
1231+ os.path.join.
1232+ * python/lib/gdb/command/pretty_printers.py: Self register
1233+ command.
1234+ * NEWS: Document auto-loading.
1235+
1236 2011-08-08 Jan Kratochvil <jan.kratochvil@redhat.com>
1237
1238 * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>
1239--- src/gdb/NEWS 2011/07/26 20:57:53 1.446
1240+++ src/gdb/NEWS 2011/08/09 12:45:39 1.447
1241@@ -23,6 +23,11 @@
1242 ** A prompt subsitution hook (prompt_hook) is now available to the
1243 Python API.
1244
1245+ ** Python commands and convenience-functions located in
1246+ 'data-directory'/python/gdb/command and
1247+ 'data-directory'/python/gdb/function are now automatically loaded
1248+ on GDB start-up.
1249+
1250 * libthread-db-search-path now supports two special values: $sdir and $pdir.
1251 $sdir specifies the default system locations of shared libraries.
1252 $pdir specifies the directory where the libpthread used by the application
1253### src/gdb/doc/ChangeLog 2011/07/26 16:59:23 1.1202
1254### src/gdb/doc/ChangeLog 2011/08/09 12:45:39 1.1203
1255## -1,3 +1,8 @@
1256+2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
1257+
1258+ * gdb.texinfo (Python): Document command and function
1259+ auto-loading.
1260+
1261 2011-07-26 Jan Kratochvil <jan.kratochvil@redhat.com>
1262 Eli Zaretskii <eliz@gnu.org>
1263
1264--- src/gdb/doc/gdb.texinfo 2011/07/26 20:57:54 1.851
1265+++ src/gdb/doc/gdb.texinfo 2011/08/09 12:45:39 1.852
1266@@ -20845,6 +20845,12 @@
1267 is automatically added to the Python Search Path in order to allow
1268 the Python interpreter to locate all scripts installed at this location.
1269
1270+Additionally, @value{GDBN} commands and convenience functions which
1271+are written in Python and are located in the
1272+@file{@var{data-directory}/python/gdb/command} or
1273+@file{@var{data-directory}/python/gdb/function} directories are
1274+automatically imported when @value{GDBN} starts.
1275+
1276 @menu
1277 * Python Commands:: Accessing Python from @value{GDBN}.
1278 * Python API:: Accessing @value{GDBN} from Python.
1279--- src/gdb/python/python.c 2011/07/22 09:22:50 1.68
1280+++ src/gdb/python/python.c 2011/08/09 12:45:40 1.69
1281@@ -1302,13 +1302,13 @@
1282 sys.path.insert (0, gdb.PYTHONDIR)\n\
1283 \n\
1284 # Tell python where to find submodules of gdb.\n\
1285- gdb.__path__ = [gdb.PYTHONDIR + '/gdb']\n\
1286+ gdb.__path__ = [os.path.join (gdb.PYTHONDIR, 'gdb')]\n\
1287 \n\
1288 # The gdb module is implemented in C rather than in Python. As a result,\n\
1289 # the associated __init.py__ script is not not executed by default when\n\
1290 # the gdb module gets imported. Execute that script manually if it\n\
1291 # exists.\n\
1292- ipy = gdb.PYTHONDIR + '/gdb/__init__.py'\n\
1293+ ipy = os.path.join (gdb.PYTHONDIR, 'gdb', '__init__.py')\n\
1294 if os.path.exists (ipy):\n\
1295 execfile (ipy)\n\
1296 \n\
1297--- src/gdb/python/lib/gdb/__init__.py 2011/01/01 15:33:26 1.3
1298+++ src/gdb/python/lib/gdb/__init__.py 2011/08/09 12:45:40 1.4
1299@@ -13,6 +13,29 @@
1300 # You should have received a copy of the GNU General Public License
1301 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1302
1303-import gdb.command.pretty_printers
1304+import traceback
1305
1306-gdb.command.pretty_printers.register_pretty_printer_commands()
1307+# Auto-load all functions/commands.
1308+
1309+# Modules to auto-load, and the paths where those modules exist.
1310+
1311+module_dict = {
1312+ 'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'),
1313+ 'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command')
1314+}
1315+
1316+# Iterate the dictionary, collating the Python files in each module
1317+# path. Construct the module name, and import.
1318+
1319+for module, location in module_dict.iteritems():
1320+ if os.path.exists(location):
1321+ py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py',
1322+ os.listdir(location))
1323+
1324+ for py_file in py_files:
1325+ # Construct from foo.py, gdb.module.foo
1326+ py_file = module + '.' + py_file[:-3]
1327+ try:
1328+ exec('import ' + py_file)
1329+ except:
1330+ print >> sys.stderr, traceback.format_exc()
1331--- src/gdb/python/lib/gdb/command/pretty_printers.py 2011/01/01 15:33:27 1.4
1332+++ src/gdb/python/lib/gdb/command/pretty_printers.py 2011/08/09 12:45:40 1.5
1333@@ -368,3 +368,5 @@
1334 InfoPrettyPrinter()
1335 EnablePrettyPrinter()
1336 DisablePrettyPrinter()
1337+
1338+register_pretty_printer_commands()
1339
1340
1341
1342http://sourceware.org/ml/gdb-patches/2011-08/msg00505.html
1343Subject: fix "info os processes" race -> crash (ext-run.exp racy FAIL)
1344http://sourceware.org/ml/gdb-cvs/2011-08/msg00116.html
1345
1346### src/gdb/ChangeLog 2011/08/26 17:58:57 1.13281
1347### src/gdb/ChangeLog 2011/08/26 18:58:02 1.13282
1348## -1,3 +1,8 @@
1349+2011-08-26 Pedro Alves <pedro@codesourcery.com>
1350+
1351+ * common/linux-osdata.c (get_cores_used_by_process): Don't assume
1352+ opening /proc/PID/task always succeeds.
1353+
1354 2011-08-26 Aleksandar Ristovski <aristovski@qnx.com>
1355
1356 * linespec.c (symtab_from_filename): Check for the end of string.
1357--- src/gdb/common/linux-osdata.c 2011/07/21 23:46:09 1.1
1358+++ src/gdb/common/linux-osdata.c 2011/08/26 18:58:04 1.2
1359@@ -259,27 +259,29 @@
1360
1361 sprintf (taskdir, "/proc/%d/task", pid);
1362 dir = opendir (taskdir);
1363-
1364- while ((dp = readdir (dir)) != NULL)
1365+ if (dir)
1366 {
1367- pid_t tid;
1368- int core;
1369+ while ((dp = readdir (dir)) != NULL)
1370+ {
1371+ pid_t tid;
1372+ int core;
1373
1374- if (!isdigit (dp->d_name[0])
1375- || NAMELEN (dp) > sizeof ("4294967295") - 1)
1376- continue;
1377+ if (!isdigit (dp->d_name[0])
1378+ || NAMELEN (dp) > sizeof ("4294967295") - 1)
1379+ continue;
1380
1381- tid = atoi (dp->d_name);
1382- core = linux_common_core_of_thread (ptid_build (pid, tid, 0));
1383+ tid = atoi (dp->d_name);
1384+ core = linux_common_core_of_thread (ptid_build (pid, tid, 0));
1385
1386- if (core >= 0)
1387- {
1388- ++cores[core];
1389- ++task_count;
1390+ if (core >= 0)
1391+ {
1392+ ++cores[core];
1393+ ++task_count;
1394+ }
1395 }
1396- }
1397
1398- closedir (dir);
1399+ closedir (dir);
1400+ }
1401
1402 return task_count;
1403 }
1404
1405
1406
1407Fix for https://bugzilla.redhat.com/show_bug.cgi?id=750341
1408http://sourceware.org/ml/gdb-patches/2011-10/msg00570.html
1409
1410
1411http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html
1412
1413### src/gdb/ChangeLog 2011/10/20 13:34:13 1.13446
1414### src/gdb/ChangeLog 2011/10/20 20:06:11 1.13447
1415## -1,3 +1,15 @@
1416+2011-10-20 Aleksandar Ristovski <aristovski@qnx.com>
1417+
1418+ * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
1419+ arguments by adding OBJFILE. Instead of getting objfile from
1420+ symbol's symtab, use new argument OBJFILE.
1421+ * cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
1422+ arguments by adding OBJFILE.
1423+ * gdb/dwarf2read.c (new_symbol_full): Change call to
1424+ cp_scan_for_anonymous_namespaces to match new signature.
1425+ * gdb/stabsread.c (define_symbol): Change call to
1426+ cp_scan_for_anonymous_namespaces to match new signature.
1427+
1428 2011-10-20 Phil Muldoon <pmuldoon@redhat.com>
1429
1430 PR python/13308
1431--- src/gdb/cp-namespace.c 2011/06/29 22:05:15 1.54
1432+++ src/gdb/cp-namespace.c 2011/10/20 20:06:13 1.55
1433@@ -53,7 +53,8 @@
1434 anonymous namespace; if so, add an appropriate using directive. */
1435
1436 void
1437-cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
1438+cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
1439+ struct objfile *const objfile)
1440 {
1441 if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
1442 {
1443@@ -96,7 +97,7 @@
1444 namespace given by the previous component if there is
1445 one, or to the global namespace if there isn't. */
1446 cp_add_using_directive (dest, src, NULL, NULL, NULL,
1447- &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
1448+ &objfile->objfile_obstack);
1449 }
1450 /* The "+ 2" is for the "::". */
1451 previous_component = next_component + 2;
1452--- src/gdb/cp-support.h 2011/08/18 16:17:38 1.45
1453+++ src/gdb/cp-support.h 2011/10/20 20:06:13 1.46
1454@@ -197,7 +197,8 @@
1455 const char *processing_current_prefix,
1456 int processing_has_namespace_info);
1457
1458-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
1459+extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
1460+ struct objfile *objfile);
1461
1462 extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
1463 const struct block *block,
1464--- src/gdb/dwarf2read.c 2011/10/20 01:11:34 1.576
1465+++ src/gdb/dwarf2read.c 2011/10/20 20:06:13 1.577
1466@@ -11992,7 +11992,7 @@
1467 namespaces based on the demangled name. */
1468 if (!processing_has_namespace_info
1469 && cu->language == language_cplus)
1470- cp_scan_for_anonymous_namespaces (sym);
1471+ cp_scan_for_anonymous_namespaces (sym, objfile);
1472 }
1473 return (sym);
1474 }
1475--- src/gdb/stabsread.c 2011/05/18 16:30:36 1.138
1476+++ src/gdb/stabsread.c 2011/10/20 20:06:14 1.139
1477@@ -729,7 +729,7 @@
1478 SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
1479
1480 if (SYMBOL_LANGUAGE (sym) == language_cplus)
1481- cp_scan_for_anonymous_namespaces (sym);
1482+ cp_scan_for_anonymous_namespaces (sym, objfile);
1483
1484 }
1485 p++;