public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [commit] Fix internal error in TUI
@ 2010-03-20  5:20 Daniel Jacobowitz
  2010-03-20 16:17 ` Tom Tromey
  2010-05-24 20:40 ` [patch] testsuite: New TUI internal error testcase [Re: [commit] Fix internal error in TUI] Jan Kratochvil
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2010-03-20  5:20 UTC (permalink / raw)
  To: gdb-patches

This patch is for Debian bug #568489.

If you start gdb with a file, but no running program, and hit C-x 2 to
switch into TUI mode, GDB crashes.  There's a NULL gdbarch which gets
passed to various gdbarch routines.

I spent a while poring over the gdbarch management in TUI, and found
it quite confusing.  This seems like the best fix.  Part of this could
be improved, in theory, by looking up the architecture associated with
"main"; but in practice, get_current_arch will match main when the
program is not yet running.  Later on, there's an explicit gdbarch.

Tested on x86_64-linux and committed.

-- 
Daniel Jacobowitz
CodeSourcery

2010-03-20  Daniel Jacobowitz  <dan@codesourcery.com>

	* tui/tui-disasm.c (tui_get_begin_asm_address): Default to
	get_current_arch.
	* tui/tui-layout.c (extract_display_start_addr): Likewise.

Index: tui/tui-disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-disasm.c,v
retrieving revision 1.33
diff -u -p -r1.33 tui-disasm.c
--- tui/tui-disasm.c	1 Jan 2010 07:32:07 -0000	1.33
+++ tui/tui-disasm.c	20 Mar 2010 04:17:05 -0000
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "symtab.h"
 #include "breakpoint.h"
 #include "frame.h"
@@ -330,7 +331,7 @@ tui_get_begin_asm_address (struct gdbarc
 {
   struct tui_gen_win_info *locator;
   struct tui_locator_element *element;
-  struct gdbarch *gdbarch = NULL;
+  struct gdbarch *gdbarch = get_current_arch ();
   CORE_ADDR addr;
 
   locator = tui_locator_win_info_ptr ();
Index: tui/tui-layout.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-layout.c,v
retrieving revision 1.36
diff -u -p -r1.36 tui-layout.c
--- tui/tui-layout.c	1 Jan 2010 07:32:07 -0000	1.36
+++ tui/tui-layout.c	20 Mar 2010 04:17:05 -0000
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "command.h"
 #include "symtab.h"
 #include "frame.h"
@@ -522,7 +523,7 @@ static void
 extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 {
   enum tui_layout_type cur_layout = tui_current_layout ();
-  struct gdbarch *gdbarch = NULL;
+  struct gdbarch *gdbarch = get_current_arch ();
   CORE_ADDR addr;
   CORE_ADDR pc;
   struct symtab_and_line cursal = get_current_source_symtab_and_line ();

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commit] Fix internal error in TUI
  2010-03-20  5:20 [commit] Fix internal error in TUI Daniel Jacobowitz
@ 2010-03-20 16:17 ` Tom Tromey
  2010-05-24 20:40 ` [patch] testsuite: New TUI internal error testcase [Re: [commit] Fix internal error in TUI] Jan Kratochvil
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2010-03-20 16:17 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

>>>>> "Daniel" == Daniel Jacobowitz <dan@codesourcery.com> writes:

Daniel> This patch is for Debian bug #568489.
Daniel> If you start gdb with a file, but no running program, and hit C-x 2 to
Daniel> switch into TUI mode, GDB crashes.  There's a NULL gdbarch which gets
Daniel> passed to various gdbarch routines.

This also sounds like http://sourceware.org/bugzilla/show_bug.cgi?id=10771

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch] testsuite: New TUI internal error testcase  [Re: [commit] Fix internal error in TUI]
  2010-03-20  5:20 [commit] Fix internal error in TUI Daniel Jacobowitz
  2010-03-20 16:17 ` Tom Tromey
@ 2010-05-24 20:40 ` Jan Kratochvil
  2010-05-27 20:08   ` Tom Tromey
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2010-05-24 20:40 UTC (permalink / raw)
  To: gdb-patches

Hi,

the fix was:
	[commit] Fix internal error in TUI
	http://sourceware.org/ml/gdb-patches/2010-03/msg00746.html
	http://sourceware.org/ml/gdb-cvs/2010-03/msg00194.html

It turns
FAIL: gdb.base/tui-layout.exp: layout asm (GDB internal error)
into a PASS.

I had to write it anyway.


Thanks,
Jan

2010-05-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/tui-layout.exp: New.

--- /dev/null	2010-05-24 04:43:32.632794021 +0200
+++ gdb-7.1/gdb/testsuite/gdb.base/tui-layout.exp	2010-05-24 20:13:30.000000000 +0200
@@ -0,0 +1,21 @@
+# Copyright 2010 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 <http://www.gnu.org/licenses/>.
+
+set testfile tui-layout
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c] } {
+    return -1
+}
+
+gdb_test "layout asm"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] testsuite: New TUI internal error testcase  [Re: [commit] Fix internal error in TUI]
  2010-05-24 20:40 ` [patch] testsuite: New TUI internal error testcase [Re: [commit] Fix internal error in TUI] Jan Kratochvil
@ 2010-05-27 20:08   ` Tom Tromey
  2010-05-28 18:52     ` Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2010-05-27 20:08 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> 2010-05-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	* gdb.base/tui-layout.exp: New.

This is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] testsuite: New TUI internal error testcase  [Re: [commit] Fix internal error in TUI]
  2010-05-27 20:08   ` Tom Tromey
@ 2010-05-28 18:52     ` Jan Kratochvil
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2010-05-28 18:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, 27 May 2010 21:58:27 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> 2010-05-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	* gdb.base/tui-layout.exp: New.
> 
> This is ok.  Thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-05/msg00246.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-28 18:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-20  5:20 [commit] Fix internal error in TUI Daniel Jacobowitz
2010-03-20 16:17 ` Tom Tromey
2010-05-24 20:40 ` [patch] testsuite: New TUI internal error testcase [Re: [commit] Fix internal error in TUI] Jan Kratochvil
2010-05-27 20:08   ` Tom Tromey
2010-05-28 18:52     ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).