From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11924 invoked by alias); 16 May 2005 22:02:51 -0000 Mailing-List: contact insight-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sources.redhat.com Received: (qmail 11719 invoked from network); 16 May 2005 22:02:36 -0000 Received: from unknown (HELO steven) (202.80.36.173) by sourceware.org with SMTP; 16 May 2005 22:02:36 -0000 Received: from sakuraindustries.com (localhost [127.0.0.1]) by steven (Postfix) with ESMTP id E7C2F1294DD for ; Tue, 17 May 2005 09:05:53 -1100 (GMT+11) Message-ID: <428A4EA1.9050007@sakuraindustries.com> Date: Mon, 16 May 2005 22:02:00 -0000 From: Steven Johnson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.6) Gecko/20040115 MIME-Version: 1.0 To: insight@sources.redhat.com Subject: Re: Problem with "file" command from CVS_HEAD References: <42896CAD.60504@sakuraindustries.com> In-Reply-To: <42896CAD.60504@sakuraindustries.com> Content-Type: multipart/mixed; boundary="------------080404050805080905010304" X-SW-Source: 2005-q2/txt/msg00067.txt.bz2 This is a multi-part message in MIME format. --------------080404050805080905010304 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 4514 I have found the problem. What happens is this: after a "file" command, gdb_loc is called by tcl, with no arguments. This makes gdb_loc look up the current PC. BUT, after a "file" command, (with a remote target) we do not have a "pc", because we havent had a chance to do a "target remote ...", which you do AFTER you specify the file to debug. So, i have modified gdb_loc, so if there is an attempt to look up the "pc" and there are no target registers yet, it returns an appropriate error. In that way the TCL Code can do what it needs to in this situation, and we dont generate a segfault. It is possible that there are calls the gdb_loc for $pc, which do not properly handle this error, I believe this is a seperate issue, and they will become plain with time. I have not experienced any problems (with my brief testing) to indicate this is actually the case. I Believe this is the correct thing to do. Attached is a patch against CVS_HEAD, doing just this. I have tested on an PowerPC:MPC8XX embedded system and it fixes the problem. I Believe this problem is peculiar to remote targets and local targets would not be effected. Comments? Is the code formating correct? Is the comment appropriate? Also, while this seems to fix the segfault i was experiencing with "file" I now have other problems, although they appear to be unrelated. Steven Johnson Steven Johnson wrote: > I have a problem with insight from CVS_HEAD and the "load" command. > > If i start Insight with --nw, and use "file" it does what i expect, > and loads the file i wish to debug. (No Problem) > > If i start insight with the gui enabled, and use "file". I get a > segfault, after "insight" has recursively tried to call > "target_fetch_registers(pc)" I say recursively, because i started > "insight" under GDB (native) and the back trace was enourmous > (actually segfaulted GDB before it could finish), and had an obvious > recursive call structure through the code which reads the pc register. > > I have various debug options enabled, and immediately after the "file" > command, insight reports in the debug log: > > architecture_changed_event > { flush_cached_frames () } > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > Operating system is "". > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > target_terminal_ours () > No symbol table is loaded. Use the "file" command. > observer_notify_executable_changed() called > { flush_cached_frames () } > target_xfer_memory (0x32478, xxx, 4, read, xxx) = 4, bytes = 94 21 ff f8 > target_xfer_memory (0x3247c, xxx, 4, read, xxx) = 4, bytes = 7c 08 02 a6 > target_xfer_memory (0x32480, xxx, 4, read, xxx) = 4, bytes = 90 01 00 0c > target_xfer_memory (0x32484, xxx, 4, read, xxx) = 4, bytes = 4b fd db 5d > target_xfer_memory (0x32488, xxx, 4, read, xxx) = 4, bytes = 3d 20 00 55 > target_fetch_registers (pc)target_fetch_registers > (pc)target_fetch_registers (pc)target_fetch_registers > (pc)target_fetch_registers (pc)target_fetch_registers > (pc)target_fetch_registers (pc)target_fetch_registers > (pc)target_fetch_registers (pc)target_fetch_registers > (pc)target_fetch_registers (pc)..........many many times. > **segfault** > > I believe the segfault occurs, because the program stack is exhausted > by the recursive call to target_fetch_registers (pc) > > The problem is, i havent connected to the target yet, so how can it > read memory, or fetch registers at all. > > This seems to be restricted to insight, so my first thought is, > insight isnt checking something that GDB does, and so is executing > things GDB normally doesnt on a "file" load. I dont mind trying to > correct this, but I do not have any idea where to start looking. Some > pointers of where I should look, or how "file" differs when insight is > running, as opposed to GDB would be appreciated. > > Thanks in advance, > Steven Johnson > > --------------080404050805080905010304 Content-Type: text/x-patch; name="insight-6.3.50-gdb_loc-no-registers.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="insight-6.3.50-gdb_loc-no-registers.patch" Content-length: 739 diff -Naur gdb-6.3/gdb/gdbtk/generic/gdbtk-cmds.c gdb-6.3-modified/gdb/gdbtk/generic/gdbtk-cmds.c --- gdb-6.3/gdb/gdbtk/generic/gdbtk-cmds.c 2005-05-15 21:49:09.000000000 -1100 +++ gdb-6.3-modified/gdb/gdbtk/generic/gdbtk-cmds.c 2005-05-16 23:20:03.338797451 -1100 @@ -2114,6 +2114,15 @@ if (objc == 1) { + /* This function can be called, before the target is properly + set-up, the following prevents an error, by trying to + read_pc when there is no pc to read. */ + if (!target_has_registers) + { + gdbtk_set_result (interp, "Target has no PC", -1); + return TCL_ERROR; + } + if (deprecated_selected_frame && (get_frame_pc (deprecated_selected_frame) != read_pc ())) { --------------080404050805080905010304--