From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23801 invoked by alias); 26 Jul 2003 01:48:53 -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 23794 invoked from network); 26 Jul 2003 01:48:50 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 26 Jul 2003 01:48:50 -0000 Received: from drow by nevyn.them.org with local (Exim 4.20 #1 (Debian)) id 19gEAv-0004wj-Rw; Fri, 25 Jul 2003 21:48:45 -0400 Date: Sat, 26 Jul 2003 01:48:00 -0000 From: Daniel Jacobowitz To: Andrew Cagney Cc: gdb-patches@sources.redhat.com, amichelotti@ipitec.it, Michael Snyder Subject: Re: patch for info threads problem with target arm-elf (PR 1199). Message-ID: <20030726014845.GA18738@nevyn.them.org> Mail-Followup-To: Andrew Cagney , gdb-patches@sources.redhat.com, amichelotti@ipitec.it, Michael Snyder References: <3F200D12.6000103@ipitec.it> <3F21CAA4.30400@redhat.com> <20030726002921.GA5573@nevyn.them.org> <3F21D8BE.8050401@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F21D8BE.8050401@redhat.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2003-07/txt/msg00459.txt.bz2 On Fri, Jul 25, 2003 at 09:26:22PM -0400, Andrew Cagney wrote: > >On Fri, Jul 25, 2003 at 05:26:12PM -0700, Michael Snyder wrote: > > > >>Andrea Michelotti wrote: > >> > > > >>>----------------------- > >>>Andrea Michelotti > >>>HW/SW Co-Design Manager > >>>IPITEC (ATMEL) > > > >> > >> > >>I think it can be approved. Do you have an FSF copyright assignment? > > > > > >I'd want to ping Andrew about this first before scattering NULL pointer > >checks - Andrew, does "there is always a frame" include when the > >inferior does not exist yet? > > Kind of :-) If the inferior doesn't exist, GDB should never get to find > out the answer. See get_current_frame and all those error() checks. > > >Also, I think a better solution to this actual crash is for info > >threads to bail out early if we don't have an inferior. Probably > >target_has_registers (). > > Yes, looking at the start of info_threads_command: > > > static void > >info_threads_command (char *arg, int from_tty) > >{ > > struct thread_info *tp; > > ptid_t current_ptid; > > struct frame_info *cur_frame; > > int saved_frame_level = frame_relative_level (deprecated_selected_frame); > > int counter; > > char *extra_info; > > > > /* Avoid coredumps which would happen if we tried to access a NULL > > deprecated_selected_frame. */ > > if (!target_has_stack) > > error ("No stack."); > > The references to: > > deprecated_selected_frame > > should have set off alarm bells! > > A quick fix would be to call get_selected_frame() (and delete that error > check). Note the access to deprecated_selected_frame above the check :) OK, this isn't the thorough fix, but how's this look? Andrea, does this work with Eclipse in place of your patch? -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2003-07-25 Daniel Jacobowitz * thread.c (info_threads_command): Use get_selected_frame (). Check that there is at least one non-sentinel frame. Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.31 diff -u -p -r1.31 thread.c --- thread.c 5 May 2003 00:27:08 -0000 1.31 +++ thread.c 26 Jul 2003 01:47:08 -0000 @@ -417,14 +417,14 @@ info_threads_command (char *arg, int fro struct thread_info *tp; ptid_t current_ptid; struct frame_info *cur_frame; - int saved_frame_level = frame_relative_level (deprecated_selected_frame); + int saved_frame_level = frame_relative_level (get_selected_frame ()); int counter; char *extra_info; - /* Avoid coredumps which would happen if we tried to access a NULL - deprecated_selected_frame. */ - if (!target_has_stack) - error ("No stack."); + /* Check that there really is a frame. This happens when a simulator + is connected but not loaded or running, for instance. */ + if (saved_frame_level < 0) + error ("No frame."); prune_threads (); target_find_new_threads (); @@ -448,10 +448,7 @@ info_threads_command (char *arg, int fro puts_filtered (" "); switch_to_thread (tp->ptid); - if (deprecated_selected_frame) - print_stack_frame (deprecated_selected_frame, -1, 0); - else - printf_filtered ("[No stack.]\n"); + print_stack_frame (get_selected_frame (), -1, 0); } switch_to_thread (current_ptid); @@ -463,12 +460,12 @@ info_threads_command (char *arg, int fro * of the stack (leaf frame). */ counter = saved_frame_level; - cur_frame = find_relative_frame (deprecated_selected_frame, &counter); + cur_frame = find_relative_frame (get_selected_frame (), &counter); if (counter != 0) { /* Ooops, can't restore, tell user where we are. */ warning ("Couldn't restore frame in current thread, at frame 0"); - print_stack_frame (deprecated_selected_frame, -1, 0); + print_stack_frame (get_selected_frame (), -1, 0); } else {