From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4322 invoked by alias); 23 May 2005 18:19:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 4122 invoked by uid 22791); 23 May 2005 18:19:08 -0000 Received: from norbert.ecoscentric.com (HELO smtp.ecoscentric.com) (194.153.168.165) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 23 May 2005 18:19:08 +0000 Received: by smtp.ecoscentric.com (Postfix, from userid 99) id 6E0B365C102; Mon, 23 May 2005 19:19:06 +0100 (BST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by smtp.ecoscentric.com (Postfix) with ESMTP id E7ECA65C064 for ; Mon, 23 May 2005 19:19:04 +0100 (BST) Message-ID: <42921E98.7010703@eCosCentric.com> Date: Mon, 23 May 2005 19:38:00 -0000 From: Jonathan Larmour User-Agent: Mozilla Thunderbird 1.0.2-1.3.3 (X11/20050513) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: frame.c backtrace limit issue and fix Content-Type: multipart/mixed; boundary="------------000606070007080102010800" X-SW-Source: 2005-05/txt/msg00518.txt.bz2 This is a multi-part message in MIME format. --------------000606070007080102010800 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1369 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 * 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 --------------000606070007080102010800 Content-Type: text/x-patch; name="gdb-btlimit-6.3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-btlimit-6.3.patch" Content-length: 3114 --- 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, --------------000606070007080102010800--