Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* frame.c backtrace limit issue and fix
@ 2005-05-23 19:38 Jonathan Larmour
  2005-05-28 23:09 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Larmour @ 2005-05-23 19:38 UTC (permalink / raw)
  To: gdb-patches

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

On my embedded m68k target, where debugging appears problematic, sometimes 
frames called in frame.c:get_prev_frame() have their frame level set to 
-1. If you have a backtrace limit set (with "set backtrace limit") then 
this would mean the following test is done:


   if (this_frame->level > backtrace_limit)
     {
       error ("Backtrace limit of %d exceeded", backtrace_limit);
     }

This looks like it would be right even if the level is -1. However 
backtrace_limit is unsigned and this results in this_frame->level being 
promoted to an unsigned 0xffffffff value.

Therefore I'm attaching a patch to correct this, simply by making 
backtrace_limit now be signed. Anyone who needs more than 2 billion stack 
levels has bigger problems :-).

I do have write access so can check this in if someone approves.

Jifl

2005-05-23  Jonathan Larmour  <jifl@eCosCentric.com>

	* command.h: Declare new add_setshow_integer_cmd function.
	* cli/cli-decode.c (add_setshow_integer_cmd): New function. Cloned
	from add_setshow_uinteger_cmd.
	* frame.c: backtrace_limit should be signed to prevent matching against
	negative frame levels.
	(_initialize_frame): Call add_setshow_integer_cmd for backtrace limit
	now.



-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine

[-- Attachment #2: gdb-btlimit-6.3.patch --]
[-- Type: text/x-patch, Size: 3114 bytes --]

--- command.h.old	2004-07-28 20:42:00.000000000 +0100
+++ command.h	2005-05-23 19:00:44.000000000 +0100
@@ -270,6 +270,18 @@
 				    struct cmd_list_element **set_list,
 				    struct cmd_list_element **show_list);
 
+extern void add_setshow_integer_cmd (char *name,
+				     enum command_class class,
+				     int *var,
+				     const char *set_doc,
+				     const char *show_doc,
+				     const char *help_doc,
+				     const char *print,
+				     cmd_sfunc_ftype *set_func,
+				     cmd_sfunc_ftype *show_func,
+				     struct cmd_list_element **set_list,
+				     struct cmd_list_element **show_list);
+
 extern void add_setshow_uinteger_cmd (char *name,
 				      enum command_class class,
 				      unsigned int *var,
--- frame.c.old	2005-05-23 18:08:02.000000000 +0100
+++ frame.c	2005-05-23 19:08:25.000000000 +0100
@@ -115,7 +115,7 @@
 /* Flag to indicate whether backtraces should stop at main et.al.  */
 
 static int backtrace_past_main;
-static unsigned int backtrace_limit = UINT_MAX;
+static int backtrace_limit = INT_MAX;
 
 static void
 fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR addr)
@@ -1525,15 +1525,15 @@
 			   NULL, NULL, &set_backtrace_cmdlist,
 			   &show_backtrace_cmdlist);
 
-  add_setshow_uinteger_cmd ("limit", class_obscure,
-			    &backtrace_limit, "\
+  add_setshow_integer_cmd ("limit", class_obscure,
+			   &backtrace_limit, "\
 Set an upper bound on the number of backtrace levels.", "\
 Show the upper bound on the number of backtrace levels.", "\
 No more than the specified number of frames can be displayed or examined.\n\
 Zero is unlimited.", "\
 An upper bound on the number of backtrace levels is %s.",
-			    NULL, NULL, &set_backtrace_cmdlist,
-			    &show_backtrace_cmdlist);
+			   NULL, NULL, &set_backtrace_cmdlist,
+			   &show_backtrace_cmdlist);
 
   /* Debug this files internals. */
   deprecated_add_show_from_set
--- cli/cli-decode.c.old	2004-07-30 18:55:47.000000000 +0100
+++ cli/cli-decode.c	2005-05-23 19:00:03.000000000 +0100
@@ -493,6 +493,27 @@
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
 void
+add_setshow_integer_cmd (char *name, enum command_class class,
+			  int *var,
+			  const char *set_doc, const char *show_doc,
+			  const char *help_doc, const char *print,
+			  cmd_sfunc_ftype *set_func,
+			  cmd_sfunc_ftype *show_func,
+			  struct cmd_list_element **set_list,
+			  struct cmd_list_element **show_list)
+{
+  add_setshow_cmd_full (name, class, var_integer, var,
+			set_doc, show_doc, help_doc, print,
+			set_func, show_func,
+			set_list, show_list,
+			NULL, NULL);
+}
+
+/* Add element named NAME to both the set and show command LISTs (the
+   list for set/show or some sublist thereof).  CLASS is as in
+   add_cmd.  VAR is address of the variable which will contain the
+   value.  SET_DOC and SHOW_DOC are the documentation strings.  */
+void
 add_setshow_uinteger_cmd (char *name, enum command_class class,
 			  unsigned int *var,
 			  const char *set_doc, const char *show_doc,

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

end of thread, other threads:[~2005-05-28 23:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-23 19:38 frame.c backtrace limit issue and fix Jonathan Larmour
2005-05-28 23:09 ` Daniel Jacobowitz
2005-05-29  1:59   ` Jonathan Larmour

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