* ada-lang.c (is_known_support_routine): New variable fullname.  Use
	access call to verify the symtab_to_fullname result.
	* breakpoint.c (print_breakpoint_location, update_static_tracepoint):
	Remove NULL check of symtab_to_fullname result.
	* cli/cli-cmds.c (edit_command): Likewise.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
	(mi_cmd_file_list_exec_source_files): Likewise.
	* python/py-symtab.c (stpy_fullname): Likewise.
	* source.c (symtab_to_fullname): Update function comment.  Rename
	variable r to fd, move it to inner block.  Always provide non-NULL
	result.
	(print_source_lines_base): Remove NULL check of symtab_to_fullname
	result.
	* stack.c (print_frame): Likewise.
	* symtab.c (iterate_over_some_symtabs, find_line_symtab, sources_info):
	Likewise.
	* tracepoint.c (print_one_static_tracepoint_marker): Likewise.

gdb/doc/
	* gdb.texinfo (GDB/MI Data Manipulation) (fullname): Make it always
	present.
	(GDB/MI File Commands) (-file-list-exec-source-files): Make the
	fullname output always present.

gdb/testsuite/
	* gdb.mi/mi-fullname-deleted.exp: New file.
This commit is contained in:
Jan Kratochvil 2012-12-25 08:03:33 +00:00
parent c2c899ab4b
commit f35a17b542
14 changed files with 124 additions and 85 deletions

View file

@ -1,3 +1,23 @@
2012-12-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* ada-lang.c (is_known_support_routine): New variable fullname. Use
access call to verify the symtab_to_fullname result.
* breakpoint.c (print_breakpoint_location, update_static_tracepoint):
Remove NULL check of symtab_to_fullname result.
* cli/cli-cmds.c (edit_command): Likewise.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(mi_cmd_file_list_exec_source_files): Likewise.
* python/py-symtab.c (stpy_fullname): Likewise.
* source.c (symtab_to_fullname): Update function comment. Rename
variable r to fd, move it to inner block. Always provide non-NULL
result.
(print_source_lines_base): Remove NULL check of symtab_to_fullname
result.
* stack.c (print_frame): Likewise.
* symtab.c (iterate_over_some_symtabs, find_line_symtab, sources_info):
Likewise.
* tracepoint.c (print_one_static_tracepoint_marker): Likewise.
2012-12-24 Jan Kratochvil <jan.kratochvil@redhat.com> 2012-12-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup. Code cleanup.

View file

@ -11084,6 +11084,7 @@ is_known_support_routine (struct frame_info *frame)
const char *func_name; const char *func_name;
enum language func_lang; enum language func_lang;
int i; int i;
const char *fullname;
/* If this code does not have any debugging information (no symtab), /* If this code does not have any debugging information (no symtab),
This cannot be any user code. */ This cannot be any user code. */
@ -11098,7 +11099,8 @@ is_known_support_routine (struct frame_info *frame)
for the user. This should also take care of case such as VxWorks 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. */ where the kernel has some debugging info provided for a few units. */
if (symtab_to_fullname (sal.symtab) == NULL) fullname = symtab_to_fullname (sal.symtab);
if (access (fullname, R_OK) != 0)
return 1; return 1;
/* Check the unit filename againt the Ada runtime file naming. /* Check the unit filename againt the Ada runtime file naming.

View file

@ -5694,7 +5694,6 @@ print_breakpoint_location (struct breakpoint *b,
struct symtab_and_line sal = find_pc_line (loc->address, 0); struct symtab_and_line sal = find_pc_line (loc->address, 0);
const char *fullname = symtab_to_fullname (sal.symtab); const char *fullname = symtab_to_fullname (sal.symtab);
if (fullname)
ui_out_field_string (uiout, "fullname", fullname); ui_out_field_string (uiout, "fullname", fullname);
} }
@ -13870,7 +13869,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
{ {
const char *fullname = symtab_to_fullname (sal2.symtab); const char *fullname = symtab_to_fullname (sal2.symtab);
if (fullname)
ui_out_field_string (uiout, "fullname", fullname); ui_out_field_string (uiout, "fullname", fullname);
} }

View file

@ -840,16 +840,7 @@ edit_command (char *arg, int from_tty)
if ((editor = (char *) getenv ("EDITOR")) == NULL) if ((editor = (char *) getenv ("EDITOR")) == NULL)
editor = "/bin/ex"; editor = "/bin/ex";
/* If we don't already know the full absolute file name of the
source file, find it now. */
if (!sal.symtab->fullname)
{
fn = symtab_to_fullname (sal.symtab); fn = symtab_to_fullname (sal.symtab);
if (!fn)
fn = "unknown";
}
else
fn = sal.symtab->fullname;
/* Quote the file name, in case it has whitespace or other special /* Quote the file name, in case it has whitespace or other special
characters. */ characters. */

View file

