Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [SH][PATCH] Disable ABI frame sniffer
@ 2005-11-09 18:08 Andrew STUBBS
  2005-11-10  0:17 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Andrew STUBBS @ 2005-11-09 18:08 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]

Hi,

The attached patch adds a new sh-specific command:

set backtrace abi-sniffer

This command allows the ABI frame sniffer to be disabled. The default 
state remains 'on', as it is now.

It is useful to disable this sniffer because it has an irritating habit 
of causing (non-fatal) errors when it runs out of frames. Specifically 
it often says 'Previous frame identical to this frame (corrupt stack?)'.

This message is worrying if you do not know what it means, but it is 
normally easily ignored. Unfortunately, the problem is more serious when 
used in conjunction with 'thread apply' as the first error kills the 
output from the rest of the threads. This command is used by some GUIs 
to populate their displays.

It is difficult to see how the ABI sniffer can be made more robust 
(although I have not looked into it in great detail), and it certainly 
can't be made totally reliable, so the best option would seem to be to 
disable it altogether.

With the ABI sniffer 'off' it is not possible to backtrace through code 
that does not have CFI. On sh-elf, at least, there is always CFI when 
there is debug info, so it is relatively rare that the ABI sniffer is 
actually required.

I have not set the default to 'off' because that causes quite a number 
of FAILs in the testsuite.

Is this all OK?

Thanks

Andrew Stubbs

[-- Attachment #2: abi_sniffer.patch --]
[-- Type: text/plain, Size: 4448 bytes --]

2005-11-09  Andrew Stubbs  <andrew.stubbs@st.com>

	* sh-tdep.c (backtrace_abi_sniffer): New variable.
	(sh_frame_this_id): Do nothing if backtrace_abi_sniffer zero.
	(sh_gdbarch_init): Add set/show abi-sniffer command.
	* frame.c (set_backtrace_cmdlist): Remove static.
	(show_backtrace_cmdlist): Likewise.
	* frame.h (set_backtrace_cmdlist): Add extern declaration.
	(show_backtrace_cmdlist): Likewise.

doc/
	* gdb.texinfo (Super-H): Add 'set/show backtrace abi-sniffer'.

Index: src/gdb/sh-tdep.c
===================================================================
--- src.orig/gdb/sh-tdep.c	2005-11-01 11:43:29.000000000 +0000
+++ src/gdb/sh-tdep.c	2005-11-01 12:26:24.000000000 +0000
@@ -2377,12 +2377,18 @@ sh_frame_prev_register (struct frame_inf
     frame_unwind_register (next_frame, (*realnump), valuep);
 }
 
+static int backtrace_abi_sniffer = 1;
+
 static void
 sh_frame_this_id (struct frame_info *next_frame, void **this_cache,
 		  struct frame_id *this_id)
 {
   struct sh_frame_cache *cache = sh_frame_cache (next_frame, this_cache);
 
+  /* Is this sniffer enabled? */
+  if (!backtrace_abi_sniffer)
+    return;
+
   /* This marks the outermost frame.  */
   if (cache->base == 0)
     return;
@@ -2726,6 +2732,22 @@ sh_gdbarch_init (struct gdbarch_info inf
   frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
   frame_unwind_append_sniffer (gdbarch, sh_frame_sniffer);
 
+  add_setshow_boolean_cmd ("abi-sniffer", class_obscure,
+                           &backtrace_abi_sniffer, "\
+Set whether backtraces should use the ABI where there is no debug info.", "\
+Show whether backtraces should use the ABI where there is no debug info.", "\
+Normally there is debug information from which to construct a backtrace\n\
+but sometimes is is not available (e.g. in assembly code). In this case the\n\
+ABI sniffer can attempt to construct a backtrace. It is disabled by default\n\
+because it can cause inconvenient errors. Note that it does not disable the\n\
+Dwarf debug information sniffer.",
+                           NULL, NULL, &set_backtrace_cmdlist,
+                           &show_backtrace_cmdlist);
+
+#ifdef SVR4_SHARED_LIBS
+  set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+#endif
+
   return gdbarch;
 }
 
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c	2005-11-01 11:16:55.000000000 +0000
+++ src/gdb/frame.c	2005-11-01 11:43:29.000000000 +0000
@@ -1558,8 +1558,8 @@ frame_sp_unwind (struct frame_info *next
 
 extern initialize_file_ftype _initialize_frame; /* -Wmissing-prototypes */
 
-static struct cmd_list_element *set_backtrace_cmdlist;
-static struct cmd_list_element *show_backtrace_cmdlist;
+struct cmd_list_element *set_backtrace_cmdlist;
+struct cmd_list_element *show_backtrace_cmdlist;
 
 static void
 set_backtrace_cmd (char *args, int from_tty)
Index: src/gdb/frame.h
===================================================================
--- src.orig/gdb/frame.h	2005-11-01 11:16:55.000000000 +0000
+++ src/gdb/frame.h	2005-11-01 11:43:29.000000000 +0000
@@ -660,4 +660,9 @@ extern void deprecated_update_frame_pc_h
 extern void deprecated_update_frame_base_hack (struct frame_info *frame,
 					       CORE_ADDR base);
 
+/* Export 'set backtrace' so that new subcommands may be added elsewhere. */
+
+extern struct cmd_list_element *set_backtrace_cmdlist;
+extern struct cmd_list_element *show_backtrace_cmdlist;
+
 #endif /* !defined (FRAME_H)  */
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2005-11-01 11:43:29.000000000 +0000
+++ src/gdb/doc/gdb.texinfo	2005-11-01 12:56:00.000000000 +0000
@@ -14790,8 +14790,21 @@ commands:
 @item regs
 @kindex regs@r{, Super-H}
 Show the values of all Super-H registers.
+
+@item set backtrace abi-sniffer
+@kindex set backtrace abi-sniffer
+This command enables or disables the SH ABI-based frame sniffer. This
+`sniffer' attempts to find the frames of a backtrace when there is no
+debug information (specifically CFI) to do the job properly. Sniffing
+frames is problematic so it is often best to switch this @samp{off}. It
+is @samp{on} by default.
+
+@item show backtrace abi-sniffer
+@kindex show backtrace abi-sniffer
+Show whether the abi-sniffer is enabled, or not.
 @end table
 
+
 @node WinCE
 @subsection Windows CE
 @cindex Windows CE

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

end of thread, other threads:[~2005-11-24 18:11 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-09 18:08 [SH][PATCH] Disable ABI frame sniffer Andrew STUBBS
2005-11-10  0:17 ` Andreas Schwab
2005-11-10  3:30   ` Daniel Jacobowitz
2005-11-10 12:27     ` Andrew STUBBS
2005-11-10 14:24       ` Daniel Jacobowitz
2005-11-10  4:27 ` Daniel Jacobowitz
2005-11-10 13:36   ` Andrew STUBBS
2005-11-10 14:34     ` Daniel Jacobowitz
2005-11-10 23:09       ` Andrew STUBBS
2005-11-10 23:13         ` Andrew STUBBS
2005-11-11  0:10         ` Mark Kettenis
2005-11-11 10:31           ` Daniel Jacobowitz
2005-11-11 18:21           ` Andrew STUBBS
2005-11-11 10:35         ` Daniel Jacobowitz
2005-11-11 20:09           ` Andrew STUBBS
2005-11-13 18:57             ` Daniel Jacobowitz
2005-11-13 23:58               ` Jim Blandy
2005-11-23 19:52               ` Andrew STUBBS
2005-11-24 22:48                 ` Andrew STUBBS
2005-11-24 23:42                   ` Mark Kettenis
2005-11-10 11:11 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox