From patchwork Wed Nov 12 04:18:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3665 Received: (qmail 27718 invoked by alias); 12 Nov 2014 04:19:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27704 invoked by uid 89); 12 Nov 2014 04:19:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f180.google.com Received: from mail-pd0-f180.google.com (HELO mail-pd0-f180.google.com) (209.85.192.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 12 Nov 2014 04:18:59 +0000 Received: by mail-pd0-f180.google.com with SMTP id ft15so11436385pdb.11 for ; Tue, 11 Nov 2014 20:18:57 -0800 (PST) X-Received: by 10.70.19.206 with SMTP id h14mr44902369pde.49.1415765937837; Tue, 11 Nov 2014 20:18:57 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id mt6sm20721840pbb.45.2014.11.11.20.18.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Nov 2014 20:18:57 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 2/5] struct symtab split part 1: SYMTAB_DIRNAME Date: Tue, 11 Nov 2014 20:18:06 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch just adds an accessor macro to symtab.dirname. 2014-11-11 Doug Evans * symtab.h (SYMTAB_DIRNAME): New macro. All uses of member symtab.dirname updated to use it. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 3ea8ff0..d0f0ddc 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1244,14 +1244,14 @@ end_symtab_with_blockvector (struct block *static_block, if (subfile->dirname) { /* Reallocate the dirname on the symbol obstack. */ - symtab->dirname = + SYMTAB_DIRNAME (symtab) = obstack_copy0 (&objfile->objfile_obstack, subfile->dirname, strlen (subfile->dirname)); } else { - symtab->dirname = NULL; + SYMTAB_DIRNAME (symtab) = NULL; } /* Use whatever language we have been using for this diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 0c3cfa7..79246ac 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1486,21 +1486,23 @@ compare_symtabs (const void *a, const void *b) { const struct symtab_and_line *sala = a; const struct symtab_and_line *salb = b; + const char *dira = SYMTAB_DIRNAME (sala->symtab); + const char *dirb = SYMTAB_DIRNAME (salb->symtab); int r; - if (!sala->symtab->dirname) + if (dira == NULL) { - if (salb->symtab->dirname) + if (dirb != NULL) return -1; } - else if (!salb->symtab->dirname) + else if (dirb == NULL) { - if (sala->symtab->dirname) + if (dira != NULL) return 1; } else { - r = filename_cmp (sala->symtab->dirname, salb->symtab->dirname); + r = filename_cmp (dira, dirb); if (r) return r; } diff --git a/gdb/jit.c b/gdb/jit.c index c12a72f..4810018 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -645,7 +645,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) symtab = allocate_symtab (stab->file_name, objfile); /* JIT compilers compile in memory. */ - symtab->dirname = NULL; + SYMTAB_DIRNAME (symtab) = NULL; /* Copy over the linetable entry if one was provided. */ if (stab->linetable) diff --git a/gdb/source.c b/gdb/source.c index 894531a..0f69578 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -659,8 +659,8 @@ source_info (char *ignore, int from_tty) return; } printf_filtered (_("Current source file is %s\n"), s->filename); - if (s->dirname) - printf_filtered (_("Compilation directory is %s\n"), s->dirname); + if (SYMTAB_DIRNAME (s) != NULL) + printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s)); if (s->fullname) printf_filtered (_("Located in %s\n"), s->fullname); if (s->nlines) @@ -1105,7 +1105,7 @@ open_source_file (struct symtab *s) if (!s) return -1; - return find_and_open_source (s->filename, s->dirname, &s->fullname); + return find_and_open_source (s->filename, SYMTAB_DIRNAME (s), &s->fullname); } /* Finds the fullname that a symtab represents. @@ -1125,7 +1125,8 @@ symtab_to_fullname (struct symtab *s) to handle cases like the file being moved. */ if (s->fullname == NULL) { - int fd = find_and_open_source (s->filename, s->dirname, &s->fullname); + int fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s), + &s->fullname); if (fd >= 0) close (fd); @@ -1137,10 +1138,11 @@ symtab_to_fullname (struct symtab *s) /* rewrite_source_path would be applied by find_and_open_source, we should report the pathname where GDB tried to find the file. */ - if (s->dirname == NULL || IS_ABSOLUTE_PATH (s->filename)) + if (SYMTAB_DIRNAME (s) == NULL || IS_ABSOLUTE_PATH (s->filename)) fullname = xstrdup (s->filename); else - fullname = concat (s->dirname, SLASH_STRING, s->filename, NULL); + fullname = concat (SYMTAB_DIRNAME (s), SLASH_STRING, s->filename, + NULL); back_to = make_cleanup (xfree, fullname); s->fullname = rewrite_source_path (fullname); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 623bcb3..323ebd5 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -297,9 +297,9 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab, fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab_to_filename_for_display (symtab)); - if (symtab->dirname) + if (SYMTAB_DIRNAME (symtab) != NULL) fprintf_filtered (outfile, "Compilation directory is %s\n", - symtab->dirname); + SYMTAB_DIRNAME (symtab)); fprintf_filtered (outfile, "Read from object file %s (", objfile_name (objfile)); gdb_print_host_address (objfile, outfile); @@ -753,7 +753,8 @@ maintenance_info_symtabs (char *regexp, int from_tty) printf_filtered ("((struct symtab *) %s)\n", host_address_to_string (symtab)); printf_filtered (" dirname %s\n", - symtab->dirname ? symtab->dirname : "(null)"); + SYMTAB_DIRNAME (symtab) != NULL + ? SYMTAB_DIRNAME (symtab) : "(null)"); printf_filtered (" fullname %s\n", symtab->fullname ? symtab->fullname : "(null)"); printf_filtered (" " diff --git a/gdb/symtab.h b/gdb/symtab.h index fdedd59..e545506 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -984,6 +984,7 @@ struct symtab #define LINETABLE(symtab) (symtab)->linetable #define SYMTAB_OBJFILE(symtab) ((symtab)->objfile) #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace) +#define SYMTAB_DIRNAME(symtab) ((symtab)->dirname) /* Call this to set the "primary" field in struct symtab. */ extern void set_symtab_primary (struct symtab *, int primary);