From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20735 invoked by alias); 17 Jan 2013 21:59:01 -0000 Received: (qmail 20727 invoked by uid 22791); 17 Jan 2013 21:59:00 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jan 2013 21:58:53 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0HLwrmw004971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Jan 2013 16:58:53 -0500 Received: from host2.jankratochvil.net (ovpn-116-19.ams2.redhat.com [10.36.116.19]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0HLwltb003865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 17 Jan 2013 16:58:49 -0500 Date: Thu, 17 Jan 2013 21:59:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch 2/9] Code cleanup: Drop IS_ABSOLUTE_PATH checks Message-ID: <20130117215846.GC16249@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00384.txt.bz2 Hi, compare_filenames_for_search did not support IS_ABSOLUTE_PATH search_name and therefore all its callers had to handle such case specially. So now compare_filenames_for_search just supports it and all the callers get simplified. This patch should have no functionality effect. Thanks, Jan gdb/ 2013-01-15 Jan Kratochvil Code cleanup. * breakpoint.c (clear_command): Remove variable is_abs, unify the call of filename_cmp with compare_filenames_for_search. * dwarf2read.c (dw2_map_symtabs_matching_filename): Remove variable is_abs, unify the call of FILENAME_CMP with compare_filenames_for_search. New gdb_asserts for full_path and real_path. Unify the call of compare_filenames_for_search with FILENAME_CMP. * psymtab.c (partial_map_symtabs_matching_filename): Likewise. * symfile.h (struct quick_symbol_functions): Extend the comment for map_symtabs_matching_filename. * symtab.c (compare_filenames_for_search): Remove the function comment relative path requirement. Handle absolute filenames. (iterate_over_some_symtabs): Remove variable is_abs, unify the call of FILENAME_CMP with compare_filenames_for_search. New gdb_asserts for full_path and real_path. Unify the call of compare_filenames_for_search with FILENAME_CMP. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -11909,8 +11909,6 @@ clear_command (char *arg, int from_tty) make_cleanup (VEC_cleanup (breakpoint_p), &found); for (i = 0; i < sals.nelts; i++) { - int is_abs; - /* If exact pc given, clear bpts at that pc. If line given (pc == 0), clear all bpts on specified line. If defaulting, clear all bpts on default line @@ -11924,7 +11922,6 @@ clear_command (char *arg, int from_tty) 1 0 */ sal = sals.sals[i]; - is_abs = sal.symtab == NULL ? 1 : IS_ABSOLUTE_PATH (sal.symtab->filename); /* Find all matching breakpoints and add them to 'found'. */ ALL_BREAKPOINTS (b) @@ -11952,12 +11949,8 @@ clear_command (char *arg, int from_tty) && sal.pspace == loc->pspace && loc->line_number == sal.line) { - if (filename_cmp (loc->symtab->filename, - sal.symtab->filename) == 0) - line_match = 1; - else if (!IS_ABSOLUTE_PATH (sal.symtab->filename) - && compare_filenames_for_search (loc->symtab->filename, - sal.symtab->filename)) + if (compare_filenames_for_search (loc->symtab->filename, + sal.symtab->filename)) line_match = 1; } --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -3068,7 +3068,6 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name, { int i; const char *name_basename = lbasename (name); - int is_abs = IS_ABSOLUTE_PATH (name); dw2_setup (objfile); @@ -3093,8 +3092,7 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name, { const char *this_name = file_data->file_names[j]; - if (FILENAME_CMP (name, this_name) == 0 - || (!is_abs && compare_filenames_for_search (this_name, name))) + if (compare_filenames_for_search (this_name, name)) { if (dw2_map_expand_apply (objfile, per_cu, name, full_path, real_path, @@ -3113,11 +3111,10 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name, const char *this_real_name = dw2_get_real_path (objfile, file_data, j); + gdb_assert (IS_ABSOLUTE_PATH (full_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); if (this_real_name != NULL - && (FILENAME_CMP (full_path, this_real_name) == 0 - || (!is_abs - && compare_filenames_for_search (this_real_name, - name)))) + && FILENAME_CMP (full_path, this_real_name) == 0) { if (dw2_map_expand_apply (objfile, per_cu, name, full_path, real_path, @@ -3131,11 +3128,10 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name, const char *this_real_name = dw2_get_real_path (objfile, file_data, j); + gdb_assert (IS_ABSOLUTE_PATH (real_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); if (this_real_name != NULL - && (FILENAME_CMP (real_path, this_real_name) == 0 - || (!is_abs - && compare_filenames_for_search (this_real_name, - name)))) + && FILENAME_CMP (real_path, this_real_name) == 0) { if (dw2_map_expand_apply (objfile, per_cu, name, full_path, real_path, --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -168,7 +168,6 @@ partial_map_symtabs_matching_filename (struct objfile *objfile, { struct partial_symtab *pst; const char *name_basename = lbasename (name); - int is_abs = IS_ABSOLUTE_PATH (name); ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) { @@ -181,8 +180,7 @@ partial_map_symtabs_matching_filename (struct objfile *objfile, if (pst->anonymous) continue; - if (FILENAME_CMP (name, pst->filename) == 0 - || (!is_abs && compare_filenames_for_search (pst->filename, name))) + if (compare_filenames_for_search (pst->filename, name)) { if (partial_map_expand_apply (objfile, name, full_path, real_path, pst, callback, data)) @@ -199,11 +197,11 @@ partial_map_symtabs_matching_filename (struct objfile *objfile, this symtab and use its absolute path. */ if (full_path != NULL) { + gdb_assert (IS_ABSOLUTE_PATH (full_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); psymtab_to_fullname (pst); if (pst->fullname != NULL - && (FILENAME_CMP (full_path, pst->fullname) == 0 - || (!is_abs && compare_filenames_for_search (pst->fullname, - name)))) + && FILENAME_CMP (full_path, pst->fullname) == 0) { if (partial_map_expand_apply (objfile, name, full_path, real_path, pst, callback, data)) @@ -214,15 +212,16 @@ partial_map_symtabs_matching_filename (struct objfile *objfile, if (real_path != NULL) { char *rp = NULL; + + gdb_assert (IS_ABSOLUTE_PATH (real_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); psymtab_to_fullname (pst); if (pst->fullname != NULL) { rp = gdb_realpath (pst->fullname); make_cleanup (xfree, rp); } - if (rp != NULL - && (FILENAME_CMP (real_path, rp) == 0 - || (!is_abs && compare_filenames_for_search (real_path, name)))) + if (rp != NULL && FILENAME_CMP (real_path, rp) == 0) { if (partial_map_expand_apply (objfile, name, full_path, real_path, pst, callback, data)) --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -159,9 +159,11 @@ struct quick_symbol_functions /* Expand and iterate over each "partial" symbol table in OBJFILE where the source file is named NAME. - If NAME is not absolute, a match after a '/' in the symbol - table's file name will also work. FULL_PATH is the absolute file - name, and REAL_PATH is the same, run through gdb_realpath. + If NAME is not absolute, a match after a '/' in the symbol table's + file name will also work, both FULL_PATH and REAL_PATH are NULL + then. If NAME is absolute then both FULL_PATH and REAL_PATH are + non-NULL absolute file names. FULL_PATH is NAME resolved via + xfullpath, REAL_PATH is NAME resolved via gdb_realpath. If a match is found, the "partial" symbol table is expanded. Then, this calls iterate_over_some_symtabs (or equivalent) over --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -146,8 +146,8 @@ const struct block *block_found; /* See whether FILENAME matches SEARCH_NAME using the rule that we advertise to the user. (The manual's description of linespecs - describes what we advertise). We assume that SEARCH_NAME is - a relative path. Returns true if they match, false otherwise. */ + describes what we advertise). Returns true if they match, false + otherwise. */ int compare_filenames_for_search (const char *filename, const char *search_name) @@ -171,7 +171,8 @@ compare_filenames_for_search (const char *filename, const char *search_name) to put the "c:file.c" name into debug info. Such compatibility works only on GDB built for DOS host. */ return (len == search_len - || IS_DIR_SEPARATOR (filename[len - search_len - 1]) + || (!IS_ABSOLUTE_PATH (search_name) + && IS_DIR_SEPARATOR (filename[len - search_len - 1])) || (HAS_DRIVE_SPEC (filename) && STRIP_DRIVE_SPEC (filename) == &filename[len - search_len])); } @@ -199,18 +200,10 @@ iterate_over_some_symtabs (const char *name, { struct symtab *s = NULL; const char* base_name = lbasename (name); - int is_abs = IS_ABSOLUTE_PATH (name); for (s = first; s != NULL && s != after_last; s = s->next) { - /* Exact match is always ok. */ - if (FILENAME_CMP (name, s->filename) == 0) - { - if (callback (s, data)) - return 1; - } - - if (!is_abs && compare_filenames_for_search (s->filename, name)) + if (compare_filenames_for_search (s->filename, name)) { if (callback (s, data)) return 1; @@ -229,17 +222,13 @@ iterate_over_some_symtabs (const char *name, { const char *fp = symtab_to_fullname (s); + gdb_assert (IS_ABSOLUTE_PATH (full_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); if (FILENAME_CMP (full_path, fp) == 0) { if (callback (s, data)) return 1; } - - if (!is_abs && compare_filenames_for_search (fp, name)) - { - if (callback (s, data)) - return 1; - } } if (real_path != NULL) @@ -248,6 +237,8 @@ iterate_over_some_symtabs (const char *name, char *rp = gdb_realpath (fullname); struct cleanup *cleanups = make_cleanup (xfree, rp); + gdb_assert (IS_ABSOLUTE_PATH (real_path)); + gdb_assert (IS_ABSOLUTE_PATH (name)); if (FILENAME_CMP (real_path, rp) == 0) { if (callback (s, data)) @@ -256,15 +247,6 @@ iterate_over_some_symtabs (const char *name, return 1; } } - - if (!is_abs && compare_filenames_for_search (rp, name)) - { - if (callback (s, data)) - { - do_cleanups (cleanups); - return 1; - } - } do_cleanups (cleanups); } }