From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12119 invoked by alias); 26 Jun 2004 12:11:32 -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 12068 invoked from network); 26 Jun 2004 12:11:26 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 26 Jun 2004 12:11:26 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5QCBPe1008524 for ; Sat, 26 Jun 2004 08:11:25 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5QCBPw06235 for ; Sat, 26 Jun 2004 08:11:25 -0400 Received: from cygbert.vinschen.de (vpn50-23.rdu.redhat.com [172.16.50.23]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i5QCBNP24282 for ; Sat, 26 Jun 2004 05:11:23 -0700 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 5BD94582E3; Sat, 26 Jun 2004 14:11:21 +0200 (CEST) Date: Sat, 26 Jun 2004 12:11:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] infcmd.c: Fix UI problem in attach_command Message-ID: <20040626121121.GC8039@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-SW-Source: 2004-06/txt/msg00563.txt.bz2 Hi, this is the infcmd.c fix which is necessary to run the to_pid_to_exec_file functionality in win32-nat.c smoothly. But I'm not sure if this patch is the right way to solve the situation. Sigh, so short a patch, so longish to explain. What happens is this: Usually, when the user attaches to a running process, the executable (determined by the to_pid_to_exec_file function) is opened and the symbols are loaded. Since the executable is the first file opened, it's symbols are loaded first. On Cygwin the situation is a bit different. Attaching to a process results in a bunch of debug messages from the Windows kernel. One of these messages is a LOAD_DLL_DEBUG_EVENT per DLL which is in use by the attached process. Each of these messages results in loading the symbol table of the DLL into GDB. This happens *before* the call to to_pid_to_exec_file and so naturally also *before* the symbols from the executable itself are loaded into GDB. The result of this change in load order is, that GDB has already the partial symbol table filled with symbols when it's asked to load the executable's symbol table. This in turn changes the UI behaviour. Instead of just printing "Reading symbols from...", the function symbol_file_add_with_addrs_or_offsets in symfile.c asks the user "Load new symbol table from... (y or n)" using the query function. That wouldn't be an actual problem if there wouldn't be this interesting behaviour in the attach_command function. Before trying to load the executable's symbol table, attach_command calls target_terminal_inferior(). The effect is, that when the above query function is called, GDB is not the foreground process. When running under a shell with job control, something funny happens. After printing the "Load new..." message, fgetc is called and at that point, the parent shell (here tcsh) takes over and prints a message "[1] + 3784 Suspended (tty input) gdb" Entering "fg" works, but it's not exactly helpful, right? However, now I'm finally at the point where my patch kicks in. When attach_command loads the symbol table of the executable, my patch temporarily returns the terminal to GDB. After that, it returns terminal ownership to the inferior process again. I'm not sure if that's the right way to fix it for two reasons. The first is, it might be the same, just to move the original call to target_terminal_inferior behinf the "if (!exec_file)" expression, this way avoiding to bounce terminal ownership between GDB and the inferior. The second reason is, if it might be better to avoid asking the user for loading the symbol table at all, even on Cygwin. In that case, I'm not sure how to do it. Anyway, below is my patch. Corinna * infcmd.c (attach_command): Return terminal control to GDB before loading executable's file symbols. Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.117 diff -u -p -r1.117 infcmd.c --- infcmd.c 20 Jun 2004 18:10:14 -0000 1.117 +++ infcmd.c 26 Jun 2004 08:18:41 -0000 @@ -1829,8 +1829,10 @@ attach_command (char *args, int from_tty if (!source_full_path_of (exec_file, &full_exec_path)) full_exec_path = savestring (exec_file, strlen (exec_file)); + target_terminal_ours (); exec_file_attach (full_exec_path, from_tty); symbol_file_add_main (full_exec_path, from_tty); + target_terminal_inferior (); } } else -- Corinna Vinschen Cygwin Co-Project Leader Red Hat, Inc.