From: Roland Schwingel <roland@onevision.com>
To: insight@sourceware.org
Subject: [PATCH/gdbtk] Update stackwin gdb api usage
Date: Mon, 02 Apr 2012 15:21:00 -0000 [thread overview]
Message-ID: <4F79C3F2.3020908@onevision.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2292 bytes --]
Hi...
Here is a new patch from my side for insight. It adresses 2 issues.
The small one first:
In the tcl code of the stackwindow there is an instance variable
maxwidth which is calculated but never used somewhere. My patch dares to
remove it.
The bigger one:
I am frequently seeing output in insight on windows 64 bit:
(Internal error: pc 0x0 in read in psymtab, but not in symtab.)
Especially when debugging objectiveC code but can also see in sometimes
when debugging plain c. This is triggered by stack unwinding (showing
stack window in insight). I tracked it down to 2 problems. One of it is
in insight itself and fixed with this patch.
The C code of insight dealing with the backtrace generation was made
somewhere in 2001 and remainded largely unchanged since then. It was
initially "inspired" by the code directly in gdb. GDB has changed since
then in that area. I updated insight's C code for generating the
backtrace for the tcl part to match again gdb's code in stack.c. I could
remove a bigger bunch of insight's private code in that area and replace
it directly with a call to find_frame_funname() of gdb itself. I also
removed some dead code here.
From what I could see now insight no longer genarates this error
message directly. I could still trigger it in some situations by just
issuing a "bt" from either insight's console or from within native gdb.
I have to dive into that. But with this patch insight itself should be
clean now in this regard.
I also updated copyright informations in the affected files.
Changelog:
2012-04-02 Roland Schwingel <roland.schwingel@onevision.com>
* generic/gdbtk-stack.c: Updated copyright informations.
include "stack.h" and "solib.h" (when needed).
(gdb_stack): Some reformatting.
(get_frame_name): Updated usage of gdb api for
backtrace generation. Some reformatting. Removed
dead code. Also handle frame type ARCH_FRAME now.
* library/stackwin.it[bh]: Remove dead instance
variable maxwidth. Updated copyright informations.
A general question:
The direction of stack dump in insight is opposite to when issueing a
backtrace inside gdb itself. Is this on purpose? Wouldn't it be nicer
when insight's stack window would show the stack in the same order?
Any comments? Is this ok?
Roland
[-- Attachment #2: stackwin.patch --]
[-- Type: text/plain, Size: 7022 bytes --]
diff -ruNp gdbtk_orig/generic/gdbtk-stack.c gdbtk/generic/gdbtk-stack.c
--- gdbtk_orig/generic/gdbtk-stack.c 2012-03-30 09:29:15.000000000 +0200
+++ gdbtk/generic/gdbtk-stack.c 2012-04-02 16:13:11.351540500 +0200
@@ -1,5 +1,6 @@
/* Tcl/Tk command definitions for Insight - Stack.
- Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2008, 2011
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -26,6 +27,10 @@
#include "dictionary.h"
#include "varobj.h"
#include "arch-utils.h"
+#include "stack.h"
+#ifndef PC_SOLIB
+#include "solib.h"
+#endif
#include <tcl.h>
#include "gdbtk.h"
@@ -475,24 +480,24 @@ gdb_stack (ClientData clientData, Tcl_In
/* Find the outermost frame */
r = GDB_get_current_frame (&fi);
if (r != GDB_OK)
- return TCL_ERROR;
+ return TCL_ERROR;
while (fi != NULL)
{
top = fi;
- r = GDB_get_prev_frame (fi, &fi);
- if (r != GDB_OK)
- fi = NULL;
+ r = GDB_get_prev_frame (fi, &fi);
+ if (r != GDB_OK)
+ fi = NULL;
}
+ result_ptr->obj_ptr = Tcl_NewListObj (0, NULL);
+
/* top now points to the top (outermost frame) of the
stack, so point it to the requested start */
start = -start;
- r = GDB_find_relative_frame (top, &start, &top);
-
- result_ptr->obj_ptr = Tcl_NewListObj (0, NULL);
+ r = GDB_find_relative_frame (top, &start, &top);
if (r != GDB_OK)
- return TCL_OK;
+ return TCL_OK;
/* If start != 0, then we have asked to start outputting
frames beyond the innermost stack frame */
@@ -503,8 +508,8 @@ gdb_stack (ClientData clientData, Tcl_In
{
get_frame_name (interp, result_ptr->obj_ptr, fi);
r = GDB_get_next_frame (fi, &fi);
- if (r != GDB_OK)
- break;
+ if (r != GDB_OK)
+ break;
}
}
}
@@ -515,14 +520,14 @@ gdb_stack (ClientData clientData, Tcl_In
/* A helper function for get_stack which adds information about
* the stack frame FI to the caller's LIST.
*
- * This is stolen from print_frame_info in stack.c.
+ * This is stolen from print_frame_info/print_frame in stack.c.
*/
+
static void
get_frame_name (Tcl_Interp *interp, Tcl_Obj *list, struct frame_info *fi)
{
- struct symtab_and_line sal;
struct symbol *func = NULL;
- const char *funname = 0;
+ const char *funname = NULL;
enum language funlang = language_unknown;
Tcl_Obj *objv[1];
@@ -532,75 +537,39 @@ get_frame_name (Tcl_Interp *interp, Tcl_
Tcl_ListObjAppendElement (interp, list, objv[0]);
return;
}
- if ((get_frame_type (fi) == SIGTRAMP_FRAME))
+ if (get_frame_type (fi) == SIGTRAMP_FRAME)
{
objv[0] = Tcl_NewStringObj ("<signal handler called>", -1);
Tcl_ListObjAppendElement (interp, list, objv[0]);
return;
}
-
- sal =
- find_pc_line (get_frame_pc (fi),
- get_next_frame (fi) != NULL
- && !(get_frame_type (fi) == SIGTRAMP_FRAME)
- && !(get_frame_type (fi) == DUMMY_FRAME));
-
- func = find_pc_function (get_frame_pc (fi));
- if (func)
- {
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
- if (msymbol != NULL
- && (SYMBOL_VALUE_ADDRESS (msymbol)
- > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
- {
- func = 0;
- funname = GDBTK_SYMBOL_SOURCE_NAME (msymbol);
- funlang = SYMBOL_LANGUAGE (msymbol);
- }
- else
- {
- funname = GDBTK_SYMBOL_SOURCE_NAME (func);
- funlang = SYMBOL_LANGUAGE (func);
- }
- }
- else
+ if (get_frame_type (fi) == ARCH_FRAME)
{
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
- if (msymbol != NULL)
- {
- funname = GDBTK_SYMBOL_SOURCE_NAME (msymbol);
- funlang = SYMBOL_LANGUAGE (msymbol);
- }
+ objv[0] = Tcl_NewStringObj ("<cross-architecture call>", -1);
+ Tcl_ListObjAppendElement (interp, list, objv[0]);
+ return;
}
- if (sal.symtab)
+ find_frame_funname (fi, &funname, &funlang, &func);
+
+ if (funname)
{
objv[0] = Tcl_NewStringObj (funname, -1);
Tcl_ListObjAppendElement (interp, list, objv[0]);
}
else
{
-#if 0
- /* we have no convenient way to deal with this yet... */
- if (fi->pc != sal.pc || !sal.symtab)
- {
- deprecated_print_address_numeric (fi->pc, 1, gdb_stdout);
- printf_filtered (" in ");
- }
- printf_symbol_filtered (gdb_stdout, funname ? funname : "??", funlang,
- DMGL_ANSI);
-#endif
- objv[0] = Tcl_NewStringObj (funname != NULL ? funname : "??", -1);
+ char *lib = NULL;
+ objv[0] = Tcl_NewStringObj (funname ? funname : "??", -1);
#ifdef PC_SOLIB
- if (!funname)
- {
- char *lib = PC_SOLIB (get_frame_pc (fi));
- if (lib)
- {
- Tcl_AppendStringsToObj (objv[0], " from ", lib, (char *) NULL);
- }
- }
+ lib = PC_SOLIB (get_frame_pc (fi));
+#else
+ lib = solib_name_from_address (get_frame_program_space (fi),
+ get_frame_pc (fi));
#endif
+ if (lib)
+ Tcl_AppendStringsToObj (objv[0], " from ", lib, (char *) NULL);
+
Tcl_ListObjAppendElement (interp, list, objv[0]);
}
}
diff -ruNp gdbtk_orig/library/stackwin.itb gdbtk/library/stackwin.itb
--- gdbtk_orig/library/stackwin.itb 2008-02-09 02:23:42.000000000 +0100
+++ gdbtk/library/stackwin.itb 2012-04-02 09:40:19.507691900 +0200
@@ -1,5 +1,5 @@
# Stack window for Insight.
-# Copyright (C) 1997, 1998, 1999, 2002, 2003, 2008 Red Hat
+# Copyright (C) 1997-2012 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
@@ -68,20 +68,14 @@ itcl::body StackWin::update {event} {
set frames {}
}
+ $itk_component(slb) delete 0 end
if {[llength $frames] == 0} {
- $itk_component(slb) delete 0 end
$itk_component(slb) insert end {NO STACK}
return
}
- $itk_component(slb) delete 0 end
set levels 0
foreach frame $frames {
- set len [string length $frame]
-
- if {$len > $maxwidth} {
- set maxwidth $len
- }
$itk_component(slb) insert end $frame
incr levels
}
diff -ruNp gdbtk_orig/library/stackwin.ith gdbtk/library/stackwin.ith
--- gdbtk_orig/library/stackwin.ith 2005-12-23 19:26:50.000000000 +0100
+++ gdbtk/library/stackwin.ith 2012-04-02 09:40:23.623824000 +0200
@@ -1,5 +1,5 @@
# Stack window class definition for GDBtk.
-# Copyright (C) 1997, 1998, 1999 Cygnus Solutions
+# Copyright (C) 1997-2012 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
@@ -20,7 +20,6 @@ itcl::class StackWin {
inherit EmbeddedWin GDBWin
private {
- variable maxwidth 40
variable Running 0
variable protect_me 0
method build_win {}
next reply other threads:[~2012-04-02 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-02 15:21 Roland Schwingel [this message]
2012-05-24 1:12 ` Keith Seitz
2012-05-25 10:23 Roland Schwingel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F79C3F2.3020908@onevision.com \
--to=roland@onevision.com \
--cc=insight@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).