@ -1,3 +1,10 @@
2012-12-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (GDB/MI Data Manipulation) (fullname): Make it always
present.
(GDB/MI File Commands) (-file-list-exec-source-files): Make the
fullname output always present.
2012-12-23 Pierre Muller <muller@sourceware.org> 2012-12-23 Pierre Muller <muller@sourceware.org>
* gdbint.texinfo (Function prototypes): Require use of "extern" * gdbint.texinfo (Function prototypes): Require use of "extern"

View file

@ -31086,9 +31086,13 @@ file name or a relative file name depending on the compile command
used. used.
@item fullname @item fullname
This field is optional. If it is present it will contain an absolute Absolute file name of @samp{file}. It is converted to a canonical form
file name of @samp{file}. If this field is not present then using the source file search path
@value{GDBN} was unable to determine the absolute file name. (@pxref{Source Path, ,Specifying Source Directories})
and after resolving all the symbolic links.
If the source file is not found this field will contain the path as
present in the debug information.
@item line_asm_insn @item line_asm_insn
This is a list of tuples containing the disassembly for @samp{line} in This is a list of tuples containing the disassembly for @samp{line} in
@ -32269,8 +32273,8 @@ The @value{GDBN} equivalent is @samp{info source}
List the source files for the current executable. List the source files for the current executable.
It will always output the filename, but only when @value{GDBN} can find It will always output both the filename and fullname (absolute file
the absolute file name of a source file, will it output the fullname. name) of a source file.
@subsubheading @value{GDBN} Command @subsubheading @value{GDBN} Command

View file

@ -48,16 +48,11 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
if (!st.symtab) if (!st.symtab)
error (_("-file-list-exec-source-file: No symtab")); error (_("-file-list-exec-source-file: No symtab"));
/* Extract the fullname if it is not known yet. */
symtab_to_fullname (st.symtab);
/* Print to the user the line, filename and fullname. */ /* Print to the user the line, filename and fullname. */
ui_out_field_int (uiout, "line", st.line); 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->filename);
/* We may not be able to open the file (not available). */ ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab));
if (st.symtab->fullname)
ui_out_field_string (uiout, "fullname", st.symtab->fullname);
ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0); ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0);
} }
@ -99,12 +94,7 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
ui_out_begin (uiout, ui_out_type_tuple, NULL); ui_out_begin (uiout, ui_out_type_tuple, NULL);
ui_out_field_string (uiout, "file", s->filename); ui_out_field_string (uiout, "file", s->filename);
ui_out_field_string (uiout, "fullname", symtab_to_fullname (s));
/* Extract the fullname if it is not known yet. */
symtab_to_fullname (s);
if (s->fullname)
ui_out_field_string (uiout, "fullname", s->fullname);
ui_out_end (uiout, ui_out_type_tuple); ui_out_end (uiout, ui_out_type_tuple);
} }

View file

