From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12011 invoked by alias); 30 Mar 2009 17:22:22 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 11962 invoked by uid 9674); 30 Mar 2009 17:22:21 -0000 Date: Mon, 30 Mar 2009 17:22:00 -0000 Message-ID: <20090330172220.11914.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer: Merge commit 'origin/archer-jankratochvil-misc' into archer X-Git-Refname: refs/heads/archer X-Git-Reftype: branch X-Git-Oldrev: 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 X-Git-Newrev: 1ffc3d262e82dca2cda7161d077daf504c83049d X-SW-Source: 2009-q1/txt/msg00399.txt.bz2 List-Id: The branch, archer has been updated via 1ffc3d262e82dca2cda7161d077daf504c83049d (commit) via 40eb49471d238095a443b0bc52d02723130c2537 (commit) via 0adf45a975c950b336e60ae9b6707a03b214cb08 (commit) via 21a8e954408460987eb5c5b3c6005ed05ef205cb (commit) via 0d0dcd08bf84e52e3dd43b37a3b06eb2f934291d (commit) via 6332d6a7d94e223d42f981701e703e549e36915b (commit) via ace893b9443896a2f15aaece99d59d406cbd58c7 (commit) via 4cbedfdc756e827c0cad49a43e68917487988b3c (commit) via 823ab34a0473db7f19cf665998afbb8763533ff1 (commit) from 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 1ffc3d262e82dca2cda7161d077daf504c83049d Merge: 40eb49471d238095a443b0bc52d02723130c2537 21a8e954408460987eb5c5b3c6005ed05ef205cb Author: Jan Kratochvil Date: Mon Mar 30 19:22:00 2009 +0200 Merge commit 'origin/archer-jankratochvil-misc' into archer commit 40eb49471d238095a443b0bc52d02723130c2537 Merge: 0d0dcd08bf84e52e3dd43b37a3b06eb2f934291d 0adf45a975c950b336e60ae9b6707a03b214cb08 Author: Jan Kratochvil Date: Mon Mar 30 19:21:55 2009 +0200 Merge commit 'origin/archer-jankratochvil-python' into archer commit 0d0dcd08bf84e52e3dd43b37a3b06eb2f934291d Merge: 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 6332d6a7d94e223d42f981701e703e549e36915b Author: Jan Kratochvil Date: Mon Mar 30 19:03:24 2009 +0200 Merge commit 'origin/archer-jankratochvil-misc' into archer ----------------------------------------------------------------------- Summary of changes: gdb/doc/gdb.texinfo | 41 +++--- gdb/dwarf2read.c | 2 +- gdb/python/python-frame.c | 59 ++++----- gdb/symtab.h | 8 +- gdb/testsuite/gdb.arch/powerpc-power7.exp | 25 +++- gdb/testsuite/gdb.base/nodebug.exp | 7 - gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c | 46 +++++++ gdb/testsuite/gdb.dwarf2/dw2-unresolved.S | 171 ++++++++++++++++++++++++ gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp | 41 ++++++ gdb/testsuite/gdb.python/python-frame.exp | 12 +- 10 files changed, 338 insertions(+), 74 deletions(-) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-unresolved.S create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c711d3d..63844a2 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19690,32 +19690,36 @@ separated by newlines. If there are no commands, this attribute is @cindex frames in python @tindex gdb.Frame @tindex Frame -When the debugged program stops, @value{GDBN} is able to analyse its call +When the debugged program stops, @value{GDBN} is able to analyze its call stack (@pxref{Frames,,Stack frames}). The @code{gdb.Frame} class represents a frame in the stack. A @code{gdb.Frame} object is only valid while its corresponding frame exists in the inferior's stack. If you try -to use an invalid frame object, a @code{RuntimeError} exception will be -thrown. +to use an invalid frame object, @value{GDBN} will throw a @code{RuntimeError} +exception. + +Two @code{gdb.Frame} objects can be compared for equality with the @code{==} +operator, like: + +@smallexample +(@value{GDBP}) python print gdb.newest_frame() == gdb.selected_frame () +True +@end smallexample The following frame-related functions are available in the @code{gdb} module: -@findex gdb.frames @defun frames Return a tuple containing all frame objects. @end defun -@findex gdb.newest_frame @defun newest_frame Return the newest frame object. @end defun -@findex gdb.selected_frame @defun selected_frame Return the selected frame object. (@pxref{Selection,,Selecting a Frame}). @end defun -@findex gdb.frame_stop_reason_string -@defun frame_stop_reason_string @var{reason} +@defun frame_stop_reason_string reason Return a string explaining the reason why @value{GDBN} stopped unwinding frames, as expressed by the given @var{reason} code (an integer, see the @code{unwind_stop_reason} method further down in this section). @@ -19724,15 +19728,11 @@ frames, as expressed by the given @var{reason} code (an integer, see the A @code{gdb.Frame} object has the following methods: @table @code -@defmethod Frame equals @code{frame} -Compare frames. -@end defmethod - @defmethod Frame is_valid Returns true if the @code{gdb.Frame} object is valid, false if not. A frame object can become invalid if the frame it refers to doesn't exist anymore in the inferior. All @code{gdb.Frame} methods will throw -an exception if it is invalid at the time the method call is made. +an exception if it is invalid at the time the method is called. @end defmethod @defmethod Frame name @@ -19741,15 +19741,16 @@ obtained. @end defmethod @defmethod Frame type -Returns the type of the frame. The value can be one of +Returns the type of the frame. The value can be one of @code{gdb.NORMAL_FRAME}, @code{gdb.DUMMY_FRAME}, @code{gdb.SIGTRAMP_FRAME} or @code{gdb.SENTINEL_FRAME}. @end defmethod @defmethod Frame unwind_stop_reason Return an integer representing the reason why it's not possible to find -frames older than this. Use @code{gdb.frame_stop_reason_string} to convert -the value returned by this function to a string. +more frames toward the outermost frame. Use +@code{gdb.frame_stop_reason_string} to convert the value returned by this +function to a string. @end defmethod @defmethod Frame pc @@ -19765,19 +19766,19 @@ Returns the symbol for the function corresponding to this frame. @c (@pxref{Symb @end defmethod @defmethod Frame older -Return the frame immediately older (outer) to this frame. +Return the frame that called this frame. @end defmethod @defmethod Frame newer -Return the frame immediately newer (inner) to this frame. +Return the frame called by this frame. @end defmethod @defmethod Frame find_sal Return the frame's symtab and line object. @c (@pxref{Symtab_and_line,, Symtab and line}). @end defmethod -@defmethod Frame read_var @var{variable} -Return the value of the given variable in this frame. @code{variable} can be +@defmethod Frame read_var variable +Return the value of the given variable in this frame. @var{variable} can be either a string or a @code{gdb.Symbol} object. @c (@pxref{Symbols In Python}). @end defmethod @end table diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 2ba61f4..625c416 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8367,7 +8367,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) && dwarf2_attr (die, DW_AT_type, cu) != NULL) { SYMBOL_CLASS (sym) = LOC_UNRESOLVED; - add_symbol_to_list (sym, &global_symbols); + add_symbol_to_list (sym, cu->list_in_scope); } else if (!die_is_declaration (die, cu)) { diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index 4b76709..6c33e65 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -109,31 +109,6 @@ frapy_is_valid (PyObject *self, PyObject *args) Py_RETURN_TRUE; } -/* Implementation of gdb.Frame.equals (self, other) -> Boolean. */ - -static PyObject * -frapy_equal_p (PyObject *self, PyObject *args) -{ - int equalp = 0; /* Initialize to appease gcc warning. */ - frame_object *self_frame = (frame_object *) self; - frame_object *other; - volatile struct gdb_exception except; - - if (!PyArg_ParseTuple (args, "O!", &frame_object_type, &other)) - return NULL; - - TRY_CATCH (except, RETURN_MASK_ALL) - { - equalp = frame_id_eq (self_frame->frame_id, other->frame_id); - } - GDB_PY_HANDLE_EXCEPTION (except); - - if (equalp) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; -} - /* Implementation of gdb.Frame.name (self) -> String. Returns the name of the function corresponding to this frame. */ @@ -581,6 +556,31 @@ gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args) return PyUnicode_Decode (str, strlen (str), host_charset (), NULL); } +/* Implements the equality comparison for Frame objects. + All other comparison operators will throw a TypeError Python exception, + as they aren't valid for frames. */ + +static PyObject * +frapy_richcompare (PyObject *self, PyObject *other, int op) +{ + if (!PyObject_TypeCheck (other, &frame_object_type)) + { + PyErr_SetString (PyExc_TypeError, "Frame object expected in comparison."); + return NULL; + } + else if (op != Py_EQ) + { + PyErr_SetString (PyExc_TypeError, "Invalid comparison for gdb.Frame."); + return NULL; + } + + if (frame_id_eq (((frame_object *) self)->frame_id, + ((frame_object *) other)->frame_id)) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; +} + /* Sets up the Frame API in the gdb module. */ void @@ -616,9 +616,6 @@ gdbpy_initialize_frames (void) static PyMethodDef frame_object_methods[] = { - { "equals", frapy_equal_p, METH_VARARGS, - "equals (frame) -> Boolean.\n\ -Compare this frame to the given frame." }, { "is_valid", frapy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\ Return true if this frame is valid, false if not." }, @@ -642,10 +639,10 @@ Return the frame's code block." }, Returns the symbol for the function corresponding to this frame." }, { "older", frapy_older, METH_NOARGS, "older () -> gdb.Frame.\n\ -Return the frame immediately older (outer) to this frame." }, +Return the frame that called this frame." }, { "newer", frapy_newer, METH_NOARGS, "newer () -> gdb.Frame.\n\ -Return the frame immetidaely newer (inner) to this frame." }, +Return the frame called by this frame." }, { "find_sal", frapy_find_sal, METH_NOARGS, "find_sal () -> gdb.Symtab_and_line.\n\ Return the frame's symtab and line." }, @@ -680,7 +677,7 @@ static PyTypeObject frame_object_type = { "GDB frame object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + frapy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 06bf7e8..801cd2b 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -472,7 +472,13 @@ enum address_class in another object file or runtime common storage. The linker might even remove the minimal symbol if the global symbol is never referenced, in which case the symbol remains - unresolved. */ + unresolved. + + GDB would normally find the symbol in the minimal symbol table if it will + not find it in the full symbol table. But a reference to an external + symbol in a local block shadowing other definition requires full symbol + without possibly having its address available for LOC_STATIC. Testcase + is provided as `gdb.dwarf2/dw2-unresolved.exp'. */ LOC_UNRESOLVED, diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.exp b/gdb/testsuite/gdb.arch/powerpc-power7.exp index d9c48f9..ae301db 100644 --- a/gdb/testsuite/gdb.arch/powerpc-power7.exp +++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp @@ -47,14 +47,23 @@ gdb_test_multiple $test $test { } } -proc func_check {offset instr} { +proc instr_to_patt {offset instr} { + # 0x0000000000000018 : stxvd2x vs43,r4,r5 + return ".*\r\n[string map {0x 0x0*} $offset] :\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" +} + +# KFAIL strings would not exist if -Many would print the same as -Mpower7. +# That means the power7 form should be the preferred one. +# http://sourceware.org/ml/gdb-patches/2009-03/threads.html#00020 + +proc func_check {offset instr {kfail ""}} { global func - # 0x0000000000000018 : stxvd2x vs43,r4,r5 - set patt ".*\r\n[string map {0x 0x0*} $offset] :\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" set test "Found $offset: $instr" - if [regexp -nocase -line $patt $func] { + if [regexp -nocase -line [instr_to_patt $offset $instr] $func] { pass $test + } elseif {$kfail != "" && [regexp -nocase -line [instr_to_patt $offset $kfail] $func]} { + kfail gdb/NNNN $test } else { fail $test } @@ -98,8 +107,8 @@ func_check 0x88 "sleep" func_check 0x8c "rvwinkle" func_check 0x90 "prtyw r3,r4" func_check 0x94 "prtyd r13,r14" -func_check 0x98 "mfcfar r10" -func_check 0x9c "mtcfar r11" +func_check 0x98 "mfcfar r10" "mfspr r10,28" +func_check 0x9c "mtcfar r11" "mtspr 28,r11" func_check 0xa0 "cmpb r3,r4,r5" func_check 0xa4 "lwzcix r10,r11,r12" func_check 0xa8 "dadd f16,f17,f18" @@ -143,8 +152,8 @@ func_check 0x13c "ftdiv cr0,f10,f11" func_check 0x140 "ftdiv cr7,f10,f11" func_check 0x144 "ftsqrt cr0,f10" func_check 0x148 "ftsqrt cr7,f10" -func_check 0x14c "dcbtt r8,r9" -func_check 0x150 "dcbtstt r8,r9" +func_check 0x14c "dcbtt r8,r9" "dcbt 16,r8,r9" +func_check 0x150 "dcbtstt r8,r9" "dcbtst 16,r8,r9" func_check 0x154 "dcffix f10,f12" func_check 0x158 "dcffix. f20,f22" func_check 0x15c "lbarx r10,r11,r12" diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 31fb88e..4c01be4 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -215,12 +215,5 @@ if [runto inner] then { if [runto middle] then { gdb_test "backtrace 10" "#0.*middle.*#1.*top.*#2.*main.*" \ "backtrace from middle in nodebug.exp" - - # Test return from a function with no debug info (symbol; still it may - # have a minimal-symbol). In gdb.base/return*.exp we would need to - # build a separate executable with no "debug" option. - gdb_test "return 0" "#0 .* top \\(.*" \ - "return from function with no debug info" \ - "Make selected stack frame return now\\? \\(y or n\\) " "y" } } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c new file mode 100644 index 0000000..c24eb96 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c @@ -0,0 +1,46 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +asm (".globl cu_text_start"); +asm ("cu_text_start:"); + +int +main (void) +{ + unsigned char var = 1; + + if (var != 1) + abort (); + { + extern unsigned char var; + + /* Do not rely on the `extern' DIE output by GCC (GCC PR debug/39563). */ +asm (".globl extern_block_start"); +asm ("extern_block_start:"); + if (var != 2) + abort (); +asm (".globl extern_block_end"); +asm ("extern_block_end:"); + } + + return 0; +} + +asm (".globl cu_text_end"); +asm ("cu_text_end:"); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S new file mode 100644 index 0000000..4c098f3 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S @@ -0,0 +1,171 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007, 2008, 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .data + +/* VAR1 is wrong here, in the real inferior it is located on stack. As both + places are never modified and they are initialized to the same value it + makes no difference. Ensure the name clash for "var". */ +var1: .byte 1 + + .globl var +var: .byte 2 + +/* Debug information */ + + .section .debug_info +.Lcu1_begin: + /* CU header */ + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ +.Lcu1_start: + .2byte 2 /* DWARF Version */ + .4byte .Labbrev1_begin /* Offset into abbrev section */ + .byte 4 /* Pointer size */ + + /* CU die */ + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ + .4byte cu_text_end /* DW_AT_high_pc */ + .4byte cu_text_start /* DW_AT_low_pc */ + .ascii "dw2-unresolved-main.c\0" /* DW_AT_name */ + .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ + .byte 1 /* DW_AT_language (C) */ + +.Ltype_uchar: + .uleb128 2 /* Abbrev: DW_TAG_base_type */ + .ascii "unsigned char\0" /* DW_AT_name */ + .byte 1 /* DW_AT_byte_size */ + .byte 7 /* DW_AT_encoding */ + + /* main */ + .uleb128 3 /* Abbrev: DW_TAG_subprogram */ + .byte 1 /* DW_AT_decl_file */ + .byte 2 /* DW_AT_decl_line */ + .ascii "main\0" /* DW_AT_name */ + .4byte .Ltype_uchar-.Lcu1_begin /* DW_AT_type */ + .4byte cu_text_start /* DW_AT_low_pc */ + .4byte cu_text_end /* DW_AT_high_pc */ + + .uleb128 4 /* Abbrev: DW_TAG_variable (location) */ + .ascii "var\0" /* DW_AT_name */ + .byte 2f - 1f /* DW_AT_location */ +1: .byte 3 /* DW_OP_addr */ +/* See VAR1 definition why this DIE is not correct. */ + .4byte var1 /* */ +2: .4byte .Ltype_uchar-.Lcu1_begin /* DW_AT_type */ + + .uleb128 6 /* Abbrev: DW_TAG_lexical_block */ + .4byte extern_block_start /* DW_AT_low_pc */ + .4byte extern_block_end /* DW_AT_high_pc */ + + .uleb128 5 /* Abbrev: DW_TAG_variable (extern) */ + .ascii "var\0" /* DW_AT_name */ + .4byte .Ltype_uchar-.Lcu1_begin /* DW_AT_type */ + .byte 1 /* DW_AT_external */ + + .byte 0 /* End of children of the lexical block */ + + .byte 0 /* End of children of main */ + + .byte 0 /* End of children of CU */ + +.Lcu1_end: + +/* Abbrev table */ + .section .debug_abbrev +.Labbrev1_begin: + .uleb128 1 /* Abbrev code */ + .uleb128 0x11 /* DW_TAG_compile_unit */ + .byte 1 /* has_children */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x25 /* DW_AT_producer */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x13 /* DW_AT_language */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 2 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 3 /* Abbrev code */ + .uleb128 0x2e /* DW_TAG_subprogram */ + .byte 1 /* has_children */ + .uleb128 0x3a /* DW_AT_decl_file */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3b /* DW_AT_decl_line */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .uleb128 0x11 /* DW_AT_low_pc */ hooks/post-receive -- Repository for Project Archer.