From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1065 invoked by alias); 24 Jan 2005 21:09:46 -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 979 invoked from network); 24 Jan 2005 21:09:42 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 24 Jan 2005 21:09:42 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j0OL9gfj013156 for ; Mon, 24 Jan 2005 16:09:42 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j0OL9fO25099 for ; Mon, 24 Jan 2005 16:09:41 -0500 Received: from cygbert.vinschen.de (vpn50-16.rdu.redhat.com [172.16.50.16]) by potter.sfbay.redhat.com (8.12.8/8.12.8) with ESMTP id j0OL9dZZ001603 for ; Mon, 24 Jan 2005 16:09:39 -0500 Received: by cygbert.vinschen.de (Postfix, from userid 500) id BB38C57D69; Mon, 24 Jan 2005 22:09:31 +0100 (CET) Date: Mon, 24 Jan 2005 21:09:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] maintenance_print_msymbols: Try harder to match files Message-ID: <20050124210931.GE17455@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: 2005-01/txt/msg00234.txt.bz2 Hi, while testing on Cygwin, I found that the maintenance_print_msymbols doesn't evaluate the optional symbol filename from the command line very user friendly. Actually it evaluates nothing at all and tests the objfile names from the loaded object files just against the command line parameter using strcmp. This has two disadvantages. - If the user types a relative pathname, the maintenance_print_msymbols function prints nothing, because object file names are stored with absolute pathnames in the objfile structure. - On Windows based systems, the user might like to enter the filename without the .exe suffix. That would fail as well. The below patch changes the maintenance_print_msymbols so that the optional filename is evaluated to an absolute pathname, just to be sure. If the file doesn't exist, maintenance_print_msymbols will generate an appropriate error message. Then it tests the inode number of this file against the inode number of the object files stored in GDB. This should be pretty reliable. Corinna * symmisc.c: Include gdb_stat.h. (maintenance_print_msymbols): Use inode numbers to compare files. Index: symmisc.c =================================================================== RCS file: /cvs/src/src/gdb/symmisc.c,v retrieving revision 1.34 diff -p -u -r1.34 symmisc.c --- symmisc.c 12 Jan 2005 18:31:33 -0000 1.34 +++ symmisc.c 24 Jan 2005 20:56:09 -0000 @@ -35,6 +35,7 @@ #include "bcache.h" #include "block.h" #include "gdb_regex.h" +#include "gdb_stat.h" #include "dictionary.h" #include "gdb_string.h" @@ -930,6 +931,8 @@ maintenance_print_msymbols (char *args, char *symname = NULL; struct objfile *objfile; + struct stat sym_st, obj_st; + dont_repeat (); if (args == NULL) @@ -948,7 +951,10 @@ maintenance_print_msymbols (char *args, /* If a second arg is supplied, it is a source file name to match on */ if (argv[1] != NULL) { - symname = argv[1]; + symname = xfullpath (argv[1]); + make_cleanup (xfree, symname); + if (symname && stat (symname, &sym_st)) + perror_with_name (symname); } } @@ -962,8 +968,9 @@ maintenance_print_msymbols (char *args, immediate_quit++; ALL_OBJFILES (objfile) - if (symname == NULL || strcmp (symname, objfile->name) == 0) - dump_msymbols (objfile, outfile); + if (symname == NULL + || (!stat (objfile->name, &obj_st) && sym_st.st_ino == obj_st.st_ino)) + dump_msymbols (objfile, outfile); immediate_quit--; fprintf_filtered (outfile, "\n\n"); do_cleanups (cleanups); -- Corinna Vinschen Cygwin Project Co-Leader Red Hat, Inc.