@ -132,11 +132,8 @@ stpy_fullname (PyObject *self, PyObject *args)
STPY_REQUIRE_VALID (self, symtab); STPY_REQUIRE_VALID (self, symtab);
fullname = symtab_to_fullname (symtab); fullname = symtab_to_fullname (symtab);
if (fullname)
return PyString_Decode (fullname, strlen (fullname),
host_charset (), NULL);
Py_RETURN_NONE; return PyString_Decode (fullname, strlen (fullname), host_charset (), NULL);
} }
/* Implementation of gdb.Symtab.is_valid (self) -> Boolean. /* Implementation of gdb.Symtab.is_valid (self) -> Boolean.

View file

@ -1075,35 +1075,32 @@ open_source_file (struct symtab *s)
/* Finds the fullname that a symtab represents. /* Finds the fullname that a symtab represents.
If this functions finds the fullname, it will save it in s->fullname This functions finds the fullname and saves it in s->fullname.
and it will also return the value. It will also return the value.
If this function fails to find the file that this symtab represents, If this function fails to find the file that this symtab represents,
NULL will be returned and s->fullname will be set to NULL. */ the expected fullname is used. Therefore the files does not have to
exist. */
const char * const char *
symtab_to_fullname (struct symtab *s) symtab_to_fullname (struct symtab *s)
{ {
int r;
if (!s)
return NULL;
/* Use cached copy if we have it. /* Use cached copy if we have it.
We rely on forget_cached_source_info being called appropriately We rely on forget_cached_source_info being called appropriately
to handle cases like the file being moved. */ to handle cases like the file being moved. */
if (s->fullname) if (s->fullname == NULL)
return s->fullname;
r = find_and_open_source (s->filename, s->dirname, &s->fullname);
if (r >= 0)
{ {
close (r); int fd = find_and_open_source (s->filename, s->dirname, &s->fullname);
return s->fullname;
if (fd >= 0)
close (fd);
else if (s->dirname == NULL)
s->fullname = xstrdup (s->filename);
else
s->fullname = concat (s->dirname, SLASH_STRING, s->filename, NULL);
} }
return NULL; return s->fullname;
} }
/* Create and initialize the table S->line_charpos that records /* Create and initialize the table S->line_charpos that records
@ -1306,7 +1303,6 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
{ {
const char *fullname = symtab_to_fullname (s); const char *fullname = symtab_to_fullname (s);
if (fullname != NULL)
ui_out_field_string (uiout, "fullname", fullname); ui_out_field_string (uiout, "fullname", fullname);
} }
ui_out_text (uiout, "\n"); ui_out_text (uiout, "\n");

View file

@ -1189,7 +1189,6 @@ print_frame (struct frame_info *frame, int print_level,
{ {
const char *fullname = symtab_to_fullname (sal.symtab); const char *fullname = symtab_to_fullname (sal.symtab);
if (fullname != NULL)
ui_out_field_string (uiout, "fullname", fullname); ui_out_field_string (uiout, "fullname", fullname);
} }
annotate_frame_source_file_end (); annotate_frame_source_file_end ();

View file

@ -224,13 +224,13 @@ iterate_over_some_symtabs (const char *name,
{ {
const char *fp = symtab_to_fullname (s); const char *fp = symtab_to_fullname (s);
if (fp != NULL && FILENAME_CMP (full_path, fp) == 0) if (FILENAME_CMP (full_path, fp) == 0)
{ {
if (callback (s, data)) if (callback (s, data))
return 1; return 1;
} }
if (fp != NULL && !is_abs && compare_filenames_for_search (fp, name)) if (!is_abs && compare_filenames_for_search (fp, name))
{ {
if (callback (s, data)) if (callback (s, data))
return 1; return 1;
@ -240,9 +240,6 @@ iterate_over_some_symtabs (const char *name,
if (real_path != NULL) if (real_path != NULL)
{ {
const char *fullname = symtab_to_fullname (s); const char *fullname = symtab_to_fullname (s);
if (fullname != NULL)
{
char *rp = gdb_realpath (fullname); char *rp = gdb_realpath (fullname);
make_cleanup (xfree, rp); make_cleanup (xfree, rp);
@ -259,7 +256,6 @@ iterate_over_some_symtabs (const char *name,
} }
} }
} }
}
return 0; return 0;
} }
@ -2551,9 +2547,6 @@ find_line_symtab (struct symtab *symtab, int line,
symtab->filename); symtab->filename);
} }
/* Get symbol full file name if possible. */
symtab_to_fullname (symtab);
ALL_SYMTABS (objfile, s) ALL_SYMTABS (objfile, s)
{ {
struct linetable *l; struct linetable *l;
@ -2561,9 +2554,7 @@ find_line_symtab (struct symtab *symtab, int line,
if (FILENAME_CMP (symtab->filename, s->filename) != 0) if (FILENAME_CMP (symtab->filename, s->filename) != 0)
continue; continue;
if (symtab->fullname != NULL if (FILENAME_CMP (symtab->fullname, symtab_to_fullname (s)) != 0)
&& symtab_to_fullname (s) != NULL
&& FILENAME_CMP (symtab->fullname, s->fullname) != 0)
continue; continue;
l = LINETABLE (s); l = LINETABLE (s);
ind = find_line_common (l, line, &exact, 0); ind = find_line_common (l, line, &exact, 0);
@ -3294,7 +3285,7 @@ sources_info (char *ignore, int from_tty)
{ {
const char *fullname = symtab_to_fullname (s); const char *fullname = symtab_to_fullname (s);
output_source_filename (fullname ? fullname : s->filename, &data); output_source_filename (fullname, &data);
} }
printf_filtered ("\n\n"); printf_filtered ("\n\n");

View file

@ -1,3 +1,7 @@
2012-12-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.mi/mi-fullname-deleted.exp: New file.
2012-12-24 Jan Kratochvil <jan.kratochvil@redhat.com> 2012-12-24 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/skip-solib.exp (info skip with pending file): Update the * gdb.base/skip-solib.exp (info skip with pending file): Update the

View file

@ -0,0 +1,41 @@
# Copyright 2012 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/>.
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
standard_testfile
set srcfileabs [standard_output_file $srcfile]
set f [open $srcfileabs "w"]
puts $f "int main (void) { return 0; }"
close $f
if { [gdb_compile "$srcfileabs" "${binfile}" executable {debug}] != "" } {
untested $testname
return -1
}
file delete -- $srcfileabs
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabs]\".*" "fullname present"

View file

@ -4872,7 +4872,6 @@ print_one_static_tracepoint_marker (int count,
{ {
const char *fullname = symtab_to_fullname (sal.symtab); const char *fullname = symtab_to_fullname (sal.symtab);
if (fullname)
ui_out_field_string (uiout, "fullname", fullname); ui_out_field_string (uiout, "fullname", fullname);
} }
else else