From: Jonathan Larmour <jifl@eCosCentric.com>
To: gdb-patches@sources.redhat.com
Subject: frame.c backtrace limit issue and fix
Date: Mon, 23 May 2005 19:38:00 -0000 [thread overview]
Message-ID: <42921E98.7010703@eCosCentric.com> (raw)
[-- 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,
next reply other threads:[~2005-05-23 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-23 19:38 Jonathan Larmour [this message]
2005-05-28 23:09 ` Daniel Jacobowitz
2005-05-29 1:59 ` Jonathan Larmour
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=42921E98.7010703@eCosCentric.com \
--to=jifl@ecoscentric.com \
--cc=gdb-patches@sources.redhat.com \
/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