* [patchv2 13/11] Make relative-with-system-absolute the default
@ 2013-01-29 22:11 Jan Kratochvil
2013-01-30 7:49 ` [patchv3 " Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2013-01-29 22:11 UTC (permalink / raw)
To: gdb-patches
Hi,
previous patches discussed it, so make the change with hopefully only pros and
no cons.
No regressions on {x86_64,x86_64-m32,i686}-fedora19pre-linux-gnu and with
gdbindex.
Thanks,
Jan
gdb/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* source.c (filename_display_string): Change it to
filename_display_relative_with_system_absolute.
(_initialize_source): Describe the new "set filename-display" default.
gdb/doc/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Backtrace): Change set filename-display default to
relative-with-system-absolute.
gdb/testsuite/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.threads/linux-dp.exp (first thread-specific breakpoint hit):
Allow displayed path for pthread_create.c.
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6541,7 +6541,7 @@ You can control how file names are displayed.
@item set filename-display
@itemx set filename-display relative
@cindex filename-display
-Display file names relative to the compilation directory. This is the default.
+Display file names relative to the compilation directory.
@item set filename-display basename
Display only basename of a filename.
@@ -6554,6 +6554,8 @@ Determine whether a source filename comes from file having separate debug
information file. In such case display the source filename as absolute one.
Otherwise display it relative to the compilation directory.
+This is the default.
+
@item set filename-display basename-with-system-absolute
Determine whether a source filename comes from file having separate debug
information file. In such case display the source filename as absolute one.
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -127,7 +127,8 @@ static const char *const filename_display_kind_names[] = {
NULL
};
-static const char *filename_display_string = filename_display_relative;
+static const char *filename_display_string =
+ filename_display_relative_with_system_absolute;
static void
show_filename_display_string (struct ui_file *file, int from_tty,
@@ -2086,7 +2087,7 @@ filename-display can be:\n\
basename-with-system-absolute - display filenames from files with separate\n\
debug info files as absolute, other files\n\
display only with basename of the filename\n\
-By default, relative filenames are displayed."),
+By default, relative-with-system-absolute is set."),
NULL,
show_filename_display_string,
&setlist, &showlist);
--- a/gdb/testsuite/gdb.threads/linux-dp.exp
+++ b/gdb/testsuite/gdb.threads/linux-dp.exp
@@ -233,7 +233,9 @@ gdb_continue_to_breakpoint "thread 5's print"
# If you do have debug info, the output obviously depends more on the
# exact library in use; under NPTL, you get:
# #2 0x0012b7fc in start_thread (arg=0x21) at pthread_create.c:264
-gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in pthread_create\).*" \
+# and with "set filename-display absolute" one gets:
+# #2 0x0012b7fc in start_thread (arg=0x21) at /path/to/pthread_create.c:264
+gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in \[^\r\n\]*pthread_create\).*" \
"first thread-specific breakpoint hit"
# Make sure it's catching the right thread. Try hitting the
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patchv3 13/11] Make relative-with-system-absolute the default
2013-01-29 22:11 [patchv2 13/11] Make relative-with-system-absolute the default Jan Kratochvil
@ 2013-01-30 7:49 ` Jan Kratochvil
2013-01-30 17:17 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2013-01-30 7:49 UTC (permalink / raw)
To: gdb-patches
Just forgot about gdb/NEWS.
On Tue, 29 Jan 2013 23:11:18 +0100, Jan Kratochvil wrote:
Hi,
previous patches discussed it, so make the change with hopefully only pros and
no cons.
No regressions on {x86_64,x86_64-m32,i686}-fedora19pre-linux-gnu and with
gdbindex.
Thanks,
Jan
gdb/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* NEWS (set filename-display): Describe the new "set filename-display"
default.
* source.c (filename_display_string): Change it to
filename_display_relative_with_system_absolute.
(_initialize_source): Describe the new "set filename-display" default.
gdb/doc/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Backtrace): Change set filename-display default to
relative-with-system-absolute.
gdb/testsuite/
2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.threads/linux-dp.exp (first thread-specific breakpoint hit):
Allow displayed path for pthread_create.c.
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -119,7 +119,9 @@ set filename-display basename|relative|absolute|relative-with-system-absolute
|basename-with-system-absolute
show filename-display
Control the way in which filenames is displayed.
- The default is "relative", which preserves previous behavior.
+ Previous behavior was "relative".
+ New default is "relative-with-system-absolute", which prints source filenames
+ from files with present separate debug info in absolute form.
* MI changes
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6541,7 +6541,7 @@ You can control how file names are displayed.
@item set filename-display
@itemx set filename-display relative
@cindex filename-display
-Display file names relative to the compilation directory. This is the default.
+Display file names relative to the compilation directory.
@item set filename-display basename
Display only basename of a filename.
@@ -6557,6 +6557,8 @@ Otherwise display it relative to the compilation directory.
Files having separate debug information file are expected to come from system
shared libraries.
+This is the default.
+
@item set filename-display basename-with-system-absolute
Determine whether a source filename comes from file having separate debug
information file. In such case display the source filename as absolute one.
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -127,7 +127,8 @@ static const char *const filename_display_kind_names[] = {
NULL
};
-static const char *filename_display_string = filename_display_relative;
+static const char *filename_display_string =
+ filename_display_relative_with_system_absolute;
static void
show_filename_display_string (struct ui_file *file, int from_tty,
@@ -2086,7 +2087,7 @@ filename-display can be:\n\
basename-with-system-absolute - display filenames from files with separate\n\
debug info files as absolute, other files\n\
display only with basename of the filename\n\
-By default, relative filenames are displayed."),
+By default, relative-with-system-absolute is set."),
NULL,
show_filename_display_string,
&setlist, &showlist);
--- a/gdb/testsuite/gdb.threads/linux-dp.exp
+++ b/gdb/testsuite/gdb.threads/linux-dp.exp
@@ -233,7 +233,9 @@ gdb_continue_to_breakpoint "thread 5's print"
# If you do have debug info, the output obviously depends more on the
# exact library in use; under NPTL, you get:
# #2 0x0012b7fc in start_thread (arg=0x21) at pthread_create.c:264
-gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in pthread_create\).*" \
+# and with "set filename-display absolute" one gets:
+# #2 0x0012b7fc in start_thread (arg=0x21) at /path/to/pthread_create.c:264
+gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in \[^\r\n\]*pthread_create\).*" \
"first thread-specific breakpoint hit"
# Make sure it's catching the right thread. Try hitting the
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-01-30 7:49 ` [patchv3 " Jan Kratochvil
@ 2013-01-30 17:17 ` Eli Zaretskii
2013-02-02 18:07 ` Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2013-01-30 17:17 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
> Date: Wed, 30 Jan 2013 08:48:59 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -119,7 +119,9 @@ set filename-display basename|relative|absolute|relative-with-system-absolute
> |basename-with-system-absolute
> show filename-display
> Control the way in which filenames is displayed.
> - The default is "relative", which preserves previous behavior.
> + Previous behavior was "relative".
> + New default is "relative-with-system-absolute", which prints source filenames
> + from files with present separate debug info in absolute form.
I believe "present" should be removed from here.
>
> * MI changes
>
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -6541,7 +6541,7 @@ You can control how file names are displayed.
> @item set filename-display
> @itemx set filename-display relative
> @cindex filename-display
> -Display file names relative to the compilation directory. This is the default.
> +Display file names relative to the compilation directory.
>
> @item set filename-display basename
> Display only basename of a filename.
> @@ -6557,6 +6557,8 @@ Otherwise display it relative to the compilation directory.
> Files having separate debug information file are expected to come from system
> shared libraries.
Documentation changes are OK with that change.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-01-30 17:17 ` Eli Zaretskii
@ 2013-02-02 18:07 ` Jan Kratochvil
2013-02-02 18:27 ` Eli Zaretskii
2013-02-05 17:35 ` Doug Evans
0 siblings, 2 replies; 11+ messages in thread
From: Jan Kratochvil @ 2013-02-02 18:07 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Wed, 30 Jan 2013 18:16:38 +0100, Eli Zaretskii wrote:
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -119,7 +119,9 @@ set filename-display basename|relative|absolute|relative-with-system-absolute
> > |basename-with-system-absolute
> > show filename-display
> > Control the way in which filenames is displayed.
> > - The default is "relative", which preserves previous behavior.
> > + Previous behavior was "relative".
> > + New default is "relative-with-system-absolute", which prints source filenames
> > + from files with present separate debug info in absolute form.
>
> I believe "present" should be removed from here.
I will remove it but it was present there to highlight it does not apply to
files with separated debug info where the separate debug info is currently not
installed. Although in such case no source filename is printed at all so it
is irrelevant whether it would be printed in absolute or relative form.
But maybe I am too biased into the internal details not interesting to casual
user.
Thanks,
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-02 18:07 ` Jan Kratochvil
@ 2013-02-02 18:27 ` Eli Zaretskii
2013-02-05 17:35 ` Doug Evans
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2013-02-02 18:27 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
> Date: Sat, 2 Feb 2013 19:06:58 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
>
> On Wed, 30 Jan 2013 18:16:38 +0100, Eli Zaretskii wrote:
> > > --- a/gdb/NEWS
> > > +++ b/gdb/NEWS
> > > @@ -119,7 +119,9 @@ set filename-display basename|relative|absolute|relative-with-system-absolute
> > > |basename-with-system-absolute
> > > show filename-display
> > > Control the way in which filenames is displayed.
> > > - The default is "relative", which preserves previous behavior.
> > > + Previous behavior was "relative".
> > > + New default is "relative-with-system-absolute", which prints source filenames
> > > + from files with present separate debug info in absolute form.
> >
> > I believe "present" should be removed from here.
>
> I will remove it but it was present there to highlight it does not apply to
> files with separated debug info where the separate debug info is currently not
> installed. Although in such case no source filename is printed at all so it
> is irrelevant whether it would be printed in absolute or relative form.
Yes, I believe your last sentence is the reason why this detail does
not need to be mentioned.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-02 18:07 ` Jan Kratochvil
2013-02-02 18:27 ` Eli Zaretskii
@ 2013-02-05 17:35 ` Doug Evans
2013-02-05 18:23 ` Jan Kratochvil
1 sibling, 1 reply; 11+ messages in thread
From: Doug Evans @ 2013-02-05 17:35 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Eli Zaretskii, gdb-patches
On Sat, Feb 2, 2013 at 10:06 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Wed, 30 Jan 2013 18:16:38 +0100, Eli Zaretskii wrote:
>> > --- a/gdb/NEWS
>> > +++ b/gdb/NEWS
>> > @@ -119,7 +119,9 @@ set filename-display basename|relative|absolute|relative-with-system-absolute
>> > |basename-with-system-absolute
>> > show filename-display
>> > Control the way in which filenames is displayed.
>> > - The default is "relative", which preserves previous behavior.
>> > + Previous behavior was "relative".
>> > + New default is "relative-with-system-absolute", which prints source filenames
>> > + from files with present separate debug info in absolute form.
>>
>> I believe "present" should be removed from here.
>
> I will remove it but it was present there to highlight it does not apply to
> files with separated debug info where the separate debug info is currently not
> installed. Although in such case no source filename is printed at all so it
> is irrelevant whether it would be printed in absolute or relative form.
>
> But maybe I am too biased into the internal details not interesting to casual
> user.
Hi.
I'm not comfortable with the conflating of the term "system" with
"separate debug info".
I can imagine that for distributions the common usage of this option
will be with
system supplied separate debug info, but the two concepts are orthogonal.
I can also imagine wanting system supplied separate debug info treated
differently from separate debug info files for the app being debugged.
How to achieve that ... dunno.
One thought (at the implementation level) was to have the setting per-objfile.
How to effect that from the u/i ... dunno.
Thoughts?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-05 17:35 ` Doug Evans
@ 2013-02-05 18:23 ` Jan Kratochvil
2013-02-06 16:02 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2013-02-05 18:23 UTC (permalink / raw)
To: Doug Evans; +Cc: Eli Zaretskii, gdb-patches
On Tue, 05 Feb 2013 18:35:35 +0100, Doug Evans wrote:
> I'm not comfortable with the conflating of the term "system" with
> "separate debug info".
Are you fine with considering "system" to be the files with separate debug
info located from 'set debug-file-directory'?
Or do you require to have new 'set debug-file-directory-for-system' and
separate 'set debug-file-directory' (empty by default)?
> I can also imagine wanting system supplied separate debug info treated
> differently from separate debug info files for the app being debugged.
"separate debug info files for the app being debugged" are those found at the
location of the binary itself or under its ".debug/" subdirectory?
If that is not enough that the new
option 'set debug-file-directory-for-system' vs.
application-specific 'set debug-file-directory' should satisfy it, I hope.
> One thought (at the implementation level) was to have the setting per-objfile.
There is still also the option to just make the default:
set filename-display absolute
For any larger application - which may involve the app separate debug info - it
is probably the best option anyway.
I just did not want to complicate debugging of small schoolbook applications
but maybe absolute filenames would be easier even in those cases, dunno.
Thanks,
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-05 18:23 ` Jan Kratochvil
@ 2013-02-06 16:02 ` Tom Tromey
2013-02-07 20:25 ` Doug Evans
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2013-02-06 16:02 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Doug Evans, Eli Zaretskii, gdb-patches
Doug> I can also imagine wanting system supplied separate debug info
Doug> treated differently from separate debug info files for the app
Doug> being debugged.
Are you saying this is something you actively want?
Or something that someone might conceivably want?
If the latter, then I suggest we not do it until someone presents a
reason that they need it. To me it seems like a complication that, in
practice, nobody would use.
If you actively want it, could you say why?
I'm having difficulty picturing the scenario in which it would be
useful.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-06 16:02 ` Tom Tromey
@ 2013-02-07 20:25 ` Doug Evans
2013-02-07 20:29 ` Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Doug Evans @ 2013-02-07 20:25 UTC (permalink / raw)
To: Tom Tromey; +Cc: Jan Kratochvil, Eli Zaretskii, gdb-patches
On Wed, Feb 6, 2013 at 8:02 AM, Tom Tromey <tromey@redhat.com> wrote:
> Doug> I can also imagine wanting system supplied separate debug info
> Doug> treated differently from separate debug info files for the app
> Doug> being debugged.
>
> Are you saying this is something you actively want?
> Or something that someone might conceivably want?
It's not something I will run into today.
> If the latter, then I suggest we not do it until someone presents a
> reason that they need it. To me it seems like a complication that, in
> practice, nobody would use.
If I have a reason to turn on foo-with-system-absolute,
I would still not want the behaviour of gdb to change because the
build system for my app generates separate debug info files.
"system" is being conflated with "separate debug info", and I'm not
comfortable with that.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patchv3 13/11] Make relative-with-system-absolute the default
2013-02-07 20:25 ` Doug Evans
@ 2013-02-07 20:29 ` Jan Kratochvil
2013-02-15 19:58 ` [patch FYI not for commit] Attempt to properly relativize executable's filenames Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2013-02-07 20:29 UTC (permalink / raw)
To: Doug Evans; +Cc: Tom Tromey, Eli Zaretskii, gdb-patches
On Thu, 07 Feb 2013 21:25:21 +0100, Doug Evans wrote:
> If I have a reason to turn on foo-with-system-absolute,
> I would still not want the behaviour of gdb to change because the
> build system for my app generates separate debug info files.
> "system" is being conflated with "separate debug info", and I'm not
> comfortable with that.
When thinking about it I believe one wants absolute source names even for any
application which uses >= 2 different DW_AT_comp_dir's.
So I will try to prepare some different patch.
Thanks,
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch FYI not for commit] Attempt to properly relativize executable's filenames
2013-02-07 20:29 ` Jan Kratochvil
@ 2013-02-15 19:58 ` Jan Kratochvil
0 siblings, 0 replies; 11+ messages in thread
From: Jan Kratochvil @ 2013-02-15 19:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey, Eli Zaretskii, Doug Evans
On Thu, 07 Feb 2013 21:29:08 +0100, Jan Kratochvil wrote:
> When thinking about it I believe one wants absolute source names even for any
> application which uses >= 2 different DW_AT_comp_dir's.
I tried that but - it does not work.
Applications contain sources from source filenames outside of their build
directory. And it is not clear which such sources are and which are not parts
of the application itself.
With -lmcheck on Fedora one gets
/builddir/build/BUILD/glibc-2.15-a316c1f/malloc/mcheck-init.c from
/usr/lib64/libmcheck.a as an example.
Then there are included-symtabs from /usr/include/filenames.h; OTOH one has
also included-symtabs from the application itself.
So currently I give up on some autodetection of proper base directory for
inferior executable. Developers of large applications just should do:
echo >>~/.gdbinit set filename-display absolute
Regards,
Jan
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d26e7c8..e86dd33 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3762,6 +3762,29 @@ dw2_has_symbols (struct objfile *objfile)
return 1;
}
+static char *
+dw2_find_common_dir (struct objfile *objfile)
+{
+ int i;
+ char *common_dir = NULL;
+
+ dw2_setup (objfile);
+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+ {
+ struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i);
+ struct quick_file_names *file_data = dw2_get_file_names (objfile, per_cu);
+ int j;
+
+ for (j = 0; j < file_data->num_file_names; ++j)
+ {
+ const char *this_file_name = file_data->file_names[j];
+
+ reduce_common_dir (&common_dir, this_file_name);
+ }
+ }
+ return common_dir;
+}
+
const struct quick_symbol_functions dwarf2_gdb_index_functions =
{
dw2_has_symbols,
@@ -3779,7 +3802,8 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
dw2_map_matching_symbols,
dw2_expand_symtabs_matching,
dw2_find_pc_sect_symtab,
- dw2_map_symbol_filenames
+ dw2_map_symbol_filenames,
+ dw2_find_common_dir
};
/* Initialize for reading DWARF for this objfile. Return 0 if this
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 8c17c14..47a38fc 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -637,6 +637,8 @@ free_objfile (struct objfile *objfile)
if (objfile->demangled_names_hash)
htab_delete (objfile->demangled_names_hash);
obstack_free (&objfile->objfile_obstack, 0);
+ xfree (objfile->common_dir_raw);
+ xfree (objfile->common_dir);
/* Rebuild section map next time we need it. */
get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 6d29084..1df8cc4 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -387,6 +387,8 @@ struct objfile
table, so we have to keep them here to relocate them
properly. */
struct symbol *template_symbols;
+
+ char *common_dir_raw, *common_dir;
};
/* Defines for the objfile flag word. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 2965e9f..8e6f19f 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1411,6 +1411,28 @@ objfile_has_psyms (struct objfile *objfile)
return objfile->psymtabs != NULL;
}
+static char *
+find_common_dir (struct objfile *objfile)
+{
+ struct partial_symtab *ps;
+ char *common_dir = NULL;
+
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
+ {
+ if (ps->dirname == NULL || IS_ABSOLUTE_PATH (ps->filename))
+ reduce_common_dir (&common_dir, ps->filename);
+ else
+ {
+ char *raw_fullname;
+
+ raw_fullname = concat (ps->dirname, SLASH_STRING, ps->filename, NULL);
+ reduce_common_dir (&common_dir, raw_fullname);
+ xfree (raw_fullname);
+ }
+ }
+ return common_dir;
+}
+
const struct quick_symbol_functions psym_functions =
{
objfile_has_psyms,
@@ -1428,7 +1450,8 @@ const struct quick_symbol_functions psym_functions =
map_matching_symbols_psymtab,
expand_symtabs_matching_via_partial,
find_pc_sect_symtab_from_partial,
- map_symbol_filenames_psymtab
+ map_symbol_filenames_psymtab,
+ find_common_dir
};
\f
diff --git a/gdb/source.c b/gdb/source.c
index f5949e6..6012fd6 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -113,15 +113,17 @@ show_lines_to_list (struct ui_file *file, int from_tty,
static const char filename_display_basename[] = "basename";
static const char filename_display_relative[] = "relative";
static const char filename_display_absolute[] = "absolute";
+static const char filename_display_common[] = "common";
static const char *const filename_display_kind_names[] = {
filename_display_basename,
filename_display_relative,
filename_display_absolute,
+ filename_display_common,
NULL
};
-static const char *filename_display_string = filename_display_relative;
+static const char *filename_display_string = filename_display_common;
static void
show_filename_display_string (struct ui_file *file, int from_tty,
@@ -1133,6 +1135,24 @@ symtab_to_fullname (struct symtab *s)
return s->fullname;
}
+void
+reduce_common_dir (char **common_dir_ptr, const char *filename)
+{
+ char *common_dir = *common_dir_ptr;
+ int i;
+
+ if (common_dir == NULL)
+ {
+ *common_dir_ptr = ldirname (filename);
+ return;
+ }
+
+ for (i = 0; common_dir[i] != 0 && common_dir[i] == filename[i]; i++);
+ while (i > 0 && !IS_DIR_SEPARATOR (filename[i]))
+ i--;
+ common_dir[i] = 0;
+}
+
/* See commentary in source.h. */
const char *
@@ -1144,6 +1164,49 @@ symtab_to_filename_for_display (struct symtab *symtab)
return symtab_to_fullname (symtab);
else if (filename_display_string == filename_display_relative)
return symtab->filename;
+ else if (filename_display_string == filename_display_common)
+ {
+ struct objfile *objfile = symtab->objfile;
+ char *fullname_raw, *dirname_raw;
+ const char *fullname;
+ size_t common_dir_raw_len, common_dir_len;
+
+ if (objfile->common_dir_raw == NULL && objfile->sf != NULL)
+ {
+ objfile->common_dir_raw = objfile->sf->qf->find_common_dir (objfile);
+ gdb_assert (objfile->common_dir == NULL);
+ if (objfile->common_dir_raw == NULL)
+ objfile->common_dir_raw = xstrdup ("");
+ if (*objfile->common_dir_raw == 0)
+ objfile->common_dir = xstrdup ("");
+ else
+ objfile->common_dir = gdb_realpath (objfile->common_dir_raw);
+ }
+
+ if (objfile->common_dir_raw == NULL || *objfile->common_dir_raw == 0)
+ return symtab_to_fullname (symtab);
+
+ if (IS_ABSOLUTE_PATH (symtab->filename))
+ fullname_raw = xstrdup (symtab->filename);
+ else
+ fullname_raw = concat (symtab->dirname, SLASH_STRING, symtab->filename,
+ NULL);
+
+ common_dir_raw_len = strlen (objfile->common_dir_raw);
+ gdb_assert (strncmp (objfile->common_dir_raw, fullname_raw,
+ common_dir_raw_len) == 0);
+ gdb_assert (IS_DIR_SEPARATOR (fullname_raw[common_dir_raw_len]));
+
+ /* File system may have changed in the meantime so gdb_assert would not
+ be appropriate here. */
+ common_dir_len = strlen (objfile->common_dir);
+ fullname = symtab_to_fullname (symtab);
+ if (strncmp (objfile->common_dir, fullname, common_dir_len) != 0
+ || !IS_DIR_SEPARATOR (fullname[common_dir_len]))
+ return fullname;
+
+ return &fullname[common_dir_len + 1];
+ }
else
internal_error (__FILE__, __LINE__, _("invalid filename_display_string"));
}
diff --git a/gdb/source.h b/gdb/source.h
index 33cad09..e70ab26 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -52,6 +52,8 @@ extern char *rewrite_source_path (const char *path);
extern const char *symtab_to_fullname (struct symtab *s);
+extern void reduce_common_dir (char **common_dir_ptr, const char *filename);
+
/* Returns filename without the compile directory part, basename or absolute
filename. It depends on 'set filename-display' value. */
extern const char *symtab_to_filename_for_display (struct symtab *symtab);
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6d6b4b8..b7696ba 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -296,6 +296,8 @@ struct quick_symbol_functions
void (*map_symbol_filenames) (struct objfile *objfile,
symbol_filename_ftype *fun, void *data,
int need_fullname);
+
+ char *(*find_common_dir) (struct objfile *objfile);
};
/* Structure of functions used for probe support. If one of these functions
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-02-15 19:58 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 22:11 [patchv2 13/11] Make relative-with-system-absolute the default Jan Kratochvil
2013-01-30 7:49 ` [patchv3 " Jan Kratochvil
2013-01-30 17:17 ` Eli Zaretskii
2013-02-02 18:07 ` Jan Kratochvil
2013-02-02 18:27 ` Eli Zaretskii
2013-02-05 17:35 ` Doug Evans
2013-02-05 18:23 ` Jan Kratochvil
2013-02-06 16:02 ` Tom Tromey
2013-02-07 20:25 ` Doug Evans
2013-02-07 20:29 ` Jan Kratochvil
2013-02-15 19:58 ` [patch FYI not for commit] Attempt to properly relativize executable's filenames Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox