This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [1/2][RFA][7.0] Rename Python files to be 8.3 safe
On Mon, 03 Aug 2009 20:33:13 +0200, Tom Tromey wrote:
> >>>>> "Thiago" == Thiago Jung Bauermann <thiago.bauermann@gmail.com> writes:
>
> Thiago> Regarding the break command, I agree with you in that GDB should
> Thiago> be smarter here. I can volunteer to make GDB smarter if that's
> Thiago> an issue in this discussion...
>
> I wish it weren't and issue, but it is. Well, at least, it is for Emacs
> users like me -- Emacs sends file:line breakpoint commands, and IME gdb
> regularly picks the "wrong" file when there is a basename clash. (It
> might also be an issue for other-front-end users, but I don't know.)
>
> A long time ago I tried to fix this problem, but I don't remember what
> happened. As I recall, I needed changes to both gdb and Emacs.
There was a patch upstream:
http://sourceware.org/ml/gdb-patches/2009-05/msg00529.html
and I have some former work which I do not remember now the state of, attached
(it would need a split etc.). (part of RH-internal Bug 499176)
Regards,
Jan
commit 51253e4f12dc722e0de4827622768fb8109714ca
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon May 18 23:13:08 2009 +0200
Fix multiple same basenames.
gdb/
* dwarf2read.c (dwarf2_create_include_psymtab): Initialize FROM.DIRNAME.
* source.c (symtab_from_concat, symtab_from_matches): New functions.
* source.h (symtab_from_matches): New prototype.
* symtab.c (append_exact_match_to_sals): Change the FILENAME parameter
for MATCH_SYMTAB_FROM. Use symtab_from_matches for the comparison.
(expand_line_sal): Use symtab_from_matches for the comparison.
gdb/testsuite/
* gdb.base/mb-dirname-invalid.c, gdb.base/mb-dirname.c,
gdb.base/mb-dirname.exp, gdb.base/mb-dirname.h-dist,
gdb.base/mb-dirname/mb-dirname.h-dist, gdb.base/mb-dirname/valid.c,
gdb.base/mb-dirname/valid2.c: New.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 90fa435..3ad2810 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1439,6 +1439,8 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst,
{
struct partial_symtab *subpst = allocate_psymtab (name, objfile);
+ subpst->from.dirname = pst->from.dirname;
+
subpst->section_offsets = pst->section_offsets;
subpst->textlow = 0;
subpst->texthigh = 0;
diff --git a/gdb/source.c b/gdb/source.c
index 6ead875..58afe4e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1068,6 +1068,54 @@ symtab_from_to_fullname (struct symtab_from *from)
return NULL;
}
+
+/* Return "DIRNAME/FILENAME" string or just original FILENAME (if no DIRNAME is
+ present there). The possibly new string is allocated by xmalloc and in such
+ case also a cleanup xfree function gets registered. */
+
+static char *
+symtab_from_concat (struct symtab_from *from)
+{
+ char *retval;
+
+ if (from->dirname == NULL)
+ return from->filename;
+
+ retval = concat (from->dirname, "/", from->filename, NULL);
+ make_cleanup (xfree, retval);
+
+ return retval;
+}
+
+/* Return non-zero if FROM1 and FROM2 point to the same source file.
+ symtab_from_to_fullname must be already called for both FROM1 and FROM2
+ before calling this function. */
+
+int
+symtab_from_matches (struct symtab_from *from1, struct symtab_from *from2)
+{
+ struct cleanup *back_to;
+ char *concat1, *concat2;
+ int retval;
+
+ if (from1->fullname && from2->fullname)
+ return FILENAME_CMP (from1->fullname, from2->fullname) == 0;
+
+ /* If the source file does not exist GDB should be still able in most cases
+ to match the symbol files (such as to find multiple compiled instances of
+ the same source line). Still such match can be fooled as it cannot use
+ the xfullpath resolving like FULLNAME has. */
+
+ back_to = make_cleanup (null_cleanup, 0);
+
+ concat1 = symtab_from_concat (from1);
+ concat2 = symtab_from_concat (from2);
+ retval = (FILENAME_CMP (concat1, concat2) == 0);
+
+ do_cleanups (back_to);
+
+ return retval;
+}
/* Create and initialize the table S->line_charpos that records
the positions of the lines in the source file, which is assumed
diff --git a/gdb/source.h b/gdb/source.h
index 577e30d..4e3c402 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -27,6 +27,9 @@ extern int open_source_file (struct symtab *s);
extern char *symtab_from_to_fullname (struct symtab_from *from);
+extern int symtab_from_matches (struct symtab_from *from1,
+ struct symtab_from *from2);
+
/* Create and initialize the table S->line_charpos that records the
positions of the lines in the source file, which is assumed to be
open on descriptor DESC. All set S->nlines to the number of such
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1290719..0f319bf 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4466,7 +4466,7 @@ append_expanded_sal (struct symtabs_and_lines *sal,
return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB. */
static int
-append_exact_match_to_sals (char *filename, int lineno,
+append_exact_match_to_sals (struct symtab_from *match_symtab_from, int lineno,
struct symtabs_and_lines *ret,
struct linetable_entry **best_item,
struct symtab **best_symtab)
@@ -4475,13 +4475,18 @@ append_exact_match_to_sals (char *filename, int lineno,
struct symtab *symtab;
int exact = 0;
int j;
+
+ symtab_from_to_fullname (match_symtab_from);
*best_item = 0;
*best_symtab = 0;
-
+
ALL_SYMTABS (objfile, symtab)
{
- if (strcmp (filename, symtab->from.filename) == 0)
- {
+ if (match_symtab_from->fullname)
+ symtab_from_to_fullname (&symtab->from);
+
+ if (symtab_from_matches (match_symtab_from, &symtab->from))
+ {
struct linetable *l;
int len;
l = LINETABLE (symtab);
@@ -4559,20 +4564,23 @@ expand_line_sal (struct symtab_and_line sal)
the right name. Then, we iterate over symtabs, knowing
that all symtabs we're interested in are loaded. */
+ symtab_from_to_fullname (&sal.symtab->from);
ALL_PSYMTABS (objfile, psymtab)
{
- if (strcmp (sal.symtab->from.filename,
- psymtab->from.filename) == 0)
+ if (sal.symtab->from.fullname)
+ symtab_from_to_fullname (&psymtab->from);
+
+ if (symtab_from_matches (&sal.symtab->from, &psymtab->from))
PSYMTAB_TO_SYMTAB (psymtab);
}
/* Now search the symtab for exact matches and append them. If
none is found, append the best_item and all its exact
matches. */
- exact = append_exact_match_to_sals (sal.symtab->from.filename, lineno,
+ exact = append_exact_match_to_sals (&sal.symtab->from, lineno,
&ret, &best_item, &best_symtab);
if (!exact && best_item)
- append_exact_match_to_sals (best_symtab->from.filename, best_item->line,
+ append_exact_match_to_sals (&best_symtab->from, best_item->line,
&ret, &best_item, &best_symtab);
}
diff --git a/gdb/testsuite/gdb.base/mb-dirname-invalid.c b/gdb/testsuite/gdb.base/mb-dirname-invalid.c
new file mode 100644
index 0000000..5ee82ed
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname-invalid.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "mb-dirname.h"
+
+void
+invalid (void)
+{
+ func ();
+}
diff --git a/gdb/testsuite/gdb.base/mb-dirname.c b/gdb/testsuite/gdb.base/mb-dirname.c
new file mode 100644
index 0000000..5e40341
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "mb-dirname/mb-dirname.h"
+
+extern void valid (void);
+extern void valid2 (void);
+extern void invalid (void);
+
+int
+main (void)
+{
+ /* `valid' calls the same static `func' function as `main'. */
+ valid ();
+ func ();
+
+ /* Modified `mb-dirname.h' name to get recognized only when the original
+ source files exist (and xfullpath gets used). */
+ valid2 ();
+
+ /* `invalid' calls a different (located in a file with different full
+ pathname) static function. */
+ invalid ();
+
+ return 0; /* break-exit */
+}
diff --git a/gdb/testsuite/gdb.base/mb-dirname.exp b/gdb/testsuite/gdb.base/mb-dirname.exp
new file mode 100644
index 0000000..f7d4ec2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname.exp
@@ -0,0 +1,105 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test referencing the same file from various compilation directories, test
+# also referencing a different file just coincidentally having the same
+# basename. Never test the filenames reported by GDB - the pathnames reporting
+# will probably change in the future.
+
+set binfile ${objdir}/${subdir}/mb-dirname-bin
+
+file mkdir $objdir/$subdir/mb-dirname
+foreach filesrc {mb-dirname/valid.c mb-dirname/mb-dirname.h-dist mb-dirname.h-dist mb-dirname-invalid.c mb-dirname.c} {
+ regsub -- {-dist$} $filesrc "" filedst
+ if {$filesrc != $filedst || $srcdir != $objdir} {
+ file copy -force $srcdir/$subdir/$filesrc $objdir/$subdir/$filedst
+ }
+}
+
+set pwd [pwd]
+cd $objdir/$subdir/mb-dirname
+set err1 [gdb_compile "valid.c" "../mb-dirname-valid.o" object {debug}]
+set err2 [gdb_compile "valid2.c" "../mb-dirname-valid2.o" object {debug}]
+cd ..
+set err3 [gdb_compile "mb-dirname-invalid.c" "mb-dirname-invalid.o" object {debug}]
+set err4 [gdb_compile "mb-dirname.c" "mb-dirname.o" object {debug}]
+cd $pwd
+
+if { "$err1" != "" || "$err2" != "" || "$err3" != "" || "$err4" != ""
+ || [gdb_compile "$objdir/$subdir/mb-dirname-valid.o $objdir/$subdir/mb-dirname-valid2.o $objdir/$subdir/mb-dirname-invalid.o $objdir/$subdir/mb-dirname.o" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+
+gdb_exit
+gdb_start
+
+# Do not call common `gdb_reinitialize_dir $srcdir/$subdir' as it would break
+# our tests - it prefers $srcdir/$subdir before $cdir therefore forcing lookup
+# of `mb-dirname/mb-dirname.h' to be matched with plain (different)
+# `mb-dirname.h'. Also gdb_reinitialize_dir makes no sense on DWARF which
+# stores the full pathname to the sources and with correct pathnames stored by
+# GCC as this testcases uses no precompiled debug info.
+
+gdb_load ${binfile}
+
+if { ! [runto_main] } then {
+ untested "Couldn't run test program"
+ return -1
+}
+
+proc part1 {name} {
+ global pf_prefix
+ set old_prefix $pf_prefix
+ lappend pf_prefix "$name:"
+
+ # Break first in `valid' to possibly find `func' also from the `../invalid.c'
+ # file as both `func' share the basename of `mb-dirname.h'
+
+ gdb_breakpoint "valid"
+ gdb_continue_to_breakpoint "get to valid" "valid.c:.*"
+
+ gdb_breakpoint "func"
+
+ gdb_continue_to_breakpoint "func in valid"
+ gdb_test "bt" "#0 \[^\n\]* func \[^\n\]*\r\n#1 \[^\n\]* valid .*" "bt in valid"
+
+ gdb_continue_to_breakpoint "func in main"
+ gdb_test "bt" "#0 \[^\n\]* func \[^\n\]*\r\n#1 \[^\n\]* main .*" "bt in main"
+
+ set pf_prefix $old_prefix
+}
+
+part1 "xfullpath"
+
+gdb_continue_to_breakpoint "func in valid2"
+gdb_test "bt" "#0 \[^\n\]* func \[^\n\]*\r\n#1 \[^\n\]* valid2 .*" "bt in valid2"
+
+gdb_continue_to_end "invalid not reached"
+
+# Now test the behavior if we delete the source files. symtab_from_matches
+# will no longer be able to rely on xfullpath resolving and therefore it will
+# not resolve FIXME.
+
+file delete -force $objdir/$subdir/mb-dirname/mb-dirname.h $objdir/$subdir/mb-dirname.h
+
+gdb_test "dir" "Source directories searched: \\\$cdir:\\\$cwd" "reset pathname cache" \
+ "Reinitialize source path to empty.*y or n. " "y"
+
+runto_main
+
+part1 "deleted"
+
+gdb_continue_to_end "valid2 not reached"
diff --git a/gdb/testsuite/gdb.base/mb-dirname.h-dist b/gdb/testsuite/gdb.base/mb-dirname.h-dist
new file mode 100644
index 0000000..0684278
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname.h-dist
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void
+func (void)
+{
+ volatile int invalid = 0;
+
+ invalid++;
+}
diff --git a/gdb/testsuite/gdb.base/mb-dirname/mb-dirname.h-dist b/gdb/testsuite/gdb.base/mb-dirname/mb-dirname.h-dist
new file mode 100644
index 0000000..4d537d6
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname/mb-dirname.h-dist
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void
+func (void)
+{
+ volatile int var = 0;
+
+ var++;
+}
diff --git a/gdb/testsuite/gdb.base/mb-dirname/valid.c b/gdb/testsuite/gdb.base/mb-dirname/valid.c
new file mode 100644
index 0000000..2c0d29e
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname/valid.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "mb-dirname.h"
+
+void
+valid (void)
+{
+ func ();
+}
diff --git a/gdb/testsuite/gdb.base/mb-dirname/valid2.c b/gdb/testsuite/gdb.base/mb-dirname/valid2.c
new file mode 100644
index 0000000..e386f17
--- /dev/null
+++ b/gdb/testsuite/gdb.base/mb-dirname/valid2.c
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Use a bit different name so that symtab_from_matches will fail in its code
+ path for missing FULLNAMEs - in the case `mb-dirname.h' got deleted. */
+
+#include "./mb-dirname.h"
+
+void
+valid2 (void)
+{
+ func ();
+}
commit 80fea8d2445f40b75e2083e68bb5b214cdacf61e
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon May 18 00:50:25 2009 +0200
unify to symtab_from_to_fullname
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8b3b795..a99fa6b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9839,7 +9839,7 @@ is_known_support_routine (struct frame_info *frame)
for the user. This should also take care of case such as VxWorks
where the kernel has some debugging info provided for a few units. */
- if (symtab_to_fullname (sal.symtab) == NULL)
+ if (symtab_from_to_fullname (&sal.symtab->from) == NULL)
return 1;
/* Check the unit filename againt the Ada runtime file naming.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 47a969d..783f083 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3474,7 +3474,7 @@ static void print_breakpoint_location (struct breakpoint *b,
if (ui_out_is_mi_like_p (uiout))
{
struct symtab_and_line sal = find_pc_line (loc->address, 0);
- char *fullname = symtab_to_fullname (sal.symtab);
+ char *fullname = symtab_from_to_fullname (&sal.symtab->from);
if (fullname)
ui_out_field_string (uiout, "fullname", fullname);
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index e49c5ad..42d73ee 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -699,7 +699,7 @@ edit_command (char *arg, int from_tty)
source file, find it now. */
if (!sal.symtab->from.fullname)
{
- fn = symtab_to_fullname (sal.symtab);
+ fn = symtab_from_to_fullname (&sal.symtab->from);
if (!fn)
fn = "unknown";
}
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 32da68a..7e724fe 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -50,7 +50,7 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
error (_("mi_cmd_file_list_exec_source_file: No symtab"));
/* Extract the fullname if it is not known yet */
- symtab_to_fullname (st.symtab);
+ symtab_from_to_fullname (&st.symtab->from);
/* Print to the user the line, filename and fullname */
ui_out_field_int (uiout, "line", st.line);
@@ -84,7 +84,7 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
ui_out_field_string (uiout, "file", s->from.filename);
/* Extract the fullname if it is not known yet */
- symtab_to_fullname (s);
+ symtab_from_to_fullname (&s->from);
if (s->from.fullname)
ui_out_field_string (uiout, "fullname", s->from.fullname);
@@ -102,7 +102,7 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
ui_out_field_string (uiout, "file", ps->from.filename);
/* Extract the fullname if it is not known yet */
- psymtab_to_fullname (ps);
+ symtab_from_to_fullname (&ps->from);
if (ps->from.fullname)
ui_out_field_string (uiout, "fullname", ps->from.fullname);
diff --git a/gdb/source.c b/gdb/source.c
index 5721b61..6ead875 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -918,11 +918,9 @@ rewrite_source_path (const char *path)
}
/* This function is capable of finding the absolute path to a
- source file, and opening it, provided you give it an
- OBJFILE and FILENAME. Both the DIRNAME and FULLNAME are only
- added suggestions on where to find the file.
+ source file, and opening it, provided you give it a FILENAME. Both the
+ DIRNAME and FULLNAME are only added suggestions on where to find the file.
- OBJFILE should be the objfile associated with a psymtab or symtab.
FILENAME should be the filename to open.
DIRNAME is the compilation directory of a particular source file.
Only some debug formats provide this info.
@@ -940,8 +938,7 @@ rewrite_source_path (const char *path)
FULLNAME is set to NULL. */
static int
-find_and_open_source (struct objfile *objfile,
- const char *filename,
+find_and_open_source (const char *filename,
const char *dirname,
char **fullname)
{
@@ -1040,63 +1037,33 @@ open_source_file (struct symtab *s)
if (!s)
return -1;
- return find_and_open_source (s->objfile, s->from.filename, s->from.dirname,
+ return find_and_open_source (s->from.filename, s->from.dirname,
&s->from.fullname);
}
-/* Finds the fullname that a symtab represents.
+/* Finds the fullname that a symtab or partial_symtab represents.
- If this functions finds the fullname, it will save it in s->fullname
+ If this functions finds the fullname, it will save it in from->fullname
and it will also return the value.
If this function fails to find the file that this symtab represents,
- NULL will be returned and s->fullname will be set to NULL. */
+ NULL will be returned and from->fullname will be set to NULL. */
char *
-symtab_to_fullname (struct symtab *s)
+symtab_from_to_fullname (struct symtab_from *from)
{
int r;
- if (!s)
- return NULL;
-
- /* Don't check s->fullname here, the file could have been
- deleted/moved/..., look for it again */
- r = find_and_open_source (s->objfile, s->from.filename, s->from.dirname,
- &s->from.fullname);
-
- if (r >= 0)
- {
- close (r);
- return s->from.fullname;
- }
-
- return NULL;
-}
-
-/* Finds the fullname that a partial_symtab represents.
-
- If this functions finds the fullname, it will save it in ps->fullname
- and it will also return the value.
-
- If this function fails to find the file that this partial_symtab represents,
- NULL will be returned and ps->fullname will be set to NULL. */
-char *
-psymtab_to_fullname (struct partial_symtab *ps)
-{
- int r;
-
- if (!ps)
+ if (!from)
return NULL;
- /* Don't check ps->fullname here, the file could have been
+ /* Don't check from->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (ps->objfile, ps->from.filename, ps->from.dirname,
- &ps->from.fullname);
+ r = find_and_open_source (from->filename, from->dirname, &from->fullname);
if (r >= 0)
{
close (r);
- return ps->from.fullname;
+ return from->fullname;
}
return NULL;
diff --git a/gdb/source.h b/gdb/source.h
index 72271fe..577e30d 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -25,8 +25,7 @@ struct symtab;
negative number for error. */
extern int open_source_file (struct symtab *s);
-extern char* psymtab_to_fullname (struct partial_symtab *ps);
-extern char* symtab_to_fullname (struct symtab *s);
+extern char *symtab_from_to_fullname (struct symtab_from *from);
/* Create and initialize the table S->line_charpos that records the
positions of the lines in the source file, which is assumed to be
diff --git a/gdb/stack.c b/gdb/stack.c
index 4622096..80fabf9 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -796,7 +796,7 @@ print_frame (struct frame_info *frame, int print_level,
ui_out_field_string (uiout, "file", sal.symtab->from.filename);
if (ui_out_is_mi_like_p (uiout))
{
- const char *fullname = symtab_to_fullname (sal.symtab);
+ const char *fullname = symtab_from_to_fullname (&sal.symtab->from);
if (fullname != NULL)
ui_out_field_string (uiout, "fullname", fullname);
}
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 53fe5c4..1290719 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -194,7 +194,7 @@ got_symtab:
if (full_path != NULL)
{
- const char *fp = symtab_to_fullname (s);
+ const char *fp = symtab_from_to_fullname (&s->from);
if (fp != NULL && FILENAME_CMP (full_path, fp) == 0)
{
return s;
@@ -203,7 +203,7 @@ got_symtab:
if (real_path != NULL)
{
- char *fullname = symtab_to_fullname (s);
+ char *fullname = symtab_from_to_fullname (&s->from);
if (fullname != NULL)
{
char *rp = gdb_realpath (fullname);
@@ -285,7 +285,7 @@ lookup_partial_symtab (const char *name)
this symtab and use its absolute path. */
if (full_path != NULL)
{
- psymtab_to_fullname (pst);
+ symtab_from_to_fullname (&pst->from);
if (pst->from.fullname != NULL
&& FILENAME_CMP (full_path, pst->from.fullname) == 0)
{
@@ -296,7 +296,7 @@ lookup_partial_symtab (const char *name)
if (real_path != NULL)
{
char *rp = NULL;
- psymtab_to_fullname (pst);
+ symtab_from_to_fullname (&pst->from);
if (pst->from.fullname != NULL)
{
rp = gdb_realpath (pst->from.fullname);
@@ -2884,7 +2884,7 @@ sources_info (char *ignore, int from_tty)
first = 1;
ALL_SYMTABS (objfile, s)
{
- const char *fullname = symtab_to_fullname (s);
+ const char *fullname = symtab_from_to_fullname (&s->from);
output_source_filename (fullname ? fullname : s->from.filename, &first);
}
printf_filtered ("\n\n");
@@ -2896,7 +2896,7 @@ sources_info (char *ignore, int from_tty)
{
if (!ps->readin)
{
- const char *fullname = psymtab_to_fullname (ps);
+ const char *fullname = symtab_from_to_fullname (&ps->from);
output_source_filename (fullname ? fullname : ps->from.filename, &first);
}
}
commit 8478793f72cc9453ce1e8ebaa632a67cbc94178c
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon May 18 00:41:49 2009 +0200
move to `from'.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f8d68c1..8b3b795 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3270,7 +3270,7 @@ See set/show multiple-symbol."));
else
printf_unfiltered (_("[%d] %s at %s:%d\n"), i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- sal.symtab->filename, sal.line);
+ sal.symtab->from.filename, sal.line);
continue;
}
else
@@ -3285,7 +3285,8 @@ See set/show multiple-symbol."));
printf_unfiltered (_("[%d] %s at %s:%d\n"),
i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- symtab->filename, SYMBOL_LINE (syms[i].sym));
+ symtab->from.filename,
+ SYMBOL_LINE (syms[i].sym));
else if (is_enumeral
&& TYPE_NAME (SYMBOL_TYPE (syms[i].sym)) != NULL)
{
@@ -3301,7 +3302,7 @@ See set/show multiple-symbol."));
: _("[%d] %s at %s:?\n"),
i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- symtab->filename);
+ symtab->from.filename);
else
printf_unfiltered (is_enumeral
? _("[%d] %s (enumeral)\n")
@@ -9849,7 +9850,7 @@ is_known_support_routine (struct frame_info *frame)
for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1)
{
re_comp (known_runtime_file_name_patterns[i]);
- if (re_exec (sal.symtab->filename))
+ if (re_exec (sal.symtab->from.filename))
return 1;
if (sal.symtab->objfile != NULL
&& re_exec (sal.symtab->objfile->name))
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3461824..47a969d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4395,8 +4395,8 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
if (sal.symtab == NULL)
b->source_file = NULL;
else
- b->source_file = savestring (sal.symtab->filename,
- strlen (sal.symtab->filename));
+ b->source_file = savestring (sal.symtab->from.filename,
+ strlen (sal.symtab->from.filename));
b->loc->section = sal.section;
b->line_number = sal.line;
@@ -5889,7 +5889,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
{
if (!find_line_pc (sal->symtab, sal->line, &pc))
error (_("No line %d in file \"%s\"."),
- sal->line, sal->symtab->filename);
+ sal->line, sal->symtab->from.filename);
sal->pc = pc;
/* If this SAL corresponds to a breakpoint inserted using
@@ -6970,7 +6970,8 @@ clear_command (char *arg, int from_tty)
int line_match = ((default_match || (0 == sal.pc))
&& b->source_file != NULL
&& sal.symtab != NULL
- && strcmp (b->source_file, sal.symtab->filename) == 0
+ && strcmp (b->source_file,
+ sal.symtab->from.filename) == 0
&& b->line_number == sal.line);
if (pc_match || line_match)
{
@@ -7493,8 +7494,8 @@ update_breakpoint_locations (struct breakpoint *b,
b->source_file = NULL;
else
b->source_file =
- savestring (sals.sals[i].symtab->filename,
- strlen (sals.sals[i].symtab->filename));
+ savestring (sals.sals[i].symtab->from.filename,
+ strlen (sals.sals[i].symtab->from.filename));
if (b->line_number == 0)
b->line_number = sals.sals[i].line;
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 6de817f..458cfdd 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1078,14 +1078,14 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
if (subfile->dirname)
{
/* Reallocate the dirname on the symbol obstack */
- symtab->dirname = (char *)
+ symtab->from.dirname = (char *)
obstack_alloc (&objfile->objfile_obstack,
strlen (subfile->dirname) + 1);
- strcpy (symtab->dirname, subfile->dirname);
+ strcpy (symtab->from.dirname, subfile->dirname);
}
else
{
- symtab->dirname = NULL;
+ symtab->from.dirname = NULL;
}
symtab->free_code = free_linetable;
symtab->free_func = NULL;
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 18d34bf..e49c5ad 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -678,11 +678,11 @@ edit_command (char *arg, int from_tty)
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n", paddress (sal.pc),
- SYMBOL_PRINT_NAME (sym), sal.symtab->filename,
+ SYMBOL_PRINT_NAME (sym), sal.symtab->from.filename,
sal.line);
else
printf_filtered ("%s is at %s:%d.\n", paddress (sal.pc),
- sal.symtab->filename, sal.line);
+ sal.symtab->from.filename, sal.line);
}
/* If what was given does not imply a symtab, it must be an undebuggable
@@ -697,14 +697,14 @@ edit_command (char *arg, int from_tty)
/* If we don't already know the full absolute file name of the
source file, find it now. */
- if (!sal.symtab->fullname)
+ if (!sal.symtab->from.fullname)
{
fn = symtab_to_fullname (sal.symtab);
if (!fn)
fn = "unknown";
}
else
- fn = sal.symtab->fullname;
+ fn = sal.symtab->from.fullname;
/* Quote the file name, in case it has whitespace or other special
characters. */
@@ -839,10 +839,10 @@ list_command (char *arg, int from_tty)
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (sal.pc), SYMBOL_PRINT_NAME (sym),
- sal.symtab->filename, sal.line);
+ sal.symtab->from.filename, sal.line);
else
printf_filtered ("%s is at %s:%d.\n", paddress (sal.pc),
- sal.symtab->filename, sal.line);
+ sal.symtab->from.filename, sal.line);
}
/* If line was not specified by just a line number,
@@ -1106,7 +1106,7 @@ ambiguous_line_spec (struct symtabs_and_lines *sals)
for (i = 0; i < sals->nelts; ++i)
printf_filtered (_("file: \"%s\", line number: %d\n"),
- sals->sals[i].symtab->filename, sals->sals[i].line);
+ sals->sals[i].symtab->from.filename, sals->sals[i].line);
}
static void
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 6059d68..ae133c9 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -403,7 +403,7 @@ coff_end_symtab (struct objfile *objfile)
symtab = end_symtab (current_source_end_addr, objfile, SECT_OFF_TEXT (objfile));
if (symtab != NULL)
- free_named_symtabs (symtab->filename);
+ free_named_symtabs (symtab->from.filename);
/* Reinitialize for beginning of new file. */
last_source_file = NULL;
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index c6c5617..7d4d30b 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -608,7 +608,7 @@ initialize_namespace_symtab (struct objfile *objfile)
namespace_symtab = allocate_symtab ("<<C++-namespaces>>", objfile);
namespace_symtab->language = language_cplus;
namespace_symtab->free_code = free_nothing;
- namespace_symtab->dirname = NULL;
+ namespace_symtab->from.dirname = NULL;
bv = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct blockvector)
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index be73769..d726d8a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1546,7 +1546,7 @@ read_dbx_symtab (struct objfile *objfile)
first_so_symnum * symbol_size,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
- pst->dirname = dirname_nso;
+ pst->from.dirname = dirname_nso;
dirname_nso = NULL;
}
continue;
@@ -1615,7 +1615,7 @@ pos %d"),
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
- if (pst && strcmp (namestring, pst->filename) == 0)
+ if (pst && strcmp (namestring, pst->from.filename) == 0)
continue;
{
int i;
@@ -1882,7 +1882,7 @@ pos %d"),
{
CORE_ADDR minsym_valu =
find_stab_function_addr (namestring,
- pst ? pst->filename : NULL,
+ pst ? pst->from.filename : NULL,
objfile);
/* find_stab_function_addr will return 0 if the minimal
symbol wasn't found. (Unfortunately, this might also
@@ -1950,7 +1950,7 @@ pos %d"),
{
CORE_ADDR minsym_valu =
find_stab_function_addr (namestring,
- pst ? pst->filename : NULL,
+ pst ? pst->from.filename : NULL,
objfile);
/* find_stab_function_addr will return 0 if the minimal
symbol wasn't found. (Unfortunately, this might also
@@ -2260,7 +2260,7 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
strncpy (p, last_function_name, n);
p[n] = 0;
- minsym = lookup_minimal_symbol (p, pst->filename, objfile);
+ minsym = lookup_minimal_symbol (p, pst->from.filename, objfile);
if (minsym == NULL)
{
/* Sun Fortran appends an underscore to the minimal symbol name,
@@ -2268,7 +2268,7 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
was not found. */
p[n] = '_';
p[n + 1] = 0;
- minsym = lookup_minimal_symbol (p, pst->filename, objfile);
+ minsym = lookup_minimal_symbol (p, pst->from.filename, objfile);
}
if (minsym)
@@ -2363,7 +2363,7 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
/* If there is already a psymtab or symtab for a file of this name, remove it.
(If there is a symtab, more drastic things also happen.)
This happens in VxWorks. */
- free_named_symtabs (pst->filename);
+ free_named_symtabs (pst->from.filename);
if (num_includes == 0
&& number_dependencies == 0
@@ -2400,7 +2400,7 @@ dbx_psymtab_to_symtab_1 (struct partial_symtab *pst)
{
fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. \
Shouldn't happen.\n",
- pst->filename);
+ pst->from.filename);
return;
}
@@ -2415,7 +2415,7 @@ Shouldn't happen.\n",
wrap_here ("");
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
- printf_filtered ("%s...", pst->dependencies[i]->filename);
+ printf_filtered ("%s...", pst->dependencies[i]->from.filename);
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
@@ -2457,7 +2457,7 @@ dbx_psymtab_to_symtab (struct partial_symtab *pst)
{
fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. \
Shouldn't happen.\n",
- pst->filename);
+ pst->from.filename);
return;
}
@@ -2467,7 +2467,7 @@ Shouldn't happen.\n",
to avoid disconcerting pauses. */
if (info_verbose)
{
- printf_filtered ("Reading in symbols for %s...", pst->filename);
+ printf_filtered ("Reading in symbols for %s...", pst->from.filename);
gdb_flush (gdb_stdout);
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6ddaecd..90fa435 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1587,9 +1587,9 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
objfile->static_psymbols.next);
if (comp_unit_die.dirname)
- pst->dirname = obsavestring (comp_unit_die.dirname,
- strlen (comp_unit_die.dirname),
- &objfile->objfile_obstack);
+ pst->from.dirname = obsavestring (comp_unit_die.dirname,
+ strlen (comp_unit_die.dirname),
+ &objfile->objfile_obstack);
pst->read_symtab_private = (char *) this_cu;
@@ -1674,7 +1674,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
/* If there is already a psymtab or symtab for a file of this
name, remove it. (If there is a symtab, more drastic things
also happen.) This happens in VxWorks. */
- free_named_symtabs (pst->filename);
+ free_named_symtabs (pst->from.filename);
info_ptr = beg_of_comp_unit + cu.header.length
+ cu.header.initial_length_size;
@@ -2527,13 +2527,15 @@ dwarf2_psymtab_to_symtab (struct partial_symtab *pst)
{
if (pst->readin)
{
- warning (_("bug: psymtab for %s is already read in."), pst->filename);
+ warning (_("bug: psymtab for %s is already read in."),
+ pst->from.filename);
}
else
{
if (info_verbose)
{
- printf_filtered (_("Reading in symbols for %s..."), pst->filename);
+ printf_filtered (_("Reading in symbols for %s..."),
+ pst->from.filename);
gdb_flush (gdb_stdout);
}
@@ -2647,7 +2649,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
wrap_here ("");
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
- printf_filtered ("%s...", pst->dependencies[i]->filename);
+ printf_filtered ("%s...", pst->dependencies[i]->from.filename);
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
@@ -7483,7 +7485,7 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
const struct file_entry fe = lh->file_names [file_index];
char *include_name = fe.name;
char *dir_name = NULL;
- char *pst_filename = pst->filename;
+ char *pst_filename = pst->from.filename;
if (fe.dir_index)
dir_name = lh->include_dirs[fe.dir_index - 1];
@@ -7495,9 +7497,9 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
make_cleanup (xfree, include_name);
}
- if (!IS_ABSOLUTE_PATH (pst_filename) && pst->dirname != NULL)
+ if (!IS_ABSOLUTE_PATH (pst_filename) && pst->from.dirname != NULL)
{
- pst_filename = concat (pst->dirname, SLASH_STRING,
+ pst_filename = concat (pst->from.dirname, SLASH_STRING,
pst_filename, (char *)NULL);
make_cleanup (xfree, pst_filename);
}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 6e79d4a..84b321f 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -820,7 +820,7 @@ elf_symfile_init (struct objfile *objfile)
void
elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
{
- char *filename = pst->filename;
+ char *filename = pst->from.filename;
struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info;
struct stab_section_info *maybe = dbx->stab_section_info;
struct stab_section_info *questionable = 0;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6579d42..2eb9f31 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -396,14 +396,14 @@ build_canonical_line_spec (struct symtab_and_line *sal, char *symname,
struct symtab *s = sal->symtab;
if (s == (struct symtab *) NULL
- || s->filename == (char *) NULL
+ || s->from.filename == (char *) NULL
|| canonical == (char ***) NULL)
return;
canonical_arr = (char **) xmalloc (sizeof (char *));
*canonical = canonical_arr;
- filename = s->filename;
+ filename = s->from.filename;
if (symname != NULL)
{
canonical_name = xmalloc (strlen (filename) + strlen (symname) + 2);
@@ -538,7 +538,7 @@ See set/show multiple-symbol."));
printf_unfiltered ("[%d] %s at %s:%d\n",
(i + 2),
SYMBOL_PRINT_NAME (sym_arr[i]),
- values.sals[i].symtab->filename,
+ values.sals[i].symtab->from.filename,
values.sals[i].line);
else
printf_unfiltered (_("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n"),
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index a020743..3e2b8ae 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -517,12 +517,12 @@ info_forks_command (char *arg, int from_tty)
sal = find_pc_line (pc, 0);
if (sal.symtab)
{
- char *tmp = strrchr (sal.symtab->filename, '/');
+ char *tmp = strrchr (sal.symtab->from.filename, '/');
if (tmp)
printf_filtered (_(", file %s"), tmp + 1);
else
- printf_filtered (_(", file %s"), sal.symtab->filename);
+ printf_filtered (_(", file %s"), sal.symtab->from.filename);
}
if (sal.line)
printf_filtered (_(", line %d"), sal.line);
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index 1885261..0a130cd 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -48,7 +48,7 @@ sal_macro_scope (struct symtab_and_line sal)
ms = (struct macro_scope *) xmalloc (sizeof (*ms));
main_file = macro_main (sal.symtab->macro_table);
- inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename);
+ inclusion = macro_lookup_inclusion (main_file, sal.symtab->from.filename);
if (inclusion)
{
@@ -77,7 +77,7 @@ sal_macro_scope (struct symtab_and_line sal)
complaint (&symfile_complaints,
_("symtab found for `%s', but that file\n"
"is not covered in the compilation unit's macro information"),
- sal.symtab->filename);
+ sal.symtab->from.filename);
}
return ms;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 7cbcc59..2ecad9d 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -304,13 +304,13 @@ mdebug_psymtab_to_symtab (struct partial_symtab *pst)
if (info_verbose)
{
- printf_filtered (_("Reading in symbols for %s..."), pst->filename);
+ printf_filtered (_("Reading in symbols for %s..."), pst->from.filename);
gdb_flush (gdb_stdout);
}
next_symbol_text_func = mdebug_next_symbol_text;
- psymtab_to_symtab_1 (pst, pst->filename);
+ psymtab_to_symtab_1 (pst, pst->from.filename);
/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
@@ -2923,7 +2923,7 @@ parse_partial_symbols (struct objfile *objfile)
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
- if (pst && strcmp (namestring, pst->filename) == 0)
+ if (pst && strcmp (namestring, pst->from.filename) == 0)
continue;
{
int i;
@@ -3808,13 +3808,13 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
printf_filtered ("%s...",
- pst->dependencies[i]->filename);
+ pst->dependencies[i]->from.filename);
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
/* We only pass the filename for debug purposes */
psymtab_to_symtab_1 (pst->dependencies[i],
- pst->dependencies[i]->filename);
+ pst->dependencies[i]->from.filename);
}
/* Do nothing if this is a dummy psymtab. */
@@ -4033,7 +4033,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
else
{
maxlines = 2 * fh->cline;
- st = new_symtab (pst->filename, maxlines, pst->objfile);
+ st = new_symtab (pst->from.filename, maxlines, pst->objfile);
/* The proper language was already determined when building
the psymtab, use it. */
@@ -4147,7 +4147,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
if (info_verbose && n_undef_symbols)
{
printf_filtered (_("File %s contains %d unresolved references:"),
- st->filename, n_undef_symbols);
+ st->from.filename, n_undef_symbols);
printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
n_undef_vars, n_undef_procs, n_undef_labels);
n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0;
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 4fdf8c7..32da68a 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -54,11 +54,11 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
/* Print to the user the line, filename and fullname */
ui_out_field_int (uiout, "line", st.line);
- ui_out_field_string (uiout, "file", st.symtab->filename);
+ ui_out_field_string (uiout, "file", st.symtab->from.filename);
/* We may not be able to open the file (not available). */
- if (st.symtab->fullname)
- ui_out_field_string (uiout, "fullname", st.symtab->fullname);
+ if (st.symtab->from.fullname)
+ ui_out_field_string (uiout, "fullname", st.symtab->from.fullname);
ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0);
}
@@ -81,13 +81,13 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
{
ui_out_begin (uiout, ui_out_type_tuple, NULL);
- ui_out_field_string (uiout, "file", s->filename);
+ ui_out_field_string (uiout, "file", s->from.filename);
/* Extract the fullname if it is not known yet */
symtab_to_fullname (s);
- if (s->fullname)
- ui_out_field_string (uiout, "fullname", s->fullname);
+ if (s->from.fullname)
+ ui_out_field_string (uiout, "fullname", s->from.fullname);
ui_out_end (uiout, ui_out_type_tuple);
}
@@ -99,13 +99,13 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
{
ui_out_begin (uiout, ui_out_type_tuple, NULL);
- ui_out_field_string (uiout, "file", ps->filename);
+ ui_out_field_string (uiout, "file", ps->from.filename);
/* Extract the fullname if it is not known yet */
psymtab_to_fullname (ps);
- if (ps->fullname)
- ui_out_field_string (uiout, "fullname", ps->fullname);
+ if (ps->from.fullname)
+ ui_out_field_string (uiout, "fullname", ps->from.fullname);
ui_out_end (uiout, ui_out_type_tuple);
}
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 8403d5f..dc4734b 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -689,7 +689,7 @@ build_address_symbolic (CORE_ADDR addr, /* IN */
if (sal.symtab)
{
- *filename = xstrdup (sal.symtab->filename);
+ *filename = xstrdup (sal.symtab->from.filename);
*line = sal.line;
}
}
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index e2568c8..d349429 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -132,9 +132,9 @@ in_eval_c (void)
{
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
- if (cursal.symtab && cursal.symtab->filename)
+ if (cursal.symtab && cursal.symtab->from.filename)
{
- char *filename = cursal.symtab->filename;
+ char *filename = cursal.symtab->from.filename;
int len = strlen (filename);
if (len >= 6 && strcmp (filename + len - 6, "eval.c") == 0)
return 1;
diff --git a/gdb/source.c b/gdb/source.c
index 50f3510..5721b61 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -259,7 +259,7 @@ select_source_symtab (struct symtab *s)
{
for (s = ofp->symtabs; s; s = s->next)
{
- const char *name = s->filename;
+ const char *name = s->from.filename;
int len = strlen (name);
if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
|| strcmp (name, "<<C++-namespaces>>") == 0)))
@@ -275,7 +275,7 @@ select_source_symtab (struct symtab *s)
{
for (ps = ofp->psymtabs; ps != NULL; ps = ps->next)
{
- const char *name = ps->filename;
+ const char *name = ps->from.filename;
int len = strlen (name);
if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
|| strcmp (name, "<<C++-namespaces>>") == 0)))
@@ -329,19 +329,19 @@ forget_cached_source_info (void)
xfree (s->line_charpos);
s->line_charpos = NULL;
}
- if (s->fullname != NULL)
+ if (s->from.fullname != NULL)
{
- xfree (s->fullname);
- s->fullname = NULL;
+ xfree (s->from.fullname);
+ s->from.fullname = NULL;
}
}
ALL_OBJFILE_PSYMTABS (objfile, pst)
{
- if (pst->fullname != NULL)
+ if (pst->from.fullname != NULL)
{
- xfree (pst->fullname);
- pst->fullname = NULL;
+ xfree (pst->from.fullname);
+ pst->from.fullname = NULL;
}
}
}
@@ -623,11 +623,11 @@ source_info (char *ignore, int from_tty)
printf_filtered (_("No current source file.\n"));
return;
}
- printf_filtered (_("Current source file is %s\n"), s->filename);
- if (s->dirname)
- printf_filtered (_("Compilation directory is %s\n"), s->dirname);
- if (s->fullname)
- printf_filtered (_("Located in %s\n"), s->fullname);
+ printf_filtered (_("Current source file is %s\n"), s->from.filename);
+ if (s->from.dirname)
+ printf_filtered (_("Compilation directory is %s\n"), s->from.dirname);
+ if (s->from.fullname)
+ printf_filtered (_("Located in %s\n"), s->from.fullname);
if (s->nlines)
printf_filtered (_("Contains %d line%s.\n"), s->nlines,
s->nlines == 1 ? "" : "s");
@@ -1040,8 +1040,8 @@ open_source_file (struct symtab *s)
if (!s)
return -1;
- return find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ return find_and_open_source (s->objfile, s->from.filename, s->from.dirname,
+ &s->from.fullname);
}
/* Finds the fullname that a symtab represents.
@@ -1061,13 +1061,13 @@ symtab_to_fullname (struct symtab *s)
/* Don't check s->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ r = find_and_open_source (s->objfile, s->from.filename, s->from.dirname,
+ &s->from.fullname);
if (r >= 0)
{
close (r);
- return s->fullname;
+ return s->from.fullname;
}
return NULL;
@@ -1090,13 +1090,13 @@ psymtab_to_fullname (struct partial_symtab *ps)
/* Don't check ps->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (ps->objfile, ps->filename, ps->dirname,
- &ps->fullname);
+ r = find_and_open_source (ps->objfile, ps->from.filename, ps->from.dirname,
+ &ps->from.fullname);
if (r >= 0)
{
close (r);
- return ps->fullname;
+ return ps->from.fullname;
}
return NULL;
@@ -1121,7 +1121,7 @@ find_source_lines (struct symtab *s, int desc)
gdb_assert (s);
line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
if (fstat (desc, &st) < 0)
- perror_with_name (s->filename);
+ perror_with_name (s->from.filename);
if (s->objfile && s->objfile->obfd)
mtime = s->objfile->mtime;
@@ -1170,7 +1170,7 @@ find_source_lines (struct symtab *s, int desc)
/* Reassign `size' to result of read for systems where \r\n -> \n. */
size = myread (desc, data, size);
if (size < 0)
- perror_with_name (s->filename);
+ perror_with_name (s->from.filename);
end = data + size;
p = data;
line_charpos[0] = 0;
@@ -1262,7 +1262,7 @@ get_filename_and_charpos (struct symtab *s, char **fullname)
}
cleanups = make_cleanup_close (desc);
if (fullname)
- *fullname = s->fullname;
+ *fullname = s->from.fullname;
if (s->line_charpos == 0)
linenums_changed = 1;
if (linenums_changed)
@@ -1286,12 +1286,12 @@ identify_source_line (struct symtab *s, int line, int mid_statement,
{
if (s->line_charpos == 0)
get_filename_and_charpos (s, (char **) NULL);
- if (s->fullname == 0)
+ if (s->from.fullname == 0)
return 0;
if (line > s->nlines)
/* Don't index off the end of the line_charpos array. */
return 0;
- annotate_source (s->fullname, line, s->line_charpos[line - 1],
+ annotate_source (s->from.fullname, line, s->line_charpos[line - 1],
mid_statement, pc);
current_source_line = line;
@@ -1348,14 +1348,14 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
if (!noerror)
{
- char *name = alloca (strlen (s->filename) + 100);
- sprintf (name, "%d\t%s", line, s->filename);
+ char *name = alloca (strlen (s->from.filename) + 100);
+ sprintf (name, "%d\t%s", line, s->from.filename);
print_sys_errmsg (name, errno);
}
else
ui_out_field_int (uiout, "line", line);
ui_out_text (uiout, "\tin ");
- ui_out_field_string (uiout, "file", s->filename);
+ ui_out_field_string (uiout, "file", s->from.filename);
ui_out_text (uiout, "\n");
return;
@@ -1370,13 +1370,13 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
{
close (desc);
error (_("Line number %d out of range; %s has %d lines."),
- line, s->filename, s->nlines);
+ line, s->from.filename, s->nlines);
}
if (lseek (desc, s->line_charpos[line - 1], 0) < 0)
{
close (desc);
- perror_with_name (s->filename);
+ perror_with_name (s->from.filename);
}
stream = fdopen (desc, FDOPEN_MODE);
@@ -1491,7 +1491,7 @@ line_info (char *arg, int from_tty)
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, sal.symtab->from.filename);
wrap_here (" ");
printf_filtered (" is at address ");
print_address (start_pc, gdb_stdout);
@@ -1501,7 +1501,7 @@ line_info (char *arg, int from_tty)
else
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, sal.symtab->from.filename);
wrap_here (" ");
printf_filtered (" starts at address ");
print_address (start_pc, gdb_stdout);
@@ -1527,7 +1527,7 @@ line_info (char *arg, int from_tty)
which the user would want to see? If we have debugging symbols
and no line numbers? */
printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
- sal.line, sal.symtab->filename);
+ sal.line, sal.symtab->from.filename);
}
xfree (sals.sals);
}
@@ -1555,7 +1555,7 @@ forward_search_command (char *regex, int from_tty)
desc = open_source_file (current_source_symtab);
if (desc < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (current_source_symtab->from.filename);
cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
@@ -1565,7 +1565,7 @@ forward_search_command (char *regex, int from_tty)
error (_("Expression not found"));
if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (current_source_symtab->from.filename);
discard_cleanups (cleanups);
stream = fdopen (desc, FDOPEN_MODE);
@@ -1646,7 +1646,7 @@ reverse_search_command (char *regex, int from_tty)
desc = open_source_file (current_source_symtab);
if (desc < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (current_source_symtab->from.filename);
cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
@@ -1656,7 +1656,7 @@ reverse_search_command (char *regex, int from_tty)
error (_("Expression not found"));
if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (current_source_symtab->from.filename);
discard_cleanups (cleanups);
stream = fdopen (desc, FDOPEN_MODE);
@@ -1702,7 +1702,7 @@ reverse_search_command (char *regex, int from_tty)
if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
{
fclose (stream);
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (current_source_symtab->from.filename);
}
}
diff --git a/gdb/stack.c b/gdb/stack.c
index 3b2b12c..4622096 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -787,13 +787,13 @@ print_frame (struct frame_info *frame, int print_level,
QUIT;
}
ui_out_text (uiout, ")");
- if (sal.symtab && sal.symtab->filename)
+ if (sal.symtab && sal.symtab->from.filename)
{
annotate_frame_source_begin ();
ui_out_wrap_hint (uiout, " ");
ui_out_text (uiout, " at ");
annotate_frame_source_file ();
- ui_out_field_string (uiout, "file", sal.symtab->filename);
+ ui_out_field_string (uiout, "file", sal.symtab->from.filename);
if (ui_out_is_mi_like_p (uiout))
{
const char *fullname = symtab_to_fullname (sal.symtab);
@@ -807,7 +807,7 @@ print_frame (struct frame_info *frame, int print_level,
annotate_frame_source_end ();
}
- if (!funname || (!sal.symtab || !sal.symtab->filename))
+ if (!funname || (!sal.symtab || !sal.symtab->from.filename))
{
#ifdef PC_SOLIB
char *lib = PC_SOLIB (get_frame_pc (frame));
@@ -1054,7 +1054,7 @@ frame_info (char *addr_exp, int from_tty)
}
wrap_here (" ");
if (sal.symtab)
- printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
+ printf_filtered (" (%s:%d)", sal.symtab->from.filename, sal.line);
puts_filtered ("; ");
wrap_here (" ");
printf_filtered ("saved %s ", pc_regname);
@@ -1500,7 +1500,7 @@ print_block_frame_labels (struct block *b, int *have_default,
fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
}
fprintf_filtered (stream, " in file %s, line %d\n",
- sal.symtab->filename, sal.line);
+ sal.symtab->from.filename, sal.line);
}
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 774101d..81629de 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1533,8 +1533,8 @@ set_initial_language (void)
pst = find_main_psymtab ();
if (pst != NULL)
{
- if (pst->filename != NULL)
- lang = deduce_language_from_filename (pst->filename);
+ if (pst->from.filename != NULL)
+ lang = deduce_language_from_filename (pst->from.filename);
if (lang == language_unknown)
{
@@ -2710,9 +2710,9 @@ allocate_symtab (char *filename, struct objfile *objfile)
symtab = (struct symtab *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct symtab));
memset (symtab, 0, sizeof (*symtab));
- symtab->filename = obsavestring (filename, strlen (filename),
- &objfile->objfile_obstack);
- symtab->fullname = NULL;
+ symtab->from.filename = obsavestring (filename, strlen (filename),
+ &objfile->objfile_obstack);
+ symtab->from.fullname = NULL;
symtab->language = deduce_language_from_filename (filename);
symtab->debugformat = obsavestring ("unknown", 7,
&objfile->objfile_obstack);
@@ -2742,8 +2742,8 @@ allocate_psymtab (char *filename, struct objfile *objfile)
sizeof (struct partial_symtab));
memset (psymtab, 0, sizeof (struct partial_symtab));
- psymtab->filename = obsavestring (filename, strlen (filename),
- &objfile->objfile_obstack);
+ psymtab->from.filename = obsavestring (filename, strlen (filename),
+ &objfile->objfile_obstack);
psymtab->symtab = NULL;
/* Prepend it to the psymtab list for the objfile it belongs to.
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 2e25c89..8dc7385 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -118,8 +118,8 @@ free_symtab (struct symtab *s)
/* Free source-related stuff */
if (s->line_charpos != NULL)
xfree (s->line_charpos);
- if (s->fullname != NULL)
- xfree (s->fullname);
+ if (s->from.fullname != NULL)
+ xfree (s->from.fullname);
if (s->debugformat != NULL)
xfree (s->debugformat);
xfree (s);
@@ -224,7 +224,7 @@ dump_objfile (struct objfile *objfile)
psymtab = psymtab->next)
{
printf_filtered ("%s at ",
- psymtab->filename);
+ psymtab->from.filename);
gdb_print_host_address (psymtab, gdb_stdout);
printf_filtered (", ");
if (psymtab->objfile != objfile)
@@ -243,7 +243,7 @@ dump_objfile (struct objfile *objfile)
symtab != NULL;
symtab = symtab->next)
{
- printf_filtered ("%s at ", symtab->filename);
+ printf_filtered ("%s at ", symtab->from.filename);
gdb_print_host_address (symtab, gdb_stdout);
printf_filtered (", ");
if (symtab->objfile != objfile)
@@ -340,7 +340,7 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
int i;
fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
- psymtab->filename);
+ psymtab->from.filename);
fprintf_filtered (outfile, "(object ");
gdb_print_host_address (psymtab, outfile);
fprintf_filtered (outfile, ")\n\n");
@@ -382,7 +382,7 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
fprintf_filtered (outfile, " %d ", i);
gdb_print_host_address (psymtab->dependencies[i], outfile);
fprintf_filtered (outfile, " %s\n",
- psymtab->dependencies[i]->filename);
+ psymtab->dependencies[i]->from.filename);
}
if (psymtab->n_global_syms > 0)
{
@@ -412,10 +412,10 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
struct block *b;
int depth;
- fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
- if (symtab->dirname)
+ fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->from.filename);
+ if (symtab->from.dirname)
fprintf_filtered (outfile, "Compilation directory is %s\n",
- symtab->dirname);
+ symtab->from.dirname);
fprintf_filtered (outfile, "Read from object file %s (", objfile->name);
gdb_print_host_address (objfile, outfile);
fprintf_filtered (outfile, ")\n");
@@ -549,7 +549,7 @@ Arguments missing: an output file name and an optional symbol file name"));
immediate_quit++;
ALL_SYMTABS (objfile, s)
- if (symname == NULL || strcmp (symname, s->filename) == 0)
+ if (symname == NULL || strcmp (symname, s->from.filename) == 0)
dump_symtab (objfile, s, outfile);
immediate_quit--;
do_cleanups (cleanups);
@@ -759,7 +759,7 @@ maintenance_print_psymbols (char *args, int from_tty)
immediate_quit++;
ALL_PSYMTABS (objfile, ps)
- if (symname == NULL || strcmp (symname, ps->filename) == 0)
+ if (symname == NULL || strcmp (symname, ps->from.filename) == 0)
dump_psymtab (objfile, ps, outfile);
immediate_quit--;
do_cleanups (cleanups);
@@ -942,7 +942,7 @@ maintenance_info_symtabs (char *regexp, int from_tty)
QUIT;
if (! regexp
- || re_exec (symtab->filename))
+ || re_exec (symtab->from.filename))
{
if (! printed_objfile_start)
{
@@ -953,14 +953,16 @@ maintenance_info_symtabs (char *regexp, int from_tty)
printed_objfile_start = 1;
}
- printf_filtered (" { symtab %s ", symtab->filename);
+ printf_filtered (" { symtab %s ", symtab->from.filename);
wrap_here (" ");
printf_filtered ("((struct symtab *) %s)\n",
host_address_to_string (symtab));
printf_filtered (" dirname %s\n",
- symtab->dirname ? symtab->dirname : "(null)");
+ symtab->from.dirname ? symtab->from.dirname
+ : "(null)");
printf_filtered (" fullname %s\n",
- symtab->fullname ? symtab->fullname : "(null)");
+ symtab->from.fullname ? symtab->from.fullname
+ : "(null)");
printf_filtered (" blockvector ((struct blockvector *) %s)%s\n",
host_address_to_string (symtab->blockvector),
symtab->primary ? " (primary)" : "");
@@ -999,7 +1001,7 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
QUIT;
if (! regexp
- || re_exec (psymtab->filename))
+ || re_exec (psymtab->from.filename))
{
if (! printed_objfile_start)
{
@@ -1010,7 +1012,7 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
printed_objfile_start = 1;
}
- printf_filtered (" { psymtab %s ", psymtab->filename);
+ printf_filtered (" { psymtab %s ", psymtab->from.filename);
wrap_here (" ");
printf_filtered ("((struct partial_symtab *) %s)\n",
host_address_to_string (psymtab));
@@ -1018,7 +1020,8 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
printf_filtered (" readin %s\n",
psymtab->readin ? "yes" : "no");
printf_filtered (" fullname %s\n",
- psymtab->fullname ? psymtab->fullname : "(null)");
+ psymtab->from.fullname ? psymtab->from.fullname
+ : "(null)");
printf_filtered (" text addresses ");
fputs_filtered (paddress (psymtab->textlow), gdb_stdout);
printf_filtered (" -- ");
@@ -1057,7 +1060,7 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
/* Note the string concatenation there --- no comma. */
printf_filtered (" psymtab %s "
"((struct partial_symtab *) %s)\n",
- dep->filename,
+ dep->from.filename,
host_address_to_string (dep));
}
printf_filtered (" }\n");
@@ -1106,7 +1109,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
printf_filtered ("Static symbol `");
puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
printf_filtered ("' only found in ");
- puts_filtered (ps->filename);
+ puts_filtered (ps->from.filename);
printf_filtered (" psymtab\n");
}
psym++;
@@ -1123,7 +1126,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
printf_filtered ("Global symbol `");
puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
printf_filtered ("' only found in ");
- puts_filtered (ps->filename);
+ puts_filtered (ps->from.filename);
printf_filtered (" psymtab\n");
}
psym++;
@@ -1131,7 +1134,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
if (ps->texthigh < ps->textlow)
{
printf_filtered ("Psymtab ");
- puts_filtered (ps->filename);
+ puts_filtered (ps->from.filename);
printf_filtered (" covers bad range ");
fputs_filtered (paddress (ps->textlow), gdb_stdout);
printf_filtered (" - ");
@@ -1144,7 +1147,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
{
printf_filtered ("Psymtab ");
- puts_filtered (ps->filename);
+ puts_filtered (ps->from.filename);
printf_filtered (" covers ");
fputs_filtered (paddress (ps->textlow), gdb_stdout);
printf_filtered (" - ");
diff --git a/gdb/symtab.c b/gdb/symtab.c
index b8a6c31..53fe5c4 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -184,7 +184,7 @@ got_symtab:
ALL_SYMTABS (objfile, s)
{
- if (FILENAME_CMP (name, s->filename) == 0)
+ if (FILENAME_CMP (name, s->from.filename) == 0)
{
return s;
}
@@ -221,7 +221,7 @@ got_symtab:
if (lbasename (name) == name)
ALL_SYMTABS (objfile, s)
{
- if (FILENAME_CMP (lbasename (s->filename), name) == 0)
+ if (FILENAME_CMP (lbasename (s->from.filename), name) == 0)
return s;
}
@@ -234,7 +234,7 @@ got_symtab:
if (ps->readin)
error (_("Internal: readin %s pst for `%s' found when no symtab found."),
- ps->filename, name);
+ ps->from.filename, name);
s = PSYMTAB_TO_SYMTAB (ps);
@@ -276,7 +276,7 @@ lookup_partial_symtab (const char *name)
ALL_PSYMTABS (objfile, pst)
{
- if (FILENAME_CMP (name, pst->filename) == 0)
+ if (FILENAME_CMP (name, pst->from.filename) == 0)
{
return (pst);
}
@@ -286,8 +286,8 @@ lookup_partial_symtab (const char *name)
if (full_path != NULL)
{
psymtab_to_fullname (pst);
- if (pst->fullname != NULL
- && FILENAME_CMP (full_path, pst->fullname) == 0)
+ if (pst->from.fullname != NULL
+ && FILENAME_CMP (full_path, pst->from.fullname) == 0)
{
return pst;
}
@@ -297,9 +297,9 @@ lookup_partial_symtab (const char *name)
{
char *rp = NULL;
psymtab_to_fullname (pst);
- if (pst->fullname != NULL)
+ if (pst->from.fullname != NULL)
{
- rp = gdb_realpath (pst->fullname);
+ rp = gdb_realpath (pst->from.fullname);
make_cleanup (xfree, rp);
}
if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
@@ -314,7 +314,7 @@ lookup_partial_symtab (const char *name)
if (lbasename (name) == name)
ALL_PSYMTABS (objfile, pst)
{
- if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
+ if (FILENAME_CMP (lbasename (pst->from.filename), name) == 0)
return (pst);
}
@@ -1561,7 +1561,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
if (!sym)
error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
block_index == GLOBAL_BLOCK ? "global" : "static",
- name, ps->filename, name, name);
+ name, ps->from.filename, name, name);
}
return fixup_symbol_section (sym, objfile);
}
@@ -1838,7 +1838,7 @@ basic_lookup_transparent_type (const char *name)
error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>)."),
- name, ps->filename, name, name);
+ name, ps->from.filename, name, name);
}
if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
return SYMBOL_TYPE (sym);
@@ -1885,7 +1885,7 @@ basic_lookup_transparent_type (const char *name)
error (_("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>)."),
- name, ps->filename, name, name);
+ name, ps->from.filename, name, name);
}
if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
return SYMBOL_TYPE (sym);
@@ -2410,7 +2410,7 @@ find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
ALL_PSYMTABS (objfile, p)
{
- if (strcmp (symtab->filename, p->filename) != 0)
+ if (strcmp (symtab->from.filename, p->from.filename) != 0)
continue;
PSYMTAB_TO_SYMTAB (p);
}
@@ -2420,7 +2420,7 @@ find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
struct linetable *l;
int ind;
- if (strcmp (symtab->filename, s->filename) != 0)
+ if (strcmp (symtab->from.filename, s->from.filename) != 0)
continue;
l = LINETABLE (s);
ind = find_line_common (l, line, &exact);
@@ -2885,7 +2885,7 @@ sources_info (char *ignore, int from_tty)
ALL_SYMTABS (objfile, s)
{
const char *fullname = symtab_to_fullname (s);
- output_source_filename (fullname ? fullname : s->filename, &first);
+ output_source_filename (fullname ? fullname : s->from.filename, &first);
}
printf_filtered ("\n\n");
@@ -2897,7 +2897,7 @@ sources_info (char *ignore, int from_tty)
if (!ps->readin)
{
const char *fullname = psymtab_to_fullname (ps);
- output_source_filename (fullname ? fullname : ps->filename, &first);
+ output_source_filename (fullname ? fullname : ps->from.filename, &first);
}
}
printf_filtered ("\n");
@@ -3134,7 +3134,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
what file it really comes from until we have full
symtabs. The symbol might be in a header file included by
this psymtab. This only affects Insight. */
- if (file_matches (ps->filename, files, nfiles)
+ if (file_matches (ps->from.filename, files, nfiles)
&& ((regexp == NULL
|| re_exec (SYMBOL_NATURAL_NAME (*psym)) != 0)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
@@ -3208,7 +3208,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
struct symtab *real_symtab = SYMBOL_SYMTAB (sym);
QUIT;
- if (file_matches (real_symtab->filename, files, nfiles)
+ if (file_matches (real_symtab->from.filename, files, nfiles)
&& ((regexp == NULL
|| re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (sym) != LOC_TYPEDEF
@@ -3309,10 +3309,10 @@ static void
print_symbol_info (domain_enum kind, struct symtab *s, struct symbol *sym,
int block, char *last)
{
- if (last == NULL || strcmp (last, s->filename) != 0)
+ if (last == NULL || strcmp (last, s->from.filename) != 0)
{
fputs_filtered ("\nFile ", gdb_stdout);
- fputs_filtered (s->filename, gdb_stdout);
+ fputs_filtered (s->from.filename, gdb_stdout);
fputs_filtered (":\n", gdb_stdout);
}
@@ -3402,7 +3402,7 @@ symtab_symbol_info (char *regexp, domain_enum kind, int from_tty)
p->symbol,
p->block,
last_filename);
- last_filename = p->symtab->filename;
+ last_filename = p->symtab->from.filename;
}
}
@@ -3450,10 +3450,10 @@ rbreak_command (char *regexp, int from_tty)
{
if (p->msymbol == NULL)
{
- char *string = alloca (strlen (p->symtab->filename)
+ char *string = alloca (strlen (p->symtab->from.filename)
+ strlen (SYMBOL_LINKAGE_NAME (p->symbol))
+ 4);
- strcpy (string, p->symtab->filename);
+ strcpy (string, p->symtab->from.filename);
strcat (string, ":'");
strcat (string, SYMBOL_LINKAGE_NAME (p->symbol));
strcat (string, "'");
@@ -3462,7 +3462,7 @@ rbreak_command (char *regexp, int from_tty)
p->symtab,
p->symbol,
p->block,
- p->symtab->filename);
+ p->symtab->from.filename);
}
else
{
@@ -4097,19 +4097,19 @@ make_source_files_completion_list (char *text, char *word)
ALL_SYMTABS (objfile, s)
{
- if (not_interesting_fname (s->filename))
+ if (not_interesting_fname (s->from.filename))
continue;
- if (!filename_seen (s->filename, 1, &first)
+ if (!filename_seen (s->from.filename, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (s->filename, text, text_len) == 0
+ && strncasecmp (s->from.filename, text, text_len) == 0
#else
- && strncmp (s->filename, text, text_len) == 0
+ && strncmp (s->from.filename, text, text_len) == 0
#endif
)
{
/* This file matches for a completion; add it to the current
list of matches. */
- add_filename_to_list (s->filename, text, word,
+ add_filename_to_list (s->from.filename, text, word,
&list, &list_used, &list_alloced);
}
else
@@ -4118,8 +4118,8 @@ make_source_files_completion_list (char *text, char *word)
debug info records leading directories, but not the other
way around. This is what subroutines of breakpoint
command do when they parse file names. */
- base_name = lbasename (s->filename);
- if (base_name != s->filename
+ base_name = lbasename (s->from.filename);
+ if (base_name != s->from.filename
&& !filename_seen (base_name, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
&& strncasecmp (base_name, text, text_len) == 0
@@ -4134,28 +4134,28 @@ make_source_files_completion_list (char *text, char *word)
ALL_PSYMTABS (objfile, ps)
{
- if (not_interesting_fname (ps->filename))
+ if (not_interesting_fname (ps->from.filename))
continue;
if (!ps->readin)
{
- if (!filename_seen (ps->filename, 1, &first)
+ if (!filename_seen (ps->from.filename, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (ps->filename, text, text_len) == 0
+ && strncasecmp (ps->from.filename, text, text_len) == 0
#else
- && strncmp (ps->filename, text, text_len) == 0
+ && strncmp (ps->from.filename, text, text_len) == 0
#endif
)
{
/* This file matches for a completion; add it to the
current list of matches. */
- add_filename_to_list (ps->filename, text, word,
+ add_filename_to_list (ps->from.filename, text, word,
&list, &list_used, &list_alloced);
}
else
{
- base_name = lbasename (ps->filename);
- if (base_name != ps->filename
+ base_name = lbasename (ps->from.filename);
+ if (base_name != ps->from.filename
&& !filename_seen (base_name, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
&& strncasecmp (base_name, text, text_len) == 0
@@ -4480,7 +4480,7 @@ append_exact_match_to_sals (char *filename, int lineno,
ALL_SYMTABS (objfile, symtab)
{
- if (strcmp (filename, symtab->filename) == 0)
+ if (strcmp (filename, symtab->from.filename) == 0)
{
struct linetable *l;
int len;
@@ -4561,18 +4561,18 @@ expand_line_sal (struct symtab_and_line sal)
ALL_PSYMTABS (objfile, psymtab)
{
- if (strcmp (sal.symtab->filename,
- psymtab->filename) == 0)
+ if (strcmp (sal.symtab->from.filename,
+ psymtab->from.filename) == 0)
PSYMTAB_TO_SYMTAB (psymtab);
}
/* Now search the symtab for exact matches and append them. If
none is found, append the best_item and all its exact
matches. */
- exact = append_exact_match_to_sals (sal.symtab->filename, lineno,
+ exact = append_exact_match_to_sals (sal.symtab->from.filename, lineno,
&ret, &best_item, &best_symtab);
if (!exact && best_item)
- append_exact_match_to_sals (best_symtab->filename, best_item->line,
+ append_exact_match_to_sals (best_symtab->from.filename, best_item->line,
&ret, &best_item, &best_symtab);
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f7689f6..b6d14eb 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -694,6 +694,23 @@ struct section_offsets
(sizeof (struct section_offsets) \
+ sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))
+/* Origin where a symtab or partial_symtab was generated from. */
+
+struct symtab_from
+ {
+ /* Name of the source file which this symtab defines. It is never NULL. */
+
+ char *filename;
+
+ /* Full path of the source file. NULL if not known. */
+
+ char *fullname;
+
+ /* Directory in which it was compiled, or NULL if we don't know. */
+
+ char *dirname;
+ };
+
/* Each source file or header is represented by a struct symtab.
These objects are chained through the `next' field. */
@@ -704,6 +721,10 @@ struct symtab
struct symtab *next;
+ /* Origin where this symtab was generated from. */
+
+ struct symtab_from from;
+
/* List of all symbol scope blocks for this symtab. May be shared
between different symtabs (and normally is for all the symtabs
in a given compilation unit). */
@@ -731,14 +752,6 @@ struct symtab
all the symtabs in a given compilation unit. */
struct macro_table *macro_table;
- /* Name of this source file. */
-
- char *filename;
-
- /* Directory in which it was compiled, or NULL if we don't know. */
-
- char *dirname;
-
/* This component says how to free the data we point to:
free_nothing => do nothing; some other symtab will free
the data this one uses.
@@ -781,12 +794,7 @@ struct symtab
char *producer;
- /* Full name of file as found by searching the source path.
- NULL if not yet known. */
-
- char *fullname;
-
- /* Object file from which this symbol information was read. */
+ /* Information about the object file from which symbols should be read. */
struct objfile *objfile;
@@ -814,17 +822,9 @@ struct partial_symtab
struct partial_symtab *next;
- /* Name of the source file which this partial_symtab defines */
-
- char *filename;
-
- /* Full path of the source file. NULL if not known. */
-
- char *fullname;
-
- /* Directory in which it was compiled, or NULL if we don't know. */
+ /* Origin where this partial_symtab was generated from. */
- char *dirname;
+ struct symtab_from from;
/* Information about the object file from which symbols should be read. */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index dece799..3a44ed9 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -285,12 +285,12 @@ set_traceframe_context (struct frame_info *trace_frame)
/* Save file name as "$trace_file", a debugger variable visible to
users. */
if (traceframe_sal.symtab == NULL ||
- traceframe_sal.symtab->filename == NULL)
+ traceframe_sal.symtab->from.filename == NULL)
set_internalvar (lookup_internalvar ("trace_file"),
allocate_value (builtin_type_void));
else
{
- len = strlen (traceframe_sal.symtab->filename);
+ len = strlen (traceframe_sal.symtab->from.filename);
file_range = create_range_type (file_range,
builtin_type_int32, 0, len - 1);
file_string = create_array_type (file_string,
@@ -298,7 +298,7 @@ set_traceframe_context (struct frame_info *trace_frame)
file_val = allocate_value (file_string);
deprecated_set_value_type (file_val, file_string);
memcpy (value_contents_raw (file_val),
- traceframe_sal.symtab->filename,
+ traceframe_sal.symtab->from.filename,
len);
deprecated_set_value_modifiable (file_val, 0);
set_internalvar (lookup_internalvar ("trace_file"), file_val);
@@ -1724,7 +1724,7 @@ trace_find_line_command (char *args, int from_tty)
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, sal.symtab->from.filename);
wrap_here (" ");
printf_filtered (" is at address ");
print_address (start_pc, gdb_stdout);
@@ -1745,7 +1745,7 @@ trace_find_line_command (char *args, int from_tty)
which the user would want to see? If we have debugging
symbols and no line numbers? */
error (_("Line number %d is out of range for \"%s\"."),
- sal.line, sal.symtab->filename);
+ sal.line, sal.symtab->from.filename);
sprintf_vma (startpc_str, start_pc);
sprintf_vma (endpc_str, end_pc - 1);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 14f0496..aa954f4 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -311,7 +311,7 @@ tui_show_disassem_and_update_source (CORE_ADDR start_addr)
if (sal.symtab)
{
set_current_source_symtab_and_line (&sal);
- tui_update_locator_filename (sal.symtab->filename);
+ tui_update_locator_filename (sal.symtab->from.filename);
}
else
tui_update_locator_filename ("?");
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 5b8000e..fa0d7ee 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -45,7 +45,7 @@ tui_set_source_content (struct symtab *s,
{
enum tui_status ret = TUI_FAILURE;
- if (s != (struct symtab *) NULL && s->filename != (char *) NULL)
+ if (s != (struct symtab *) NULL && s->from.filename != (char *) NULL)
{
FILE *stream;
int i, desc, c, line_width, nlines;
@@ -62,8 +62,8 @@ tui_set_source_content (struct symtab *s,
{
if (!noerror)
{
- char *name = alloca (strlen (s->filename) + 100);
- sprintf (name, "%s:%d", s->filename, line_no);
+ char *name = alloca (strlen (s->from.filename) + 100);
+ sprintf (name, "%s:%d", s->from.filename, line_no);
print_sys_errmsg (name, errno);
}
ret = TUI_FAILURE;
@@ -78,12 +78,12 @@ tui_set_source_content (struct symtab *s,
close (desc);
printf_unfiltered (
"Line number %d out of range; %s has %d lines.\n",
- line_no, s->filename, s->nlines);
+ line_no, s->from.filename, s->nlines);
}
else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0)
{
close (desc);
- perror_with_name (s->filename);
+ perror_with_name (s->from.filename);
}
else
{
@@ -93,11 +93,11 @@ tui_set_source_content (struct symtab *s,
if (TUI_SRC_WIN->generic.title)
xfree (TUI_SRC_WIN->generic.title);
- TUI_SRC_WIN->generic.title = xstrdup (s->filename);
+ TUI_SRC_WIN->generic.title = xstrdup (s->from.filename);
if (src->filename)
xfree (src->filename);
- src->filename = xstrdup (s->filename);
+ src->filename = xstrdup (s->from.filename);
/* Determine the threshold for the length of the
line and the offset to start the display. */
@@ -145,7 +145,7 @@ tui_set_source_content (struct symtab *s,
element->which_element.source.is_exec_point =
(strcmp (((struct tui_win_element *)
locator->content[0])->which_element.locator.file_name,
- s->filename) == 0
+ s->from.filename) == 0
&& cur_line_no == ((struct tui_win_element *)
locator->content[0])->which_element.locator.line_no);
if (c != EOF)
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index ccc9b9f..fbc0de6 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -334,8 +334,8 @@ tui_show_frame_info (struct frame_info *fi)
find_frame_sal (fi, &sal);
source_already_displayed = sal.symtab != 0
- && tui_source_is_displayed (sal.symtab->filename);
- tui_set_locator_info (sal.symtab == 0 ? "??" : sal.symtab->filename,
+ && tui_source_is_displayed (sal.symtab->from.filename);
+ tui_set_locator_info (sal.symtab == 0 ? "??" : sal.symtab->from.filename,
tui_get_function_from_frame (fi),
sal.line,
get_frame_pc (fi));
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 158aa89..af82321 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -57,7 +57,7 @@ tui_display_main (void)
tui_update_source_windows_with_addr (addr);
sal = find_pc_line (addr, 0);
if (sal.symtab)
- tui_update_locator_filename (sal.symtab->filename);
+ tui_update_locator_filename (sal.symtab->from.filename);
else
tui_update_locator_filename ("??");
}
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 9ae929f..f7da574 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1748,7 +1748,7 @@ xcoff_psymtab_to_symtab_1 (struct partial_symtab *pst)
{
fprintf_unfiltered
(gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
+ pst->from.filename);
return;
}
@@ -1763,7 +1763,7 @@ xcoff_psymtab_to_symtab_1 (struct partial_symtab *pst)
wrap_here ("");
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
- printf_filtered ("%s...", pst->dependencies[i]->filename);
+ printf_filtered ("%s...", pst->dependencies[i]->from.filename);
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
@@ -1802,7 +1802,7 @@ xcoff_psymtab_to_symtab (struct partial_symtab *pst)
{
fprintf_unfiltered
(gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
+ pst->from.filename);
return;
}
@@ -1813,7 +1813,7 @@ xcoff_psymtab_to_symtab (struct partial_symtab *pst)
to avoid disconcerting pauses. */
if (info_verbose)
{
- printf_filtered ("Reading in symbols for %s...", pst->filename);
+ printf_filtered ("Reading in symbols for %s...", pst->from.filename);
gdb_flush (gdb_stdout);
}
@@ -2050,7 +2050,7 @@ xcoff_end_psymtab (struct partial_symtab *pst, char **include_list,
/* If there is already a psymtab or symtab for a file of this name,
remove it. (If there is a symtab, more drastic things also
happen.) This happens in VxWorks. */
- free_named_symtabs (pst->filename);
+ free_named_symtabs (pst->from.filename);
if (num_includes == 0
&& number_dependencies == 0
@@ -2544,7 +2544,7 @@ scan_xcoff_symtab (struct objfile *objfile)
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
- if (pst && strcmp (namestring, pst->filename) == 0)
+ if (pst && strcmp (namestring, pst->from.filename) == 0)
continue;
{
int i;