This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] set/unset/show substitute-path commands (take 2)


Hello,

Sorry for the delay, got side-tracked on something else...

Here is take 3 of the substitute-path feature. I corrected something
that I forgot, namely use FILENAME_CMP to do comparisons rather than
strcmp. I also implemented Andrew's two suggestions.

2006-07-19  Joel Brobecker  <brobecker@adacore.com>

        * source.c: #include gdb_assert.h.
        (substitute_path_rule): New struct.
        (substitute_path_rules): New static global variable.
        (substitute_path_rule_matches): New function.
        (get_substitute_path_rule): New function.
        (rewrite_source_path): New function.
        (find_and_open_source): Add source path rewriting support.
        (strip_trailing_directory_separator): New function.
        (make_cleanup_argv): New function.
        (find_substitute_path_rule): New function.
        (add_substitute_path_rule): New function.
        (delete_substitute_path_rule): New function.
        (show_substitute_path_command): New function.
        (unset_substitute_path_command): New function.
        (set_substitute_path_command): New function.
        (_initialize_source): Add new substitute-path commands.
        * Makefile.in (source.o): Add dependency on gdb_assert.h.

Tested on x86-linux.

> 2006-07-14  Joel Brobecker  <brobecker@adacore.com>
> 
>         * gdb.base/subst.exp: New testcase.

I adjusted the testcase according to the modifications in the code.
I also tried to add a test that would verify that the substitution
correctly takes place, but as expected, I'm having some trouble
doing that. Here is what I did:

        * gdb.base/subst.exp
        * gdb.base/subst.c
        * gdb.base/subst.dir/subst.c

The version of subst.c in subst.dir is a modified version of subst.c.
I built the subst executable using gdb.base/subst.c, as usual. And then
tried to add a substitution rule as follow:

        (gdb) set substitute-path '${srcdir}/${subdir}' '${srcdir}/${subdir}/subst.dir'

But the problem is that ${srcdir} is not string equal to what compiler
put in the debugging information. As far as I can tell from the testcase
output, ${srcdir} is something like ../../gdb/testsuite. I don't see how
to reliably get the source path in a way that would be identical to what
the compiler sets.

Perhaps this is telling us that, instead of just FILENAME_CMP, we should
use something more sophisticated like xfullpath to check for path equality.
But I'm very reluctant to even suggest that, because performance would
probably become horrendous on large applications where lots and lots of
files are used.

Any suggestion on how to setup this test?

Again, documentation will be supplied as soon as this patch gets in.

Thanks,
-- 
Joel

Attachment: subst.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]