* Re: -file-list-exec-source-files
@ 2004-06-27 19:14 Michael Elizabeth Chastain
0 siblings, 0 replies; 69+ messages in thread
From: Michael Elizabeth Chastain @ 2004-06-27 19:14 UTC (permalink / raw)
To: bob, schwab; +Cc: eliz, ezannoni, gdb-patches
It's repeatable with selftest.exp, pr gdb/1677,
but that does not qualify as a small example.
gdb running on gdb ... now use gdb to debug that ...
actually it's not so bad if you run selftest.exp
and then do '/usr/bin/gdb /my/unstable/gdb core'.
to sniff around in the data structures.
I'll see if I can make a small demonstration this week.
Michael C
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
@ 2004-06-29 22:37 Michael Elizabeth Chastain
2004-06-30 3:32 ` -file-list-exec-source-files Eli Zaretskii
0 siblings, 1 reply; 69+ messages in thread
From: Michael Elizabeth Chastain @ 2004-06-29 22:37 UTC (permalink / raw)
To: bob, eliz; +Cc: ezannoni, gdb-patches, jimb
Eli, it looks like you think that Bob's patch falls within your
area of authority.
To me, it looks like a generic symtab patch and that is the domain
of Jim and Elena. I don't think you have the authority to approve
this patch.
Although maybe I'm missing something here?
(I like Bob's patch, too, and I recommend that Jim or Elena approve it,
based on my test results with it).
And I hate being the guy to make a fuss over this. Also poor Bob
doesn't deserve this hassle either.
Michael C
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 22:37 -file-list-exec-source-files Michael Elizabeth Chastain
@ 2004-06-30 3:32 ` Eli Zaretskii
2004-07-06 21:02 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-06-30 3:32 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: bob, ezannoni, gdb-patches, jimb
> Date: Tue, 29 Jun 2004 18:37:20 -0400 (EDT)
> From: mec.gnu@mindspring.com (Michael Elizabeth Chastain)
>
> Eli, it looks like you think that Bob's patch falls within your
> area of authority.
>
> To me, it looks like a generic symtab patch and that is the domain
> of Jim and Elena. I don't think you have the authority to approve
> this patch.
The patch is for a function in symtab.c, but it's not about symbols,
it's about looking for source/object files, and that belongs to
source.c, at least logically. That's why I thought I could approve
this.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-30 3:32 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-07-06 21:02 ` Bob Rossi
2004-07-08 11:19 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-07-06 21:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Michael Elizabeth Chastain, ezannoni, gdb-patches, jimb
On Wed, Jun 30, 2004 at 06:27:14AM +0200, Eli Zaretskii wrote:
> > Date: Tue, 29 Jun 2004 18:37:20 -0400 (EDT)
> > From: mec.gnu@mindspring.com (Michael Elizabeth Chastain)
> >
> > Eli, it looks like you think that Bob's patch falls within your
> > area of authority.
> >
> > To me, it looks like a generic symtab patch and that is the domain
> > of Jim and Elena. I don't think you have the authority to approve
> > this patch.
>
> The patch is for a function in symtab.c, but it's not about symbols,
> it's about looking for source/object files, and that belongs to
> source.c, at least logically. That's why I thought I could approve
> this.
No disrespect meant to anyone ...
Can I commit this now?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-07-06 21:02 ` -file-list-exec-source-files Bob Rossi
@ 2004-07-08 11:19 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-07-08 11:19 UTC (permalink / raw)
To: Eli Zaretskii, Michael Elizabeth Chastain, ezannoni, gdb-patches, jimb
On Tue, Jul 06, 2004 at 05:02:10PM -0400, Bob Rossi wrote:
> On Wed, Jun 30, 2004 at 06:27:14AM +0200, Eli Zaretskii wrote:
> > > Date: Tue, 29 Jun 2004 18:37:20 -0400 (EDT)
> > > From: mec.gnu@mindspring.com (Michael Elizabeth Chastain)
> > >
> > > Eli, it looks like you think that Bob's patch falls within your
> > > area of authority.
> > >
> > > To me, it looks like a generic symtab patch and that is the domain
> > > of Jim and Elena. I don't think you have the authority to approve
> > > this patch.
> >
> > The patch is for a function in symtab.c, but it's not about symbols,
> > it's about looking for source/object files, and that belongs to
> > source.c, at least logically. That's why I thought I could approve
> > this.
>
> No disrespect meant to anyone ...
> Can I commit this now?
This patch is committed. I don't know what the PR was associated with
it, but it could probaby be closed now.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
@ 2004-06-29 4:57 Michael Elizabeth Chastain
0 siblings, 0 replies; 69+ messages in thread
From: Michael Elizabeth Chastain @ 2004-06-29 4:57 UTC (permalink / raw)
To: bob, schwab; +Cc: eliz, ezannoni, gdb-patches
bob> The patch below checks symtab_to_fullname's return value against NULL.
bob> Even though this is the "trivial" fix, I believe it is the correct
bob> patch. When I added these calls recently, I blindly changed the old call
bob> to symtab_to_fullname, and the old call did not return NULL.
First, I had a formatting problem with the patch. By the time
I got it, the patch had no tabs, and it looked like the tabs
were expanded to 4 spaces each (instead of 8 spaces). No big deal,
I just applied the changes by hand.
I ran this patch in my test bed and it fixed the problem for me. It
also has no regressions in any other tests.
As usual, my test bed is: native i686-pc-linux-gnu, red hat 8.0,
gcc 2.95.3 and gcc 3.3.3, dwarf-2 and stabs+.
I discovered a subtle interaction between my testbed, selftest.exp,
and this bug. Unlike most people, I don't run the test suite in
the build directory. My script runs the test suite in a fresh
'test' directory for each run. The 'test' directory has a fresh
copy of the build/gdb/testsuite directory (which is actually just
a framework), but it does not have build/gdb itself. And indeed
I remove everything in the build/ tree except for the testsuite/
subtree to save space.
When I make that removal, I get the crash. No removal, no crash.
I think that's why symtab_to_fullname returns NULL for me. I don't have
any more objfiles for gdb itself. And it happens only in selftest.exp,
because selftest.exp is special.
I'm not qualified to say whether this is the *right* fix but it
fixes the problem for me.
Michael C
===
2004-06-28 Bob Rossi <bob@brasko.net>
* symtab.c (lookup_symtab): check return value of symtab_to_fullname
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
@ 2004-03-25 3:54 Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-25 3:54 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
Elena, thanks for taking the time to review my patch.
When is a good point to resubmit a patch? After every review, or after
all the issues are ironed out?
> > Here is an initial patch for -file-list-exec-source-files.
> > Some feedback would be appreciated.
> >
> > I ran the testsuite and the results are the same before and after this
> > patch.
> >
> > Index: gdb/ChangeLog
> > * dbxread.c (read_dbx_symtab): set pst->dirname when known
>
> Each entry should start with capital letter and end with period.
>
> I see some coding standards are not adhered to throughout the code.
> Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> calls.
Ok, I will try to fix all of the coding standard errors. Is there a
program I can run on the source files before I create the diff that
formats the code according to the standard?
>
> >
> > Index: gdb/dbxread.c
> > ===================================================================
> > Index: gdb/dwarf2read.c
> > ===================================================================
>
> These are ok
Great!
> >
> > Index: gdb/defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.143
> > diff -w -u -r1.143 defs.h
> > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > @@ -616,8 +616,6 @@
> >
> > extern void init_last_source_visited (void);
> >
> > -extern char *symtab_to_filename (struct symtab *);
> > -
> > /* From exec.c */
> >
> > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > Index: gdb/dwarf2read.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > retrieving revision 1.135
> > diff -w -u -r1.135 dwarf2read.c
> > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > @@ -316,6 +316,7 @@
> > unsigned int offset;
> > unsigned int abbrev;
> > char *name;
> > + char *dirname;
> > int has_pc_info;
> > CORE_ADDR lowpc;
> > CORE_ADDR highpc;
> > @@ -1254,6 +1255,8 @@
> > objfile->global_psymbols.next,
> > objfile->static_psymbols.next);
> >
> > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > +
> > pst->read_symtab_private = (char *)
> > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > @@ -4326,6 +4329,10 @@
> > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > if (part_die->name == NULL)
> > part_die->name = DW_STRING (&attr);
> > + break;
> > + case DW_AT_comp_dir:
> > + if (part_die->dirname == NULL)
> > + part_die->dirname = DW_STRING (&attr);
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
It would probably just be best if you told me what case's you want me to
implement here. It seems that Jason Molenda understodd most of the
cases. I really don't know anything about what GCC emits and would would
be practical to implement.
> > Index: gdb/source.c
> > ===================================================================
>
> this part I am not clear about.
Ok, Ok. I thought about this a lot. I think I made the best decision and
can describe why.
A few assumptions are in order. In order to get the fullname (abs path)
to a file, GDB need's three things. The directory the file was compiled
in (dirname), the filename in question (filename) and a list of paths
to search.
> There is already a function called source_full_path_of() would it help
> if you used it?
The function source_full_path_of does not take into account 'dirname'.
It calls openp, which is not capable of finding the fullname of a file,
since it doesn't understand what dirname is. Basically, I don't even
think this function (source_full_path_of) is "truly" capable of
finding the fullpath to a file. However, instead of removing it,
I left it, since caller's of this function might be using for something
I know nothing about.
> What is the difference between find_and_open_source and
> open_source_file? I.e. why did you need to introduce it. I think it's
> not clear just from your comments about the file possibly baing moved
> around.
open_source_file was left around for backwards compatibility. The unit
source.c was used to calling a function, with just passing the symtab,
and getting back the symtab with a valid fullname. I could remove all
occurences of this function and replace it with symtab_to_fullname.
> I am a bit worried about the substitution of symtab_to_filename with
> symtab_to_fullname. The former returns null only if there is no
> symtab. The latter returns null when there is no symtab OR when it
> cannot find the file. So the behavior is slightly different.
I basically think that the call -file-list-exec-source-files shouldn't
'cache' it's results. GDB looks for each file, every time it is
requested to get the fullname. This is because, the user could have
changed the path, or moved/deleted the file. I don't think GDB should
just return the filename instead, of the fullname.
So, if find_and_open_source couldn't "find and open the source file", it
returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
get's set to NULL.
The testsuite didn't seem to have a problem with this, and I think it
makes sense to not trick the caller into having results when it couldn't
find any.
If the caller really wanted this functionality,
return s->filename; /* File not found. Just use short name */
I believe it should be the caller's responsibility.
if ( symtab_to_fullname ( s ) == NULL )
/* use symtab->filename */
else
/* use symtab->fullname */
It doesn't really make sense to return the filename and not state that
it is not really the fullname. Also, if the caller tries to access
s->fullname, it will not be successful, because the file simply isn't
there.
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.49
> > diff -w -u -r1.49 source.c
> > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > @@ -805,30 +805,47 @@
> > return 1;
> > }
> >
> > -
> > -/* Open a source file given a symtab S. Returns a file descriptor or
> > - negative number for error. */
> > -
> > +/* 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.
> > +
> > + 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.
> > + FULLNAME can be the last known absolute path to the file in question.
> > +
> > + On Success
> > + A valid file descriptor is returned. ( the return value is positive )
> > + FULLNAME is set to the absolute path to the file just opened.
> > +
> > + On Failure
> > + A non valid file descriptor is returned. ( the return value is negitive )
> > + FULLNAME is set to NULL. */
> > int
> > -open_source_file (struct symtab *s)
> > +find_and_open_source (
> > + struct objfile *objfile,
> > + const char *filename,
> > + const char *dirname,
> > + char **fullname )
> > {
>
> coding standards....
Ok.
> > char *path = source_path;
> > const char *p;
> > int result;
> > - char *fullname;
> >
> > /* Quick way out if we already know its full name */
> > - if (s->fullname)
> > + if (*fullname)
> > {
> > - result = open (s->fullname, OPEN_MODE);
> > + result = open (*fullname, OPEN_MODE);
> > if (result >= 0)
> > return result;
> > /* Didn't work -- free old one, try again. */
> > - xmfree (s->objfile->md, s->fullname);
> > - s->fullname = NULL;
> > + xmfree (objfile->md, *fullname);
> > + *fullname = NULL;
> > }
> >
> > - if (s->dirname != NULL)
> > + if (dirname != NULL)
> > {
> > /* Replace a path entry of $cdir with the compilation directory name */
> > #define cdir_len 5
> > @@ -841,60 +858,102 @@
> > int len;
> >
> > path = (char *)
> > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > len = p - source_path;
> > strncpy (path, source_path, len); /* Before $cdir */
> > - strcpy (path + len, s->dirname); /* new stuff */
> > + strcpy (path + len, dirname); /* new stuff */
> > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > }
> > }
> >
> > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > if (result < 0)
> > {
> > /* Didn't work. Try using just the basename. */
> > - p = lbasename (s->filename);
> > - if (p != s->filename)
> > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > + p = lbasename (filename);
> > + if (p != filename)
> > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > }
> >
> > if (result >= 0)
> > {
> > - fullname = s->fullname;
> > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > - xfree (fullname);
> > + char *tmp_fullname;
> > + tmp_fullname = *fullname;
> > + *fullname = mstrsave (objfile->md, *fullname);
> > + xfree (tmp_fullname);
> > }
> > return result;
> > }
> >
> > -/* Return the path to the source file associated with symtab. Returns NULL
> > - if no symtab. */
> > +/* Open a source file given a symtab S. Returns a file descriptor or
> > + negative number for error.
> > +
> > + This function is a convience function to find_and_open_source. */
> > +
> > +int
> > +open_source_file (struct symtab *s)
> > +{
> > + if (!s)
> > + return -1;
> > +
> > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > +}
> > +
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
> > char *
> > -symtab_to_filename (struct symtab *s)
> > +symtab_to_fullname (struct symtab *s)
> > {
> > - int fd;
> > + int r;
> >
> > if (!s)
> > return NULL;
> >
> > - /* If we've seen the file before, just return fullname. */
> > + /* 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);
> >
> > - if (s->fullname)
> > + if (r)
> > + {
> > + close (r);
> > return s->fullname;
> > + }
> >
> > - /* Try opening the file to setup fullname */
> > + return NULL;
> > +}
> >
> > - fd = open_source_file (s);
> > - if (fd < 0)
> > - return s->filename; /* File not found. Just use short name */
> > +/* Finds the fullname that a partial_symtab represents.
> >
> > - /* Found the file. Cleanup and return the full name */
> > + If this functions finds the fullname, it will save it in ps->fullname
> > + and it will also return the value.
> >
> > - close (fd);
> > - return s->fullname;
> > + 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)
> > + return NULL;
> > +
> > + /* 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);
> > +
> > + if (r)
> > + {
> > + close (r);
> > + return ps->fullname;
> > }
> > \f
> > + return NULL;
> > +}
> >
> > /* Create and initialize the table S->line_charpos that records
> > the positions of the lines in the source file, which is assumed
>
>
>
> > Index: gdb/source.h
> > ===================================================================
> > Index: gdb/symtab.c
> > ===================================================================
>
> These are obvious if the rest goes in.
>
>
> > Index: gdb/symtab.h
> > ===================================================================
>
> OK.
>
>
> > Index: gdb/mi/mi-cmd-file.c
> > ===================================================================
>
>
> > +static const char * const FILENAME = "filename";
> > +static const char * const FULLNAME = "fullname";
>
> I don't think these are necessary.
It just unifies the output convention I am using in the
mi-cmd-file unit. What would you prefer to see?
> >
> > /* Return to the client the absolute path and line number of the
> > current file being executed. */
> > @@ -39,7 +43,6 @@
> > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> >
> > -
> > /* Set the default file and line, also get them */
> > set_default_source_symtab_and_line();
> > st = get_current_source_symtab_and_line();
> > @@ -51,17 +54,67 @@
> > error ("mi_cmd_file_list_exec_source_file: No symtab");
> >
> > /* Extract the fullname if it is not known yet */
> > - if (st.symtab->fullname == NULL)
> > - symtab_to_filename (st.symtab);
> > -
> > - /* We may not be able to open the file (not available). */
> > - if (st.symtab->fullname == NULL)
> > - error ("mi_cmd_file_list_exec_source_file: File not found");
>
> Why get rid of the error message?
Ok.
> > + symtab_to_fullname (st.symtab);
> >
> > /* 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, "fullname", st.symtab->fullname);
> > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
I don't know. I am thinking that GDB should just return the absolute
path to all of the source files it can find. If it can not find some,
should it issue a warning? That way the front end could say, "you need
to add a directory to the source search path".
> > + return MI_CMD_DONE;
> > +}
> > +
> > +enum mi_cmd_result
> > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > +{
> > + struct symtab *s;
> > + struct partial_symtab *ps;
> > + struct objfile *objfile;
> > +
> > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > +
> > + /* Print the table header */
> > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > +
> > + /* Look at all of the symtabs */
> > + ALL_SYMTABS (objfile, s)
> > + {
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, s->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > +
> > + /* Look at all of the psymtabs */
> > + ALL_PSYMTABS (objfile, ps)
> > + {
> > + if (!ps->readin) {
>
> coding standards....
Ok.
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, ps->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > + }
> > +
> > + ui_out_end ( uiout, ui_out_type_list );
> >
> > return MI_CMD_DONE;
> > }
>
>
>
> > Index: gdb/mi/mi-cmds.c
> > ===================================================================
>
> > Index: gdb/mi/mi-cmds.h
> > ===================================================================
>
> these changes are ok.
Great!
> > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi-file.exp
> > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -55,7 +55,7 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
>
> Wouldn't this break existing MI parsers?
Yes. I figured it could be mi2. Also, for some reason, I thought no one
would be using this function since I wrote it for CGDB, and I haven't
used it yet. I have a larger plan in mind for MI, than just these 2
commands (-file-list-exec-source-file and -file-list-exec-source-files).
I would like to add the fullname to a lot of commands. However, I think
'filename' and 'fullname' should be standardized, so that front end
writers immediatly understand what they are. It is awkard to have 1
function say "file=" and another say "filename=", when those 2 words
mean the same thing.
However, if this changes isn't acceptable, I can change it back.
> > "request path info of current source file (${srcfile})"
> > }
> >
> > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi2-file.exp
> > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -47,7 +47,7 @@
> > mi_gdb_reinitialize_dir $srcdir/$subdir
> > mi_gdb_load ${binfile}
> >
> > -proc test_tbreak_creation_and_listing {} {
> > +proc test_file_list_exec_source_file {} {
> > global srcfile
> > global srcdir
> > global subdir
> > @@ -55,11 +55,21 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > "request path info of current source file (${srcfile})"
> > }
> >
> > -test_tbreak_creation_and_listing
> > +proc test_file_list_exec_source_files {} {
> > + global srcfile
> > +
> > + # get the path and absolute path to the current executable
> > + mi_gdb_test "222-file-list-exec-source-files" \
> > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
>
> > + "Getting a list of source files failed."
> ^^^^^^^
> why failed?
OOO, That isn't an error condition, it's just a comment. I see.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* -file-list-exec-source-files
@ 2004-02-26 2:06 Bob Rossi
2004-02-26 23:54 ` -file-list-exec-source-files Andrew Cagney
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-02-26 2:06 UTC (permalink / raw)
To: gdb-patches
Hi,
Any chance this will make the 6.1 release?
It would be *very* helpful if it did.
Here is an initial patch for -file-list-exec-source-files.
Some feedback would be appreciated.
I ran the testsuite and the results are the same before and after this
patch.
Index: gdb/ChangeLog
* dbxread.c (read_dbx_symtab): set pst->dirname when known
* dwarf2read.c (partial_die_info) : add dirname field
(dwarf2_build_psymtabs_hard) : set pst->dirname when known
(read_partial_die) : save away DW_AT_comp_dir
* defs.h (symtab_to_filename) : Removed.
* source.c (find_and_open_source) : Added.
(open_source_file): just calls find_and_open_source
(symtab_to_filename) : Removed.
(symtab_to_fullname, psymtab_to_fullname ) : Added.
* source.h (psymtab_to_fullname,symtab_to_fullname): Added.
* symtab.c (lookup_symtab): Call symtab_to_fullname instead of
symtab_to_filename
* symtab.h (partial_symtab): Add dirname field.
* mi/mi-cmd-file.c (FILENAME,FULLNAME): Add
(mi_cmd_file_list_exec_source_file): Call new function symtab_to_fullname
to find fullname. Print out "filename", instead of "file"
(mi_cmd_file_list_exec_source_files): Added.
* mi/mi-cmds.c (mi_cmd_mi_cmds) : Add -file-list-exec-source-files
* mi/mi-cmds.h (mi_cmd_file_list_exec_source_files): Added
Index: gdb/doc/ChangeLog
* gdb.texinfo: Add -file-list-exec-source-files doco
(-file-list-exec-source-file): change "file" to "filename"
Index: gdb/testsuite/ChangeLog
* gdb.mi/mi-file.exp: Change "file" to "filename"
* gdb.mi/mi2-file.exp:
(test_file_list_exec_source_files) Added
(test_file_list_exec_source_file) Added
(test_tbreak_creation_and_listing) Removed
Index: gdb/dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.64
diff -w -u -r1.64 dbxread.c
--- gdb/dbxread.c 14 Feb 2004 15:46:32 -0000 1.64
+++ gdb/dbxread.c 25 Feb 2004 03:51:34 -0000
@@ -1463,6 +1463,7 @@
static int prev_so_symnum = -10;
static int first_so_symnum;
char *p;
+ static char *dirname_nso;
int prev_textlow_not_set;
valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -1520,18 +1521,27 @@
p = strrchr (namestring, '/');
if (p && *(p + 1) == '\000')
- continue; /* Simply ignore directory name SOs */
+ {
+ /* Save the directory name SOs locally, then save it into
+ the psymtab when it's created below. */
+ dirname_nso = namestring;
+ continue;
+ }
/* Some other compilers (C++ ones in particular) emit useless
SOs for non-existant .c files. We ignore all subsequent SOs that
immediately follow the first. */
if (!pst)
+ {
pst = start_psymtab (objfile,
namestring, valu,
first_so_symnum * symbol_size,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = dirname_nso;
+ dirname_nso = NULL;
+ }
continue;
}
Index: gdb/defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.143
diff -w -u -r1.143 defs.h
--- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
+++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
@@ -616,8 +616,6 @@
extern void init_last_source_visited (void);
-extern char *symtab_to_filename (struct symtab *);
-
/* From exec.c */
extern void exec_set_section_offsets (bfd_signed_vma text_off,
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135
diff -w -u -r1.135 dwarf2read.c
--- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
+++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
@@ -316,6 +316,7 @@
unsigned int offset;
unsigned int abbrev;
char *name;
+ char *dirname;
int has_pc_info;
CORE_ADDR lowpc;
CORE_ADDR highpc;
@@ -1254,6 +1255,8 @@
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = xstrdup ( comp_unit_die.dirname );
+
pst->read_symtab_private = (char *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
@@ -4326,6 +4329,10 @@
/* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
if (part_die->name == NULL)
part_die->name = DW_STRING (&attr);
+ break;
+ case DW_AT_comp_dir:
+ if (part_die->dirname == NULL)
+ part_die->dirname = DW_STRING (&attr);
break;
case DW_AT_MIPS_linkage_name:
part_die->name = DW_STRING (&attr);
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.49
diff -w -u -r1.49 source.c
--- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
+++ gdb/source.c 25 Feb 2004 03:51:45 -0000
@@ -805,30 +805,47 @@
return 1;
}
-
-/* Open a source file given a symtab S. Returns a file descriptor or
- negative number for error. */
-
+/* 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.
+
+ 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.
+ FULLNAME can be the last known absolute path to the file in question.
+
+ On Success
+ A valid file descriptor is returned. ( the return value is positive )
+ FULLNAME is set to the absolute path to the file just opened.
+
+ On Failure
+ A non valid file descriptor is returned. ( the return value is negitive )
+ FULLNAME is set to NULL. */
int
-open_source_file (struct symtab *s)
+find_and_open_source (
+ struct objfile *objfile,
+ const char *filename,
+ const char *dirname,
+ char **fullname )
{
char *path = source_path;
const char *p;
int result;
- char *fullname;
/* Quick way out if we already know its full name */
- if (s->fullname)
+ if (*fullname)
{
- result = open (s->fullname, OPEN_MODE);
+ result = open (*fullname, OPEN_MODE);
if (result >= 0)
return result;
/* Didn't work -- free old one, try again. */
- xmfree (s->objfile->md, s->fullname);
- s->fullname = NULL;
+ xmfree (objfile->md, *fullname);
+ *fullname = NULL;
}
- if (s->dirname != NULL)
+ if (dirname != NULL)
{
/* Replace a path entry of $cdir with the compilation directory name */
#define cdir_len 5
@@ -841,60 +858,102 @@
int len;
path = (char *)
- alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
+ alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
len = p - source_path;
strncpy (path, source_path, len); /* Before $cdir */
- strcpy (path + len, s->dirname); /* new stuff */
+ strcpy (path + len, dirname); /* new stuff */
strcat (path + len, source_path + len + cdir_len); /* After $cdir */
}
}
- result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
+ result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
- p = lbasename (s->filename);
- if (p != s->filename)
- result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
+ p = lbasename (filename);
+ if (p != filename)
+ result = openp (path, 0, p, OPEN_MODE, 0, fullname);
}
if (result >= 0)
{
- fullname = s->fullname;
- s->fullname = mstrsave (s->objfile->md, s->fullname);
- xfree (fullname);
+ char *tmp_fullname;
+ tmp_fullname = *fullname;
+ *fullname = mstrsave (objfile->md, *fullname);
+ xfree (tmp_fullname);
}
return result;
}
-/* Return the path to the source file associated with symtab. Returns NULL
- if no symtab. */
+/* Open a source file given a symtab S. Returns a file descriptor or
+ negative number for error.
+
+ This function is a convience function to find_and_open_source. */
+
+int
+open_source_file (struct symtab *s)
+{
+ if (!s)
+ return -1;
+
+ return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
+}
+
+/* Finds the fullname that a 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 symtab represents,
+ NULL will be returned and ps->fullname will be set to NULL. */
char *
-symtab_to_filename (struct symtab *s)
+symtab_to_fullname (struct symtab *s)
{
- int fd;
+ int r;
if (!s)
return NULL;
- /* If we've seen the file before, just return fullname. */
+ /* 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);
- if (s->fullname)
+ if (r)
+ {
+ close (r);
return s->fullname;
+ }
- /* Try opening the file to setup fullname */
+ return NULL;
+}
- fd = open_source_file (s);
- if (fd < 0)
- return s->filename; /* File not found. Just use short name */
+/* Finds the fullname that a partial_symtab represents.
- /* Found the file. Cleanup and return the full name */
+ If this functions finds the fullname, it will save it in ps->fullname
+ and it will also return the value.
- close (fd);
- return s->fullname;
+ 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)
+ return NULL;
+
+ /* 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);
+
+ if (r)
+ {
+ close (r);
+ return ps->fullname;
}
\f
+ return NULL;
+}
/* Create and initialize the table S->line_charpos that records
the positions of the lines in the source file, which is assumed
Index: gdb/source.h
===================================================================
RCS file: /cvs/src/src/gdb/source.h,v
retrieving revision 1.4
diff -w -u -r1.4 source.h
--- gdb/source.h 12 Apr 2003 17:41:25 -0000 1.4
+++ gdb/source.h 25 Feb 2004 03:51:45 -0000
@@ -27,6 +27,9 @@
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 );
+
/* 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
Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.128
diff -w -u -r1.128 symtab.c
--- gdb/symtab.c 19 Feb 2004 19:01:26 -0000 1.128
+++ gdb/symtab.c 25 Feb 2004 03:51:49 -0000
@@ -181,7 +181,7 @@
if (full_path != NULL)
{
- const char *fp = symtab_to_filename (s);
+ const char *fp = symtab_to_fullname (s);
if (FILENAME_CMP (full_path, fp) == 0)
{
return s;
@@ -190,7 +190,7 @@
if (real_path != NULL)
{
- char *rp = gdb_realpath (symtab_to_filename (s));
+ char *rp = gdb_realpath (symtab_to_fullname (s));
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
Index: gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.88
diff -w -u -r1.88 symtab.h
--- gdb/symtab.h 17 Feb 2004 15:21:22 -0000 1.88
+++ gdb/symtab.h 25 Feb 2004 03:51:51 -0000
@@ -877,6 +877,10 @@
char *fullname;
+ /* Directory in which it was compiled, or NULL if we don't know. */
+
+ char *dirname;
+
/* Information about the object file from which symbols should be read. */
struct objfile *objfile;
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.196
diff -w -u -r1.196 gdb.texinfo
--- gdb/doc/gdb.texinfo 24 Feb 2004 15:41:29 -0000 1.196
+++ gdb/doc/gdb.texinfo 25 Feb 2004 03:52:19 -0000
@@ -16740,7 +16740,7 @@
@smallexample
(@value{GDBP})
123-file-list-exec-source-file
-123^done,line="1",file="foo.c",fullname="/home/bar/foo.c"
+123^done,line="1",filename="foo.c",fullname="/home/bar/foo.c"
(@value{GDBP})
@end smallexample
@@ -16756,14 +16756,24 @@
List the source files for the current executable.
+It will always output the filename, but only when GDB can find the absolute
+path to a source file, will it output the fullname.
+
@subsubheading @value{GDBN} Command
There's no @value{GDBN} command which directly corresponds to this one.
@code{gdbtk} has an analogous command @samp{gdb_listfiles}.
@subsubheading Example
-N.A.
-
+@smallexample
+(@value{GDBP})
+-file-list-exec-source-files
+^done,files=[
+@{filename=foo.c,fullname=/home/foo.c@},
+@{filename=/home/bar.c,fullname=/home/bar.c@},
+@{filename=gdb_could_not_find_fullpath.c@}]
+(@value{GDBP})
+@end smallexample
@subheading The @code{-file-list-shared-libraries} Command
@findex -file-list-shared-libraries
Index: gdb/mi/mi-cmd-file.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
retrieving revision 1.1
diff -w -u -r1.1 mi-cmd-file.c
--- gdb/mi/mi-cmd-file.c 2 Apr 2003 22:10:35 -0000 1.1
+++ gdb/mi/mi-cmd-file.c 25 Feb 2004 03:52:20 -0000
@@ -25,6 +25,10 @@
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
+#include "objfiles.h"
+
+static const char * const FILENAME = "filename";
+static const char * const FULLNAME = "fullname";
/* Return to the client the absolute path and line number of the
current file being executed. */
@@ -39,7 +43,6 @@
if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
-
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
@@ -51,17 +54,67 @@
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
- if (st.symtab->fullname == NULL)
- symtab_to_filename (st.symtab);
-
- /* We may not be able to open the file (not available). */
- if (st.symtab->fullname == NULL)
- error ("mi_cmd_file_list_exec_source_file: File not found");
+ symtab_to_fullname (st.symtab);
/* 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, "fullname", st.symtab->fullname);
+ ui_out_field_string (uiout, FILENAME, st.symtab->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);
+
+ return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
+{
+ struct symtab *s;
+ struct partial_symtab *ps;
+ struct objfile *objfile;
+
+ if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
+ error ("mi_cmd_file_list_exec_source_files: Usage: No args");
+
+ /* Print the table header */
+ ui_out_begin ( uiout, ui_out_type_list, "files");
+
+ /* Look at all of the symtabs */
+ ALL_SYMTABS (objfile, s)
+ {
+ ui_out_begin ( uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, FILENAME, s->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);
+
+ ui_out_end ( uiout, ui_out_type_tuple );
+ }
+
+ /* Look at all of the psymtabs */
+ ALL_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin) {
+ ui_out_begin ( uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, FILENAME, ps->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);
+
+ ui_out_end ( uiout, ui_out_type_tuple );
+ }
+ }
+
+ ui_out_end ( uiout, ui_out_type_list );
return MI_CMD_DONE;
}
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.14
diff -w -u -r1.14 mi-cmds.c
--- gdb/mi/mi-cmds.c 4 Aug 2003 23:18:50 -0000 1.14
+++ gdb/mi/mi-cmds.c 25 Feb 2004 03:52:20 -0000
@@ -81,7 +81,7 @@
{ "file-exec-file", { "exec-file", 1 }, NULL, NULL },
{ "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
{ "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
- { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
+ { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
{ "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
{ "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
{ "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
Index: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.12
diff -w -u -r1.12 mi-cmds.h
--- gdb/mi/mi-cmds.h 24 Jan 2004 04:21:43 -0000 1.12
+++ gdb/mi/mi-cmds.h 25 Feb 2004 03:52:20 -0000
@@ -87,6 +87,7 @@
extern mi_cmd_args_ftype mi_cmd_exec_until;
extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
+extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
Index: gdb/testsuite/gdb.mi/mi-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi-file.exp
--- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
+++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
@@ -55,7 +55,7 @@
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
- "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
+ "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
Index: gdb/testsuite/gdb.mi/mi2-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi2-file.exp
--- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
+++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
@@ -47,7 +47,7 @@
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-proc test_tbreak_creation_and_listing {} {
+proc test_file_list_exec_source_file {} {
global srcfile
global srcdir
global subdir
@@ -55,11 +55,21 @@
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
- "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
+ "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
-test_tbreak_creation_and_listing
+proc test_file_list_exec_source_files {} {
+ global srcfile
+
+ # get the path and absolute path to the current executable
+ mi_gdb_test "222-file-list-exec-source-files" \
+ "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
+ "Getting a list of source files failed."
+}
+
+test_file_list_exec_source_file
+test_file_list_exec_source_files
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-02-26 2:06 -file-list-exec-source-files Bob Rossi
@ 2004-02-26 23:54 ` Andrew Cagney
2004-02-27 13:23 ` -file-list-exec-source-files Bob Rossi
2004-02-29 3:20 ` -file-list-exec-source-files Bob Rossi
0 siblings, 2 replies; 69+ messages in thread
From: Andrew Cagney @ 2004-02-26 23:54 UTC (permalink / raw)
To: Bob Rossi, Elena Zannoni; +Cc: gdb-patches
> Hi,
>
> Any chance this will make the 6.1 release?
> It would be *very* helpful if it did.
I'm sure it would, sigh. 6.1 is already kind of running a month late
(it was ment to be branched in january).
Since it's touching both MI and symtab, Elena (pass buck) is probably
best at reviewing it?
Andrew
> Here is an initial patch for -file-list-exec-source-files.
> Some feedback would be appreciated.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-02-26 23:54 ` -file-list-exec-source-files Andrew Cagney
@ 2004-02-27 13:23 ` Bob Rossi
2004-02-29 3:20 ` -file-list-exec-source-files Bob Rossi
1 sibling, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-02-27 13:23 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Elena Zannoni, gdb-patches
On Thu, Feb 26, 2004 at 06:53:59PM -0500, Andrew Cagney wrote:
> >Hi,
> >
> >Any chance this will make the 6.1 release?
> >It would be *very* helpful if it did.
>
> I'm sure it would, sigh. 6.1 is already kind of running a month late
> (it was ment to be branched in january).
>
> Since it's touching both MI and symtab, Elena (pass buck) is probably
> best at reviewing it?
>
I can provide any information necessary.
Thanks for your time,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-02-26 23:54 ` -file-list-exec-source-files Andrew Cagney
2004-02-27 13:23 ` -file-list-exec-source-files Bob Rossi
@ 2004-02-29 3:20 ` Bob Rossi
2004-03-02 0:33 ` -file-list-exec-source-files Bob Rossi
1 sibling, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-02-29 3:20 UTC (permalink / raw)
To: gdb-patches
On Thu, Feb 26, 2004 at 06:53:59PM -0500, Andrew Cagney wrote:
> >Hi,
> >
> >Any chance this will make the 6.1 release?
> >It would be *very* helpful if it did.
>
> I'm sure it would, sigh. 6.1 is already kind of running a month late
> (it was ment to be branched in january).
>
> Since it's touching both MI and symtab, Elena (pass buck) is probably
> best at reviewing it?
Just wondering ... how long does it usually take to get a patch
approved?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-02-29 3:20 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-02 0:33 ` Bob Rossi
2004-03-02 5:43 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
0 siblings, 2 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-02 0:33 UTC (permalink / raw)
To: gdb-patches
On Sat, Feb 28, 2004 at 12:20:07PM -0500, Bob Rossi wrote:
> On Thu, Feb 26, 2004 at 06:53:59PM -0500, Andrew Cagney wrote:
> > >Hi,
> > >
> > >Any chance this will make the 6.1 release?
> > >It would be *very* helpful if it did.
> >
> > I'm sure it would, sigh. 6.1 is already kind of running a month late
> > (it was ment to be branched in january).
> >
> > Since it's touching both MI and symtab, Elena (pass buck) is probably
> > best at reviewing it?
>
> Just wondering ... how long does it usually take to get a patch
> approved?
I am disappointed with the time it takes to have my small patches
reviewed. Being someone who doesn't contribute often to GDB, and not
knowing much about the project, what do you think my expectations should be?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 0:33 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-02 5:43 ` Eli Zaretskii
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
2004-03-19 0:09 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
1 sibling, 2 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-03-02 5:43 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> Date: Mon, 1 Mar 2004 19:33:39 -0500
> From: Bob Rossi <bob@brasko.net>
>
> I am disappointed with the time it takes to have my small patches
> reviewed. Being someone who doesn't contribute often to GDB, and not
> knowing much about the project, what do you think my expectations should be?
I think most, if not all, of the GDB maintainers share your
disappointment. Unfortunately, the question how to shorten the
patch-approval time doesn't seem to have simple answers, given the
current number of active maintainers and their available resources.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 5:43 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-03-02 15:21 ` Andrew Cagney
2004-03-02 15:28 ` -file-list-exec-source-files Bob Rossi
` (2 more replies)
2004-03-19 0:09 ` -file-list-exec-source-files Eli Zaretskii
1 sibling, 3 replies; 69+ messages in thread
From: Andrew Cagney @ 2004-03-02 15:21 UTC (permalink / raw)
To: Eli Zaretskii, Bob Rossi; +Cc: gdb-patches
>>Date: Mon, 1 Mar 2004 19:33:39 -0500
>>> From: Bob Rossi <bob@brasko.net>
>>>
>>> I am disappointed with the time it takes to have my small patches
>>> reviewed. Being someone who doesn't contribute often to GDB, and not
>>> knowing much about the project, what do you think my expectations should be?
>
>
> I think most, if not all, of the GDB maintainers share your
> disappointment. Unfortunately, the question how to shorten the
> patch-approval time doesn't seem to have simple answers, given the
> current number of active maintainers and their available resources.
Bob, if there isn't a resonse within a week, please ping.
Eli, here are the numbers for this patch:
02-24: Posted
02-25
02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
02-27: Question about when response would be
02-28: <weekend>
02-29: <weekend>
03-01: Above post
03-01: <seven days>
enjoy,
Andrew
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
@ 2004-03-02 15:28 ` Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-02 16:32 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Andrew Cagney
2 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-03-02 15:28 UTC (permalink / raw)
To: gdb-patches
On Tue, Mar 02, 2004 at 10:21:31AM -0500, Andrew Cagney wrote:
> >>Date: Mon, 1 Mar 2004 19:33:39 -0500
> >>>From: Bob Rossi <bob@brasko.net>
> >>>
> >>>I am disappointed with the time it takes to have my small patches
> >>>reviewed. Being someone who doesn't contribute often to GDB, and not
> >>>knowing much about the project, what do you think my expectations should
> >>>be?
> >
> >
> >I think most, if not all, of the GDB maintainers share your
> >disappointment. Unfortunately, the question how to shorten the
> >patch-approval time doesn't seem to have simple answers, given the
> >current number of active maintainers and their available resources.
>
> Bob, if there isn't a resonse within a week, please ping.
> Eli, here are the numbers for this patch:
>
> 02-24: Posted
> 02-25
> 02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
> 02-27: Question about when response would be
> 02-28: <weekend>
> 02-29: <weekend>
> 03-01: Above post
> 03-01: <seven days>
Ok. Thanks.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 15:28 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-19 0:09 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches
On Tue, Mar 02, 2004 at 10:21:31AM -0500, Andrew Cagney wrote:
> >>Date: Mon, 1 Mar 2004 19:33:39 -0500
> >>>From: Bob Rossi <bob@brasko.net>
> >>>
> >>>I am disappointed with the time it takes to have my small patches
> >>>reviewed. Being someone who doesn't contribute often to GDB, and not
> >>>knowing much about the project, what do you think my expectations should
> >>>be?
> >
> >
> >I think most, if not all, of the GDB maintainers share your
> >disappointment. Unfortunately, the question how to shorten the
> >patch-approval time doesn't seem to have simple answers, given the
> >current number of active maintainers and their available resources.
>
> Bob, if there isn't a resonse within a week, please ping.
> Eli, here are the numbers for this patch:
>
> 02-24: Posted
> 02-25
> 02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
> 02-27: Question about when response would be
> 02-28: <weekend>
> 02-29: <weekend>
> 03-01: Above post
> 03-01: <seven days>
Ok. Thanks.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
2004-03-02 15:28 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-02 16:32 ` Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Andrew Cagney
2 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-03-02 16:32 UTC (permalink / raw)
To: Andrew Cagney; +Cc: bob, gdb-patches
> Date: Tue, 02 Mar 2004 10:21:31 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> Eli, here are the numbers for this patch:
>
> 02-24: Posted
> 02-25
> 02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
> 02-27: Question about when response would be
> 02-28: <weekend>
> 02-29: <weekend>
> 03-01: Above post
> 03-01: <seven days>
Thanks.
My personal, perhaps not-so-objective, opinion is that this isn't too
bad.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 16:32 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-03-19 0:09 ` Eli Zaretskii
0 siblings, 0 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-03-19 0:09 UTC (permalink / raw)
To: Andrew Cagney; +Cc: bob, gdb-patches
> Date: Tue, 02 Mar 2004 10:21:31 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> Eli, here are the numbers for this patch:
>
> 02-24: Posted
> 02-25
> 02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
> 02-27: Question about when response would be
> 02-28: <weekend>
> 02-29: <weekend>
> 03-01: Above post
> 03-01: <seven days>
Thanks.
My personal, perhaps not-so-objective, opinion is that this isn't too
bad.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
2004-03-02 15:28 ` -file-list-exec-source-files Bob Rossi
2004-03-02 16:32 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-03-19 0:09 ` Andrew Cagney
2 siblings, 0 replies; 69+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Eli Zaretskii, Bob Rossi; +Cc: gdb-patches
>>Date: Mon, 1 Mar 2004 19:33:39 -0500
>>> From: Bob Rossi <bob@brasko.net>
>>>
>>> I am disappointed with the time it takes to have my small patches
>>> reviewed. Being someone who doesn't contribute often to GDB, and not
>>> knowing much about the project, what do you think my expectations should be?
>
>
> I think most, if not all, of the GDB maintainers share your
> disappointment. Unfortunately, the question how to shorten the
> patch-approval time doesn't seem to have simple answers, given the
> current number of active maintainers and their available resources.
Bob, if there isn't a resonse within a week, please ping.
Eli, here are the numbers for this patch:
02-24: Posted
02-25
02-26: I responded, passed buck to Elena, should have To:ed Elena :-(
02-27: Question about when response would be
02-28: <weekend>
02-29: <weekend>
03-01: Above post
03-01: <seven days>
enjoy,
Andrew
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 5:43 ` -file-list-exec-source-files Eli Zaretskii
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
@ 2004-03-19 0:09 ` Eli Zaretskii
1 sibling, 0 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-03-19 0:09 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> Date: Mon, 1 Mar 2004 19:33:39 -0500
> From: Bob Rossi <bob@brasko.net>
>
> I am disappointed with the time it takes to have my small patches
> reviewed. Being someone who doesn't contribute often to GDB, and not
> knowing much about the project, what do you think my expectations should be?
I think most, if not all, of the GDB maintainers share your
disappointment. Unfortunately, the question how to shorten the
patch-approval time doesn't seem to have simple answers, given the
current number of active maintainers and their available resources.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-02 0:33 ` -file-list-exec-source-files Bob Rossi
2004-03-02 5:43 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-03-19 0:09 ` Bob Rossi
1 sibling, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches
On Sat, Feb 28, 2004 at 12:20:07PM -0500, Bob Rossi wrote:
> On Thu, Feb 26, 2004 at 06:53:59PM -0500, Andrew Cagney wrote:
> > >Hi,
> > >
> > >Any chance this will make the 6.1 release?
> > >It would be *very* helpful if it did.
> >
> > I'm sure it would, sigh. 6.1 is already kind of running a month late
> > (it was ment to be branched in january).
> >
> > Since it's touching both MI and symtab, Elena (pass buck) is probably
> > best at reviewing it?
>
> Just wondering ... how long does it usually take to get a patch
> approved?
I am disappointed with the time it takes to have my small patches
reviewed. Being someone who doesn't contribute often to GDB, and not
knowing much about the project, what do you think my expectations should be?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* -file-list-exec-source-files
@ 2004-02-25 4:01 Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Elena Zannoni
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-02-25 4:01 UTC (permalink / raw)
To: gdb-patches
Hi,
Here is an initial patch for -file-list-exec-source-files.
Some feedback would be appreciated.
I ran the testsuite and the results are the same before and after this
patch.
Index: gdb/ChangeLog
* dbxread.c (read_dbx_symtab): set pst->dirname when known
* dwarf2read.c (partial_die_info) : add dirname field
(dwarf2_build_psymtabs_hard) : set pst->dirname when known
(read_partial_die) : save away DW_AT_comp_dir
* defs.h (symtab_to_filename) : Removed.
* source.c (find_and_open_source) : Added.
(open_source_file): just calls find_and_open_source
(symtab_to_filename) : Removed.
(symtab_to_fullname, psymtab_to_fullname ) : Added.
* source.h (psymtab_to_fullname,symtab_to_fullname): Added.
* symtab.c (lookup_symtab): Call symtab_to_fullname instead of
symtab_to_filename
* symtab.h (partial_symtab): Add dirname field.
* mi/mi-cmd-file.c (FILENAME,FULLNAME): Add
(mi_cmd_file_list_exec_source_file): Call new function symtab_to_fullname
to find fullname. Print out "filename", instead of "file"
(mi_cmd_file_list_exec_source_files): Added.
* mi/mi-cmds.c (mi_cmd_mi_cmds) : Add -file-list-exec-source-files
* mi/mi-cmds.h (mi_cmd_file_list_exec_source_files): Added
Index: gdb/doc/ChangeLog
* gdb.texinfo: Add -file-list-exec-source-files doco
(-file-list-exec-source-file): change "file" to "filename"
Index: gdb/testsuite/ChangeLog
* gdb.mi/mi-file.exp: Change "file" to "filename"
* gdb.mi/mi2-file.exp:
(test_file_list_exec_source_files) Added
(test_file_list_exec_source_file) Added
(test_tbreak_creation_and_listing) Removed
Index: gdb/dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.64
diff -w -u -r1.64 dbxread.c
--- gdb/dbxread.c 14 Feb 2004 15:46:32 -0000 1.64
+++ gdb/dbxread.c 25 Feb 2004 03:51:34 -0000
@@ -1463,6 +1463,7 @@
static int prev_so_symnum = -10;
static int first_so_symnum;
char *p;
+ static char *dirname_nso;
int prev_textlow_not_set;
valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -1520,18 +1521,27 @@
p = strrchr (namestring, '/');
if (p && *(p + 1) == '\000')
- continue; /* Simply ignore directory name SOs */
+ {
+ /* Save the directory name SOs locally, then save it into
+ the psymtab when it's created below. */
+ dirname_nso = namestring;
+ continue;
+ }
/* Some other compilers (C++ ones in particular) emit useless
SOs for non-existant .c files. We ignore all subsequent SOs that
immediately follow the first. */
if (!pst)
+ {
pst = start_psymtab (objfile,
namestring, valu,
first_so_symnum * symbol_size,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = dirname_nso;
+ dirname_nso = NULL;
+ }
continue;
}
Index: gdb/defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.143
diff -w -u -r1.143 defs.h
--- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
+++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
@@ -616,8 +616,6 @@
extern void init_last_source_visited (void);
-extern char *symtab_to_filename (struct symtab *);
-
/* From exec.c */
extern void exec_set_section_offsets (bfd_signed_vma text_off,
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135
diff -w -u -r1.135 dwarf2read.c
--- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
+++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
@@ -316,6 +316,7 @@
unsigned int offset;
unsigned int abbrev;
char *name;
+ char *dirname;
int has_pc_info;
CORE_ADDR lowpc;
CORE_ADDR highpc;
@@ -1254,6 +1255,8 @@
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = xstrdup ( comp_unit_die.dirname );
+
pst->read_symtab_private = (char *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
@@ -4326,6 +4329,10 @@
/* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
if (part_die->name == NULL)
part_die->name = DW_STRING (&attr);
+ break;
+ case DW_AT_comp_dir:
+ if (part_die->dirname == NULL)
+ part_die->dirname = DW_STRING (&attr);
break;
case DW_AT_MIPS_linkage_name:
part_die->name = DW_STRING (&attr);
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.49
diff -w -u -r1.49 source.c
--- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
+++ gdb/source.c 25 Feb 2004 03:51:45 -0000
@@ -805,30 +805,47 @@
return 1;
}
-
-/* Open a source file given a symtab S. Returns a file descriptor or
- negative number for error. */
-
+/* 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.
+
+ 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.
+ FULLNAME can be the last known absolute path to the file in question.
+
+ On Success
+ A valid file descriptor is returned. ( the return value is positive )
+ FULLNAME is set to the absolute path to the file just opened.
+
+ On Failure
+ A non valid file descriptor is returned. ( the return value is negitive )
+ FULLNAME is set to NULL. */
int
-open_source_file (struct symtab *s)
+find_and_open_source (
+ struct objfile *objfile,
+ const char *filename,
+ const char *dirname,
+ char **fullname )
{
char *path = source_path;
const char *p;
int result;
- char *fullname;
/* Quick way out if we already know its full name */
- if (s->fullname)
+ if (*fullname)
{
- result = open (s->fullname, OPEN_MODE);
+ result = open (*fullname, OPEN_MODE);
if (result >= 0)
return result;
/* Didn't work -- free old one, try again. */
- xmfree (s->objfile->md, s->fullname);
- s->fullname = NULL;
+ xmfree (objfile->md, *fullname);
+ *fullname = NULL;
}
- if (s->dirname != NULL)
+ if (dirname != NULL)
{
/* Replace a path entry of $cdir with the compilation directory name */
#define cdir_len 5
@@ -841,60 +858,102 @@
int len;
path = (char *)
- alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
+ alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
len = p - source_path;
strncpy (path, source_path, len); /* Before $cdir */
- strcpy (path + len, s->dirname); /* new stuff */
+ strcpy (path + len, dirname); /* new stuff */
strcat (path + len, source_path + len + cdir_len); /* After $cdir */
}
}
- result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
+ result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
- p = lbasename (s->filename);
- if (p != s->filename)
- result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
+ p = lbasename (filename);
+ if (p != filename)
+ result = openp (path, 0, p, OPEN_MODE, 0, fullname);
}
if (result >= 0)
{
- fullname = s->fullname;
- s->fullname = mstrsave (s->objfile->md, s->fullname);
- xfree (fullname);
+ char *tmp_fullname;
+ tmp_fullname = *fullname;
+ *fullname = mstrsave (objfile->md, *fullname);
+ xfree (tmp_fullname);
}
return result;
}
-/* Return the path to the source file associated with symtab. Returns NULL
- if no symtab. */
+/* Open a source file given a symtab S. Returns a file descriptor or
+ negative number for error.
+
+ This function is a convience function to find_and_open_source. */
+
+int
+open_source_file (struct symtab *s)
+{
+ if (!s)
+ return -1;
+
+ return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
+}
+
+/* Finds the fullname that a 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 symtab represents,
+ NULL will be returned and ps->fullname will be set to NULL. */
char *
-symtab_to_filename (struct symtab *s)
+symtab_to_fullname (struct symtab *s)
{
- int fd;
+ int r;
if (!s)
return NULL;
- /* If we've seen the file before, just return fullname. */
+ /* 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);
- if (s->fullname)
+ if (r)
+ {
+ close (r);
return s->fullname;
+ }
- /* Try opening the file to setup fullname */
+ return NULL;
+}
- fd = open_source_file (s);
- if (fd < 0)
- return s->filename; /* File not found. Just use short name */
+/* Finds the fullname that a partial_symtab represents.
- /* Found the file. Cleanup and return the full name */
+ If this functions finds the fullname, it will save it in ps->fullname
+ and it will also return the value.
- close (fd);
- return s->fullname;
+ 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)
+ return NULL;
+
+ /* 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);
+
+ if (r)
+ {
+ close (r);
+ return ps->fullname;
}
\f
+ return NULL;
+}
/* Create and initialize the table S->line_charpos that records
the positions of the lines in the source file, which is assumed
Index: gdb/source.h
===================================================================
RCS file: /cvs/src/src/gdb/source.h,v
retrieving revision 1.4
diff -w -u -r1.4 source.h
--- gdb/source.h 12 Apr 2003 17:41:25 -0000 1.4
+++ gdb/source.h 25 Feb 2004 03:51:45 -0000
@@ -27,6 +27,9 @@
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 );
+
/* 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
Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.128
diff -w -u -r1.128 symtab.c
--- gdb/symtab.c 19 Feb 2004 19:01:26 -0000 1.128
+++ gdb/symtab.c 25 Feb 2004 03:51:49 -0000
@@ -181,7 +181,7 @@
if (full_path != NULL)
{
- const char *fp = symtab_to_filename (s);
+ const char *fp = symtab_to_fullname (s);
if (FILENAME_CMP (full_path, fp) == 0)
{
return s;
@@ -190,7 +190,7 @@
if (real_path != NULL)
{
- char *rp = gdb_realpath (symtab_to_filename (s));
+ char *rp = gdb_realpath (symtab_to_fullname (s));
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
Index: gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.88
diff -w -u -r1.88 symtab.h
--- gdb/symtab.h 17 Feb 2004 15:21:22 -0000 1.88
+++ gdb/symtab.h 25 Feb 2004 03:51:51 -0000
@@ -877,6 +877,10 @@
char *fullname;
+ /* Directory in which it was compiled, or NULL if we don't know. */
+
+ char *dirname;
+
/* Information about the object file from which symbols should be read. */
struct objfile *objfile;
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.196
diff -w -u -r1.196 gdb.texinfo
--- gdb/doc/gdb.texinfo 24 Feb 2004 15:41:29 -0000 1.196
+++ gdb/doc/gdb.texinfo 25 Feb 2004 03:52:19 -0000
@@ -16740,7 +16740,7 @@
@smallexample
(@value{GDBP})
123-file-list-exec-source-file
-123^done,line="1",file="foo.c",fullname="/home/bar/foo.c"
+123^done,line="1",filename="foo.c",fullname="/home/bar/foo.c"
(@value{GDBP})
@end smallexample
@@ -16756,14 +16756,24 @@
List the source files for the current executable.
+It will always output the filename, but only when GDB can find the absolute
+path to a source file, will it output the fullname.
+
@subsubheading @value{GDBN} Command
There's no @value{GDBN} command which directly corresponds to this one.
@code{gdbtk} has an analogous command @samp{gdb_listfiles}.
@subsubheading Example
-N.A.
-
+@smallexample
+(@value{GDBP})
+-file-list-exec-source-files
+^done,files=[
+@{filename=foo.c,fullname=/home/foo.c@},
+@{filename=/home/bar.c,fullname=/home/bar.c@},
+@{filename=gdb_could_not_find_fullpath.c@}]
+(@value{GDBP})
+@end smallexample
@subheading The @code{-file-list-shared-libraries} Command
@findex -file-list-shared-libraries
Index: gdb/mi/mi-cmd-file.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
retrieving revision 1.1
diff -w -u -r1.1 mi-cmd-file.c
--- gdb/mi/mi-cmd-file.c 2 Apr 2003 22:10:35 -0000 1.1
+++ gdb/mi/mi-cmd-file.c 25 Feb 2004 03:52:20 -0000
@@ -25,6 +25,10 @@
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
+#include "objfiles.h"
+
+static const char * const FILENAME = "filename";
+static const char * const FULLNAME = "fullname";
/* Return to the client the absolute path and line number of the
current file being executed. */
@@ -39,7 +43,6 @@
if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
-
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
@@ -51,17 +54,67 @@
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
- if (st.symtab->fullname == NULL)
- symtab_to_filename (st.symtab);
-
- /* We may not be able to open the file (not available). */
- if (st.symtab->fullname == NULL)
- error ("mi_cmd_file_list_exec_source_file: File not found");
+ symtab_to_fullname (st.symtab);
/* 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, "fullname", st.symtab->fullname);
+ ui_out_field_string (uiout, FILENAME, st.symtab->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);
+
+ return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
+{
+ struct symtab *s;
+ struct partial_symtab *ps;
+ struct objfile *objfile;
+
+ if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
+ error ("mi_cmd_file_list_exec_source_files: Usage: No args");
+
+ /* Print the table header */
+ ui_out_begin ( uiout, ui_out_type_list, "files");
+
+ /* Look at all of the symtabs */
+ ALL_SYMTABS (objfile, s)
+ {
+ ui_out_begin ( uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, FILENAME, s->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);
+
+ ui_out_end ( uiout, ui_out_type_tuple );
+ }
+
+ /* Look at all of the psymtabs */
+ ALL_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin) {
+ ui_out_begin ( uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, FILENAME, ps->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);
+
+ ui_out_end ( uiout, ui_out_type_tuple );
+ }
+ }
+
+ ui_out_end ( uiout, ui_out_type_list );
return MI_CMD_DONE;
}
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.14
diff -w -u -r1.14 mi-cmds.c
--- gdb/mi/mi-cmds.c 4 Aug 2003 23:18:50 -0000 1.14
+++ gdb/mi/mi-cmds.c 25 Feb 2004 03:52:20 -0000
@@ -81,7 +81,7 @@
{ "file-exec-file", { "exec-file", 1 }, NULL, NULL },
{ "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
{ "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
- { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
+ { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
{ "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
{ "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
{ "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
Index: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.12
diff -w -u -r1.12 mi-cmds.h
--- gdb/mi/mi-cmds.h 24 Jan 2004 04:21:43 -0000 1.12
+++ gdb/mi/mi-cmds.h 25 Feb 2004 03:52:20 -0000
@@ -87,6 +87,7 @@
extern mi_cmd_args_ftype mi_cmd_exec_until;
extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
+extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
Index: gdb/testsuite/gdb.mi/mi-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi-file.exp
--- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
+++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
@@ -55,7 +55,7 @@
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
- "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
+ "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
Index: gdb/testsuite/gdb.mi/mi2-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi2-file.exp
--- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
+++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
@@ -47,7 +47,7 @@
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-proc test_tbreak_creation_and_listing {} {
+proc test_file_list_exec_source_file {} {
global srcfile
global srcdir
global subdir
@@ -55,11 +55,21 @@
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
- "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
+ "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
-test_tbreak_creation_and_listing
+proc test_file_list_exec_source_files {} {
+ global srcfile
+
+ # get the path and absolute path to the current executable
+ mi_gdb_test "222-file-list-exec-source-files" \
+ "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
+ "Getting a list of source files failed."
+}
+
+test_file_list_exec_source_file
+test_file_list_exec_source_files
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-02-25 4:01 -file-list-exec-source-files Bob Rossi
@ 2004-03-19 0:09 ` Elena Zannoni
2004-03-05 22:36 ` -file-list-exec-source-files Elena Zannoni
` (2 more replies)
0 siblings, 3 replies; 69+ messages in thread
From: Elena Zannoni @ 2004-03-19 0:09 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
Bob Rossi writes:
> Hi,
>
> Here is an initial patch for -file-list-exec-source-files.
> Some feedback would be appreciated.
>
> I ran the testsuite and the results are the same before and after this
> patch.
>
> Index: gdb/ChangeLog
> * dbxread.c (read_dbx_symtab): set pst->dirname when known
Each entry should start with capital letter and end with period.
I see some coding standards are not adhered to throughout the code.
Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
calls.
>
> Index: gdb/dbxread.c
> ===================================================================
> Index: gdb/dwarf2read.c
> ===================================================================
These are ok
>
> Index: gdb/defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.143
> diff -w -u -r1.143 defs.h
> --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> @@ -616,8 +616,6 @@
>
> extern void init_last_source_visited (void);
>
> -extern char *symtab_to_filename (struct symtab *);
> -
> /* From exec.c */
>
> extern void exec_set_section_offsets (bfd_signed_vma text_off,
> Index: gdb/dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.135
> diff -w -u -r1.135 dwarf2read.c
> --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> @@ -316,6 +316,7 @@
> unsigned int offset;
> unsigned int abbrev;
> char *name;
> + char *dirname;
> int has_pc_info;
> CORE_ADDR lowpc;
> CORE_ADDR highpc;
> @@ -1254,6 +1255,8 @@
> objfile->global_psymbols.next,
> objfile->static_psymbols.next);
>
> + pst->dirname = xstrdup ( comp_unit_die.dirname );
> +
> pst->read_symtab_private = (char *)
> obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> @@ -4326,6 +4329,10 @@
> /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> if (part_die->name == NULL)
> part_die->name = DW_STRING (&attr);
> + break;
> + case DW_AT_comp_dir:
> + if (part_die->dirname == NULL)
> + part_die->dirname = DW_STRING (&attr);
The dwarf2 specs say that the name is in the form ":pathname" or
"hostname:pathname". Should we worry about the hostname? Does gcc emit
that? I have looked at a few executables and didn't see the hostname
part.
> Index: gdb/source.c
> ===================================================================
this part I am not clear about.
There is already a function called source_full_path_of() would it help
if you used it?
What is the difference between find_and_open_source and
open_source_file? I.e. why did you need to introduce it. I think it's
not clear just from your comments about the file possibly baing moved
around.
I am a bit worried about the substitution of symtab_to_filename with
symtab_to_fullname. The former returns null only if there is no
symtab. The latter returns null when there is no symtab OR when it
cannot find the file. So the behavior is slightly different.
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.49
> diff -w -u -r1.49 source.c
> --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> @@ -805,30 +805,47 @@
> return 1;
> }
>
> -
> -/* Open a source file given a symtab S. Returns a file descriptor or
> - negative number for error. */
> -
> +/* 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.
> +
> + 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.
> + FULLNAME can be the last known absolute path to the file in question.
> +
> + On Success
> + A valid file descriptor is returned. ( the return value is positive )
> + FULLNAME is set to the absolute path to the file just opened.
> +
> + On Failure
> + A non valid file descriptor is returned. ( the return value is negitive )
> + FULLNAME is set to NULL. */
> int
> -open_source_file (struct symtab *s)
> +find_and_open_source (
> + struct objfile *objfile,
> + const char *filename,
> + const char *dirname,
> + char **fullname )
> {
coding standards....
> char *path = source_path;
> const char *p;
> int result;
> - char *fullname;
>
> /* Quick way out if we already know its full name */
> - if (s->fullname)
> + if (*fullname)
> {
> - result = open (s->fullname, OPEN_MODE);
> + result = open (*fullname, OPEN_MODE);
> if (result >= 0)
> return result;
> /* Didn't work -- free old one, try again. */
> - xmfree (s->objfile->md, s->fullname);
> - s->fullname = NULL;
> + xmfree (objfile->md, *fullname);
> + *fullname = NULL;
> }
>
> - if (s->dirname != NULL)
> + if (dirname != NULL)
> {
> /* Replace a path entry of $cdir with the compilation directory name */
> #define cdir_len 5
> @@ -841,60 +858,102 @@
> int len;
>
> path = (char *)
> - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> len = p - source_path;
> strncpy (path, source_path, len); /* Before $cdir */
> - strcpy (path + len, s->dirname); /* new stuff */
> + strcpy (path + len, dirname); /* new stuff */
> strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> }
> }
>
> - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> if (result < 0)
> {
> /* Didn't work. Try using just the basename. */
> - p = lbasename (s->filename);
> - if (p != s->filename)
> - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> + p = lbasename (filename);
> + if (p != filename)
> + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> }
>
> if (result >= 0)
> {
> - fullname = s->fullname;
> - s->fullname = mstrsave (s->objfile->md, s->fullname);
> - xfree (fullname);
> + char *tmp_fullname;
> + tmp_fullname = *fullname;
> + *fullname = mstrsave (objfile->md, *fullname);
> + xfree (tmp_fullname);
> }
> return result;
> }
>
> -/* Return the path to the source file associated with symtab. Returns NULL
> - if no symtab. */
> +/* Open a source file given a symtab S. Returns a file descriptor or
> + negative number for error.
> +
> + This function is a convience function to find_and_open_source. */
> +
> +int
> +open_source_file (struct symtab *s)
> +{
> + if (!s)
> + return -1;
> +
> + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> +}
> +
> +/* Finds the fullname that a 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 symtab represents,
> + NULL will be returned and ps->fullname will be set to NULL. */
> char *
> -symtab_to_filename (struct symtab *s)
> +symtab_to_fullname (struct symtab *s)
> {
> - int fd;
> + int r;
>
> if (!s)
> return NULL;
>
> - /* If we've seen the file before, just return fullname. */
> + /* 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);
>
> - if (s->fullname)
> + if (r)
> + {
> + close (r);
> return s->fullname;
> + }
>
> - /* Try opening the file to setup fullname */
> + return NULL;
> +}
>
> - fd = open_source_file (s);
> - if (fd < 0)
> - return s->filename; /* File not found. Just use short name */
> +/* Finds the fullname that a partial_symtab represents.
>
> - /* Found the file. Cleanup and return the full name */
> + If this functions finds the fullname, it will save it in ps->fullname
> + and it will also return the value.
>
> - close (fd);
> - return s->fullname;
> + 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)
> + return NULL;
> +
> + /* 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);
> +
> + if (r)
> + {
> + close (r);
> + return ps->fullname;
> }
> \f
> + return NULL;
> +}
>
> /* Create and initialize the table S->line_charpos that records
> the positions of the lines in the source file, which is assumed
> Index: gdb/source.h
> ===================================================================
> Index: gdb/symtab.c
> ===================================================================
These are obvious if the rest goes in.
> Index: gdb/symtab.h
> ===================================================================
OK.
> Index: gdb/mi/mi-cmd-file.c
> ===================================================================
> +static const char * const FILENAME = "filename";
> +static const char * const FULLNAME = "fullname";
I don't think these are necessary.
>
> /* Return to the client the absolute path and line number of the
> current file being executed. */
> @@ -39,7 +43,6 @@
> if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> error ("mi_cmd_file_list_exec_source_file: Usage: No args");
>
> -
> /* Set the default file and line, also get them */
> set_default_source_symtab_and_line();
> st = get_current_source_symtab_and_line();
> @@ -51,17 +54,67 @@
> error ("mi_cmd_file_list_exec_source_file: No symtab");
>
> /* Extract the fullname if it is not known yet */
> - if (st.symtab->fullname == NULL)
> - symtab_to_filename (st.symtab);
> -
> - /* We may not be able to open the file (not available). */
> - if (st.symtab->fullname == NULL)
> - error ("mi_cmd_file_list_exec_source_file: File not found");
Why get rid of the error message?
> + symtab_to_fullname (st.symtab);
>
> /* 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, "fullname", st.symtab->fullname);
> + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> + return MI_CMD_DONE;
> +}
> +
> +enum mi_cmd_result
> +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> +{
> + struct symtab *s;
> + struct partial_symtab *ps;
> + struct objfile *objfile;
> +
> + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> +
> + /* Print the table header */
> + ui_out_begin ( uiout, ui_out_type_list, "files");
> +
> + /* Look at all of the symtabs */
> + ALL_SYMTABS (objfile, s)
> + {
> + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, FILENAME, s->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);
> +
> + ui_out_end ( uiout, ui_out_type_tuple );
> + }
> +
> + /* Look at all of the psymtabs */
> + ALL_PSYMTABS (objfile, ps)
> + {
> + if (!ps->readin) {
coding standards....
> + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, FILENAME, ps->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);
> +
> + ui_out_end ( uiout, ui_out_type_tuple );
> + }
> + }
> +
> + ui_out_end ( uiout, ui_out_type_list );
>
> return MI_CMD_DONE;
> }
> Index: gdb/mi/mi-cmds.c
> ===================================================================
> Index: gdb/mi/mi-cmds.h
> ===================================================================
these changes are ok.
> Index: gdb/testsuite/gdb.mi/mi-file.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi-file.exp
> --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> @@ -55,7 +55,7 @@
>
> # get the path and absolute path to the current executable
> mi_gdb_test "111-file-list-exec-source-file" \
> - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
Wouldn't this break existing MI parsers?
> "request path info of current source file (${srcfile})"
> }
>
> Index: gdb/testsuite/gdb.mi/mi2-file.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi2-file.exp
> --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> @@ -47,7 +47,7 @@
> mi_gdb_reinitialize_dir $srcdir/$subdir
> mi_gdb_load ${binfile}
>
> -proc test_tbreak_creation_and_listing {} {
> +proc test_file_list_exec_source_file {} {
> global srcfile
> global srcdir
> global subdir
> @@ -55,11 +55,21 @@
>
> # get the path and absolute path to the current executable
> mi_gdb_test "111-file-list-exec-source-file" \
> - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> "request path info of current source file (${srcfile})"
> }
>
> -test_tbreak_creation_and_listing
> +proc test_file_list_exec_source_files {} {
> + global srcfile
> +
> + # get the path and absolute path to the current executable
> + mi_gdb_test "222-file-list-exec-source-files" \
> + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> + "Getting a list of source files failed."
^^^^^^^
why failed?
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Elena Zannoni
@ 2004-03-05 22:36 ` Elena Zannoni
2004-03-19 0:09 ` -file-list-exec-source-files Jason Molenda
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2 siblings, 0 replies; 69+ messages in thread
From: Elena Zannoni @ 2004-03-05 22:36 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
Bob Rossi writes:
> Hi,
>
> Here is an initial patch for -file-list-exec-source-files.
> Some feedback would be appreciated.
>
> I ran the testsuite and the results are the same before and after this
> patch.
>
> Index: gdb/ChangeLog
> * dbxread.c (read_dbx_symtab): set pst->dirname when known
Each entry should start with capital letter and end with period.
I see some coding standards are not adhered to throughout the code.
Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
calls.
>
> Index: gdb/dbxread.c
> ===================================================================
> Index: gdb/dwarf2read.c
> ===================================================================
These are ok
>
> Index: gdb/defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.143
> diff -w -u -r1.143 defs.h
> --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> @@ -616,8 +616,6 @@
>
> extern void init_last_source_visited (void);
>
> -extern char *symtab_to_filename (struct symtab *);
> -
> /* From exec.c */
>
> extern void exec_set_section_offsets (bfd_signed_vma text_off,
> Index: gdb/dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.135
> diff -w -u -r1.135 dwarf2read.c
> --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> @@ -316,6 +316,7 @@
> unsigned int offset;
> unsigned int abbrev;
> char *name;
> + char *dirname;
> int has_pc_info;
> CORE_ADDR lowpc;
> CORE_ADDR highpc;
> @@ -1254,6 +1255,8 @@
> objfile->global_psymbols.next,
> objfile->static_psymbols.next);
>
> + pst->dirname = xstrdup ( comp_unit_die.dirname );
> +
> pst->read_symtab_private = (char *)
> obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> @@ -4326,6 +4329,10 @@
> /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> if (part_die->name == NULL)
> part_die->name = DW_STRING (&attr);
> + break;
> + case DW_AT_comp_dir:
> + if (part_die->dirname == NULL)
> + part_die->dirname = DW_STRING (&attr);
The dwarf2 specs say that the name is in the form ":pathname" or
"hostname:pathname". Should we worry about the hostname? Does gcc emit
that? I have looked at a few executables and didn't see the hostname
part.
> Index: gdb/source.c
> ===================================================================
this part I am not clear about.
There is already a function called source_full_path_of() would it help
if you used it?
What is the difference between find_and_open_source and
open_source_file? I.e. why did you need to introduce it. I think it's
not clear just from your comments about the file possibly baing moved
around.
I am a bit worried about the substitution of symtab_to_filename with
symtab_to_fullname. The former returns null only if there is no
symtab. The latter returns null when there is no symtab OR when it
cannot find the file. So the behavior is slightly different.
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.49
> diff -w -u -r1.49 source.c
> --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> @@ -805,30 +805,47 @@
> return 1;
> }
>
> -
> -/* Open a source file given a symtab S. Returns a file descriptor or
> - negative number for error. */
> -
> +/* 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.
> +
> + 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.
> + FULLNAME can be the last known absolute path to the file in question.
> +
> + On Success
> + A valid file descriptor is returned. ( the return value is positive )
> + FULLNAME is set to the absolute path to the file just opened.
> +
> + On Failure
> + A non valid file descriptor is returned. ( the return value is negitive )
> + FULLNAME is set to NULL. */
> int
> -open_source_file (struct symtab *s)
> +find_and_open_source (
> + struct objfile *objfile,
> + const char *filename,
> + const char *dirname,
> + char **fullname )
> {
coding standards....
> char *path = source_path;
> const char *p;
> int result;
> - char *fullname;
>
> /* Quick way out if we already know its full name */
> - if (s->fullname)
> + if (*fullname)
> {
> - result = open (s->fullname, OPEN_MODE);
> + result = open (*fullname, OPEN_MODE);
> if (result >= 0)
> return result;
> /* Didn't work -- free old one, try again. */
> - xmfree (s->objfile->md, s->fullname);
> - s->fullname = NULL;
> + xmfree (objfile->md, *fullname);
> + *fullname = NULL;
> }
>
> - if (s->dirname != NULL)
> + if (dirname != NULL)
> {
> /* Replace a path entry of $cdir with the compilation directory name */
> #define cdir_len 5
> @@ -841,60 +858,102 @@
> int len;
>
> path = (char *)
> - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> len = p - source_path;
> strncpy (path, source_path, len); /* Before $cdir */
> - strcpy (path + len, s->dirname); /* new stuff */
> + strcpy (path + len, dirname); /* new stuff */
> strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> }
> }
>
> - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> if (result < 0)
> {
> /* Didn't work. Try using just the basename. */
> - p = lbasename (s->filename);
> - if (p != s->filename)
> - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> + p = lbasename (filename);
> + if (p != filename)
> + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> }
>
> if (result >= 0)
> {
> - fullname = s->fullname;
> - s->fullname = mstrsave (s->objfile->md, s->fullname);
> - xfree (fullname);
> + char *tmp_fullname;
> + tmp_fullname = *fullname;
> + *fullname = mstrsave (objfile->md, *fullname);
> + xfree (tmp_fullname);
> }
> return result;
> }
>
> -/* Return the path to the source file associated with symtab. Returns NULL
> - if no symtab. */
> +/* Open a source file given a symtab S. Returns a file descriptor or
> + negative number for error.
> +
> + This function is a convience function to find_and_open_source. */
> +
> +int
> +open_source_file (struct symtab *s)
> +{
> + if (!s)
> + return -1;
> +
> + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> +}
> +
> +/* Finds the fullname that a 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 symtab represents,
> + NULL will be returned and ps->fullname will be set to NULL. */
> char *
> -symtab_to_filename (struct symtab *s)
> +symtab_to_fullname (struct symtab *s)
> {
> - int fd;
> + int r;
>
> if (!s)
> return NULL;
>
> - /* If we've seen the file before, just return fullname. */
> + /* 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);
>
> - if (s->fullname)
> + if (r)
> + {
> + close (r);
> return s->fullname;
> + }
>
> - /* Try opening the file to setup fullname */
> + return NULL;
> +}
>
> - fd = open_source_file (s);
> - if (fd < 0)
> - return s->filename; /* File not found. Just use short name */
> +/* Finds the fullname that a partial_symtab represents.
>
> - /* Found the file. Cleanup and return the full name */
> + If this functions finds the fullname, it will save it in ps->fullname
> + and it will also return the value.
>
> - close (fd);
> - return s->fullname;
> + 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)
> + return NULL;
> +
> + /* 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);
> +
> + if (r)
> + {
> + close (r);
> + return ps->fullname;
> }
> \f
> + return NULL;
> +}
>
> /* Create and initialize the table S->line_charpos that records
> the positions of the lines in the source file, which is assumed
> Index: gdb/source.h
> ===================================================================
> Index: gdb/symtab.c
> ===================================================================
These are obvious if the rest goes in.
> Index: gdb/symtab.h
> ===================================================================
OK.
> Index: gdb/mi/mi-cmd-file.c
> ===================================================================
> +static const char * const FILENAME = "filename";
> +static const char * const FULLNAME = "fullname";
I don't think these are necessary.
>
> /* Return to the client the absolute path and line number of the
> current file being executed. */
> @@ -39,7 +43,6 @@
> if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> error ("mi_cmd_file_list_exec_source_file: Usage: No args");
>
> -
> /* Set the default file and line, also get them */
> set_default_source_symtab_and_line();
> st = get_current_source_symtab_and_line();
> @@ -51,17 +54,67 @@
> error ("mi_cmd_file_list_exec_source_file: No symtab");
>
> /* Extract the fullname if it is not known yet */
> - if (st.symtab->fullname == NULL)
> - symtab_to_filename (st.symtab);
> -
> - /* We may not be able to open the file (not available). */
> - if (st.symtab->fullname == NULL)
> - error ("mi_cmd_file_list_exec_source_file: File not found");
Why get rid of the error message?
> + symtab_to_fullname (st.symtab);
>
> /* 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, "fullname", st.symtab->fullname);
> + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> + return MI_CMD_DONE;
> +}
> +
> +enum mi_cmd_result
> +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> +{
> + struct symtab *s;
> + struct partial_symtab *ps;
> + struct objfile *objfile;
> +
> + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> +
> + /* Print the table header */
> + ui_out_begin ( uiout, ui_out_type_list, "files");
> +
> + /* Look at all of the symtabs */
> + ALL_SYMTABS (objfile, s)
> + {
> + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, FILENAME, s->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);
> +
> + ui_out_end ( uiout, ui_out_type_tuple );
> + }
> +
> + /* Look at all of the psymtabs */
> + ALL_PSYMTABS (objfile, ps)
> + {
> + if (!ps->readin) {
coding standards....
> + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, FILENAME, ps->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);
> +
> + ui_out_end ( uiout, ui_out_type_tuple );
> + }
> + }
> +
> + ui_out_end ( uiout, ui_out_type_list );
>
> return MI_CMD_DONE;
> }
> Index: gdb/mi/mi-cmds.c
> ===================================================================
> Index: gdb/mi/mi-cmds.h
> ===================================================================
these changes are ok.
> Index: gdb/testsuite/gdb.mi/mi-file.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi-file.exp
> --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> @@ -55,7 +55,7 @@
>
> # get the path and absolute path to the current executable
> mi_gdb_test "111-file-list-exec-source-file" \
> - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
Wouldn't this break existing MI parsers?
> "request path info of current source file (${srcfile})"
> }
>
> Index: gdb/testsuite/gdb.mi/mi2-file.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi2-file.exp
> --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> @@ -47,7 +47,7 @@
> mi_gdb_reinitialize_dir $srcdir/$subdir
> mi_gdb_load ${binfile}
>
> -proc test_tbreak_creation_and_listing {} {
> +proc test_file_list_exec_source_file {} {
> global srcfile
> global srcdir
> global subdir
> @@ -55,11 +55,21 @@
>
> # get the path and absolute path to the current executable
> mi_gdb_test "111-file-list-exec-source-file" \
> - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> "request path info of current source file (${srcfile})"
> }
>
> -test_tbreak_creation_and_listing
> +proc test_file_list_exec_source_files {} {
> + global srcfile
> +
> + # get the path and absolute path to the current executable
> + mi_gdb_test "222-file-list-exec-source-files" \
> + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> + "Getting a list of source files failed."
^^^^^^^
why failed?
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Elena Zannoni
2004-03-05 22:36 ` -file-list-exec-source-files Elena Zannoni
@ 2004-03-19 0:09 ` Jason Molenda
2004-03-05 23:02 ` -file-list-exec-source-files Jason Molenda
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2 siblings, 1 reply; 69+ messages in thread
From: Jason Molenda @ 2004-03-19 0:09 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, Bob Rossi
Hi Elena,
On Mar 5, 2004, at 2:31 PM, Elena Zannoni wrote:
>> @@ -1254,6 +1255,8 @@
>> objfile->global_psymbols.next,
>> objfile->static_psymbols.next);
>>
>> + pst->dirname = xstrdup ( comp_unit_die.dirname );
>> +
>> pst->read_symtab_private = (char *)
>> obstack_alloc (&objfile->objfile_obstack, sizeof (struct
>> dwarf2_pinfo));
>> DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
>> @@ -4326,6 +4329,10 @@
>> /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
>> if (part_die->name == NULL)
>> part_die->name = DW_STRING (&attr);
>> + break;
>> + case DW_AT_comp_dir:
>> + if (part_die->dirname == NULL)
>> + part_die->dirname = DW_STRING (&attr);
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
Oh that the DWARF spec were this cut-and-dried. :-) DWARF3 draft 8 says
A DW_AT_comp_dir attribute whose value is a null-terminated string
containing the current working directory of the compilation command
that produced this compilation unit in whatever form makes sense for
the host system.
The suggested form for the value of DW_AT_comp_dir attribute on UNIX
systems is "hostname:pathname". If no hostname is available, the
suggested form is ":pathname".
gcc puts the output of getpwd() into DW_AT_comp_dir. Obviously the
spec allows this. I suppose a consumer must be prepared to handle any
one of
/path/to/file
:/path/to/file
hostname:/path/to/file
C:/path/to/file
hostname:C:/path/to/file
And I wonder what should be done if one of the directory names contains
a ":". /path/to:haha/file is clearly ambiguous -- a producer could
disambiguate by always prepending a ":", but the consumer has no way of
knowing what it might be receiving. Quite a sticky wicket.
J
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Jason Molenda
@ 2004-03-05 23:02 ` Jason Molenda
0 siblings, 0 replies; 69+ messages in thread
From: Jason Molenda @ 2004-03-05 23:02 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, Bob Rossi
Hi Elena,
On Mar 5, 2004, at 2:31 PM, Elena Zannoni wrote:
>> @@ -1254,6 +1255,8 @@
>> objfile->global_psymbols.next,
>> objfile->static_psymbols.next);
>>
>> + pst->dirname = xstrdup ( comp_unit_die.dirname );
>> +
>> pst->read_symtab_private = (char *)
>> obstack_alloc (&objfile->objfile_obstack, sizeof (struct
>> dwarf2_pinfo));
>> DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
>> @@ -4326,6 +4329,10 @@
>> /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
>> if (part_die->name == NULL)
>> part_die->name = DW_STRING (&attr);
>> + break;
>> + case DW_AT_comp_dir:
>> + if (part_die->dirname == NULL)
>> + part_die->dirname = DW_STRING (&attr);
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
Oh that the DWARF spec were this cut-and-dried. :-) DWARF3 draft 8 says
A DW_AT_comp_dir attribute whose value is a null-terminated string
containing the current working directory of the compilation command
that produced this compilation unit in whatever form makes sense for
the host system.
The suggested form for the value of DW_AT_comp_dir attribute on UNIX
systems is "hostname:pathname". If no hostname is available, the
suggested form is ":pathname".
gcc puts the output of getpwd() into DW_AT_comp_dir. Obviously the
spec allows this. I suppose a consumer must be prepared to handle any
one of
/path/to/file
:/path/to/file
hostname:/path/to/file
C:/path/to/file
hostname:C:/path/to/file
And I wonder what should be done if one of the directory names contains
a ":". /path/to:haha/file is clearly ambiguous -- a producer could
disambiguate by always prepending a ":", but the consumer has no way of
knowing what it might be receiving. Quite a sticky wicket.
J
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Elena Zannoni
2004-03-05 22:36 ` -file-list-exec-source-files Elena Zannoni
2004-03-19 0:09 ` -file-list-exec-source-files Jason Molenda
@ 2004-03-19 0:09 ` Bob Rossi
2004-03-06 15:57 ` -file-list-exec-source-files Bob Rossi
2004-03-11 13:25 ` -file-list-exec-source-files Bob Rossi
2 siblings, 2 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches
Elena, thanks for taking the time to review my patch.
When is a good point to resubmit a patch? After every review, or after
all the issues are ironed out?
> > Here is an initial patch for -file-list-exec-source-files.
> > Some feedback would be appreciated.
> >
> > I ran the testsuite and the results are the same before and after this
> > patch.
> >
> > Index: gdb/ChangeLog
> > * dbxread.c (read_dbx_symtab): set pst->dirname when known
>
> Each entry should start with capital letter and end with period.
>
> I see some coding standards are not adhered to throughout the code.
> Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> calls.
Ok, I will try to fix all of the coding standard errors. Is there a
program I can run on the source files before I create the diff that
formats the code according to the standard?
>
> >
> > Index: gdb/dbxread.c
> > ===================================================================
> > Index: gdb/dwarf2read.c
> > ===================================================================
>
> These are ok
Great!
> >
> > Index: gdb/defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.143
> > diff -w -u -r1.143 defs.h
> > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > @@ -616,8 +616,6 @@
> >
> > extern void init_last_source_visited (void);
> >
> > -extern char *symtab_to_filename (struct symtab *);
> > -
> > /* From exec.c */
> >
> > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > Index: gdb/dwarf2read.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > retrieving revision 1.135
> > diff -w -u -r1.135 dwarf2read.c
> > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > @@ -316,6 +316,7 @@
> > unsigned int offset;
> > unsigned int abbrev;
> > char *name;
> > + char *dirname;
> > int has_pc_info;
> > CORE_ADDR lowpc;
> > CORE_ADDR highpc;
> > @@ -1254,6 +1255,8 @@
> > objfile->global_psymbols.next,
> > objfile->static_psymbols.next);
> >
> > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > +
> > pst->read_symtab_private = (char *)
> > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > @@ -4326,6 +4329,10 @@
> > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > if (part_die->name == NULL)
> > part_die->name = DW_STRING (&attr);
> > + break;
> > + case DW_AT_comp_dir:
> > + if (part_die->dirname == NULL)
> > + part_die->dirname = DW_STRING (&attr);
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
It would probably just be best if you told me what case's you want me to
implement here. It seems that Jason Molenda understodd most of the
cases. I really don't know anything about what GCC emits and would would
be practical to implement.
> > Index: gdb/source.c
> > ===================================================================
>
> this part I am not clear about.
Ok, Ok. I thought about this a lot. I think I made the best decision and
can describe why.
A few assumptions are in order. In order to get the fullname (abs path)
to a file, GDB need's three things. The directory the file was compiled
in (dirname), the filename in question (filename) and a list of paths
to search.
> There is already a function called source_full_path_of() would it help
> if you used it?
The function source_full_path_of does not take into account 'dirname'.
It calls openp, which is not capable of finding the fullname of a file,
since it doesn't understand what dirname is. Basically, I don't even
think this function (source_full_path_of) is "truly" capable of
finding the fullpath to a file. However, instead of removing it,
I left it, since caller's of this function might be using for something
I know nothing about.
> What is the difference between find_and_open_source and
> open_source_file? I.e. why did you need to introduce it. I think it's
> not clear just from your comments about the file possibly baing moved
> around.
open_source_file was left around for backwards compatibility. The unit
source.c was used to calling a function, with just passing the symtab,
and getting back the symtab with a valid fullname. I could remove all
occurences of this function and replace it with symtab_to_fullname.
> I am a bit worried about the substitution of symtab_to_filename with
> symtab_to_fullname. The former returns null only if there is no
> symtab. The latter returns null when there is no symtab OR when it
> cannot find the file. So the behavior is slightly different.
I basically think that the call -file-list-exec-source-files shouldn't
'cache' it's results. GDB looks for each file, every time it is
requested to get the fullname. This is because, the user could have
changed the path, or moved/deleted the file. I don't think GDB should
just return the filename instead, of the fullname.
So, if find_and_open_source couldn't "find and open the source file", it
returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
get's set to NULL.
The testsuite didn't seem to have a problem with this, and I think it
makes sense to not trick the caller into having results when it couldn't
find any.
If the caller really wanted this functionality,
return s->filename; /* File not found. Just use short name */
I believe it should be the caller's responsibility.
if ( symtab_to_fullname ( s ) == NULL )
/* use symtab->filename */
else
/* use symtab->fullname */
It doesn't really make sense to return the filename and not state that
it is not really the fullname. Also, if the caller tries to access
s->fullname, it will not be successful, because the file simply isn't
there.
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.49
> > diff -w -u -r1.49 source.c
> > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > @@ -805,30 +805,47 @@
> > return 1;
> > }
> >
> > -
> > -/* Open a source file given a symtab S. Returns a file descriptor or
> > - negative number for error. */
> > -
> > +/* 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.
> > +
> > + 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.
> > + FULLNAME can be the last known absolute path to the file in question.
> > +
> > + On Success
> > + A valid file descriptor is returned. ( the return value is positive )
> > + FULLNAME is set to the absolute path to the file just opened.
> > +
> > + On Failure
> > + A non valid file descriptor is returned. ( the return value is negitive )
> > + FULLNAME is set to NULL. */
> > int
> > -open_source_file (struct symtab *s)
> > +find_and_open_source (
> > + struct objfile *objfile,
> > + const char *filename,
> > + const char *dirname,
> > + char **fullname )
> > {
>
> coding standards....
Ok.
> > char *path = source_path;
> > const char *p;
> > int result;
> > - char *fullname;
> >
> > /* Quick way out if we already know its full name */
> > - if (s->fullname)
> > + if (*fullname)
> > {
> > - result = open (s->fullname, OPEN_MODE);
> > + result = open (*fullname, OPEN_MODE);
> > if (result >= 0)
> > return result;
> > /* Didn't work -- free old one, try again. */
> > - xmfree (s->objfile->md, s->fullname);
> > - s->fullname = NULL;
> > + xmfree (objfile->md, *fullname);
> > + *fullname = NULL;
> > }
> >
> > - if (s->dirname != NULL)
> > + if (dirname != NULL)
> > {
> > /* Replace a path entry of $cdir with the compilation directory name */
> > #define cdir_len 5
> > @@ -841,60 +858,102 @@
> > int len;
> >
> > path = (char *)
> > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > len = p - source_path;
> > strncpy (path, source_path, len); /* Before $cdir */
> > - strcpy (path + len, s->dirname); /* new stuff */
> > + strcpy (path + len, dirname); /* new stuff */
> > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > }
> > }
> >
> > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > if (result < 0)
> > {
> > /* Didn't work. Try using just the basename. */
> > - p = lbasename (s->filename);
> > - if (p != s->filename)
> > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > + p = lbasename (filename);
> > + if (p != filename)
> > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > }
> >
> > if (result >= 0)
> > {
> > - fullname = s->fullname;
> > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > - xfree (fullname);
> > + char *tmp_fullname;
> > + tmp_fullname = *fullname;
> > + *fullname = mstrsave (objfile->md, *fullname);
> > + xfree (tmp_fullname);
> > }
> > return result;
> > }
> >
> > -/* Return the path to the source file associated with symtab. Returns NULL
> > - if no symtab. */
> > +/* Open a source file given a symtab S. Returns a file descriptor or
> > + negative number for error.
> > +
> > + This function is a convience function to find_and_open_source. */
> > +
> > +int
> > +open_source_file (struct symtab *s)
> > +{
> > + if (!s)
> > + return -1;
> > +
> > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > +}
> > +
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
> > char *
> > -symtab_to_filename (struct symtab *s)
> > +symtab_to_fullname (struct symtab *s)
> > {
> > - int fd;
> > + int r;
> >
> > if (!s)
> > return NULL;
> >
> > - /* If we've seen the file before, just return fullname. */
> > + /* 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);
> >
> > - if (s->fullname)
> > + if (r)
> > + {
> > + close (r);
> > return s->fullname;
> > + }
> >
> > - /* Try opening the file to setup fullname */
> > + return NULL;
> > +}
> >
> > - fd = open_source_file (s);
> > - if (fd < 0)
> > - return s->filename; /* File not found. Just use short name */
> > +/* Finds the fullname that a partial_symtab represents.
> >
> > - /* Found the file. Cleanup and return the full name */
> > + If this functions finds the fullname, it will save it in ps->fullname
> > + and it will also return the value.
> >
> > - close (fd);
> > - return s->fullname;
> > + 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)
> > + return NULL;
> > +
> > + /* 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);
> > +
> > + if (r)
> > + {
> > + close (r);
> > + return ps->fullname;
> > }
> > \f
> > + return NULL;
> > +}
> >
> > /* Create and initialize the table S->line_charpos that records
> > the positions of the lines in the source file, which is assumed
>
>
>
> > Index: gdb/source.h
> > ===================================================================
> > Index: gdb/symtab.c
> > ===================================================================
>
> These are obvious if the rest goes in.
>
>
> > Index: gdb/symtab.h
> > ===================================================================
>
> OK.
>
>
> > Index: gdb/mi/mi-cmd-file.c
> > ===================================================================
>
>
> > +static const char * const FILENAME = "filename";
> > +static const char * const FULLNAME = "fullname";
>
> I don't think these are necessary.
It just unifies the output convention I am using in the
mi-cmd-file unit. What would you prefer to see?
> >
> > /* Return to the client the absolute path and line number of the
> > current file being executed. */
> > @@ -39,7 +43,6 @@
> > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> >
> > -
> > /* Set the default file and line, also get them */
> > set_default_source_symtab_and_line();
> > st = get_current_source_symtab_and_line();
> > @@ -51,17 +54,67 @@
> > error ("mi_cmd_file_list_exec_source_file: No symtab");
> >
> > /* Extract the fullname if it is not known yet */
> > - if (st.symtab->fullname == NULL)
> > - symtab_to_filename (st.symtab);
> > -
> > - /* We may not be able to open the file (not available). */
> > - if (st.symtab->fullname == NULL)
> > - error ("mi_cmd_file_list_exec_source_file: File not found");
>
> Why get rid of the error message?
Ok.
> > + symtab_to_fullname (st.symtab);
> >
> > /* 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, "fullname", st.symtab->fullname);
> > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
I don't know. I am thinking that GDB should just return the absolute
path to all of the source files it can find. If it can not find some,
should it issue a warning? That way the front end could say, "you need
to add a directory to the source search path".
> > + return MI_CMD_DONE;
> > +}
> > +
> > +enum mi_cmd_result
> > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > +{
> > + struct symtab *s;
> > + struct partial_symtab *ps;
> > + struct objfile *objfile;
> > +
> > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > +
> > + /* Print the table header */
> > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > +
> > + /* Look at all of the symtabs */
> > + ALL_SYMTABS (objfile, s)
> > + {
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, s->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > +
> > + /* Look at all of the psymtabs */
> > + ALL_PSYMTABS (objfile, ps)
> > + {
> > + if (!ps->readin) {
>
> coding standards....
Ok.
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, ps->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > + }
> > +
> > + ui_out_end ( uiout, ui_out_type_list );
> >
> > return MI_CMD_DONE;
> > }
>
>
>
> > Index: gdb/mi/mi-cmds.c
> > ===================================================================
>
> > Index: gdb/mi/mi-cmds.h
> > ===================================================================
>
> these changes are ok.
Great!
> > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi-file.exp
> > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -55,7 +55,7 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
>
> Wouldn't this break existing MI parsers?
Yes. I figured it could be mi2. Also, for some reason, I thought no one
would be using this function since I wrote it for CGDB, and I haven't
used it yet. I have a larger plan in mind for MI, than just these 2
commands (-file-list-exec-source-file and -file-list-exec-source-files).
I would like to add the fullname to a lot of commands. However, I think
'filename' and 'fullname' should be standardized, so that front end
writers immediatly understand what they are. It is awkard to have 1
function say "file=" and another say "filename=", when those 2 words
mean the same thing.
However, if this changes isn't acceptable, I can change it back.
> > "request path info of current source file (${srcfile})"
> > }
> >
> > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi2-file.exp
> > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -47,7 +47,7 @@
> > mi_gdb_reinitialize_dir $srcdir/$subdir
> > mi_gdb_load ${binfile}
> >
> > -proc test_tbreak_creation_and_listing {} {
> > +proc test_file_list_exec_source_file {} {
> > global srcfile
> > global srcdir
> > global subdir
> > @@ -55,11 +55,21 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > "request path info of current source file (${srcfile})"
> > }
> >
> > -test_tbreak_creation_and_listing
> > +proc test_file_list_exec_source_files {} {
> > + global srcfile
> > +
> > + # get the path and absolute path to the current executable
> > + mi_gdb_test "222-file-list-exec-source-files" \
> > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
>
> > + "Getting a list of source files failed."
> ^^^^^^^
> why failed?
OOO, That isn't an error condition, it's just a comment. I see.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-06 15:57 ` Bob Rossi
2004-03-11 13:25 ` -file-list-exec-source-files Bob Rossi
1 sibling, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-06 15:57 UTC (permalink / raw)
To: gdb-patches
Elena, thanks for taking the time to review my patch.
When is a good point to resubmit a patch? After every review, or after
all the issues are ironed out?
> > Here is an initial patch for -file-list-exec-source-files.
> > Some feedback would be appreciated.
> >
> > I ran the testsuite and the results are the same before and after this
> > patch.
> >
> > Index: gdb/ChangeLog
> > * dbxread.c (read_dbx_symtab): set pst->dirname when known
>
> Each entry should start with capital letter and end with period.
>
> I see some coding standards are not adhered to throughout the code.
> Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> calls.
Ok, I will try to fix all of the coding standard errors. Is there a
program I can run on the source files before I create the diff that
formats the code according to the standard?
>
> >
> > Index: gdb/dbxread.c
> > ===================================================================
> > Index: gdb/dwarf2read.c
> > ===================================================================
>
> These are ok
Great!
> >
> > Index: gdb/defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.143
> > diff -w -u -r1.143 defs.h
> > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > @@ -616,8 +616,6 @@
> >
> > extern void init_last_source_visited (void);
> >
> > -extern char *symtab_to_filename (struct symtab *);
> > -
> > /* From exec.c */
> >
> > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > Index: gdb/dwarf2read.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > retrieving revision 1.135
> > diff -w -u -r1.135 dwarf2read.c
> > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > @@ -316,6 +316,7 @@
> > unsigned int offset;
> > unsigned int abbrev;
> > char *name;
> > + char *dirname;
> > int has_pc_info;
> > CORE_ADDR lowpc;
> > CORE_ADDR highpc;
> > @@ -1254,6 +1255,8 @@
> > objfile->global_psymbols.next,
> > objfile->static_psymbols.next);
> >
> > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > +
> > pst->read_symtab_private = (char *)
> > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > @@ -4326,6 +4329,10 @@
> > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > if (part_die->name == NULL)
> > part_die->name = DW_STRING (&attr);
> > + break;
> > + case DW_AT_comp_dir:
> > + if (part_die->dirname == NULL)
> > + part_die->dirname = DW_STRING (&attr);
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
It would probably just be best if you told me what case's you want me to
implement here. It seems that Jason Molenda understodd most of the
cases. I really don't know anything about what GCC emits and would would
be practical to implement.
> > Index: gdb/source.c
> > ===================================================================
>
> this part I am not clear about.
Ok, Ok. I thought about this a lot. I think I made the best decision and
can describe why.
A few assumptions are in order. In order to get the fullname (abs path)
to a file, GDB need's three things. The directory the file was compiled
in (dirname), the filename in question (filename) and a list of paths
to search.
> There is already a function called source_full_path_of() would it help
> if you used it?
The function source_full_path_of does not take into account 'dirname'.
It calls openp, which is not capable of finding the fullname of a file,
since it doesn't understand what dirname is. Basically, I don't even
think this function (source_full_path_of) is "truly" capable of
finding the fullpath to a file. However, instead of removing it,
I left it, since caller's of this function might be using for something
I know nothing about.
> What is the difference between find_and_open_source and
> open_source_file? I.e. why did you need to introduce it. I think it's
> not clear just from your comments about the file possibly baing moved
> around.
open_source_file was left around for backwards compatibility. The unit
source.c was used to calling a function, with just passing the symtab,
and getting back the symtab with a valid fullname. I could remove all
occurences of this function and replace it with symtab_to_fullname.
> I am a bit worried about the substitution of symtab_to_filename with
> symtab_to_fullname. The former returns null only if there is no
> symtab. The latter returns null when there is no symtab OR when it
> cannot find the file. So the behavior is slightly different.
I basically think that the call -file-list-exec-source-files shouldn't
'cache' it's results. GDB looks for each file, every time it is
requested to get the fullname. This is because, the user could have
changed the path, or moved/deleted the file. I don't think GDB should
just return the filename instead, of the fullname.
So, if find_and_open_source couldn't "find and open the source file", it
returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
get's set to NULL.
The testsuite didn't seem to have a problem with this, and I think it
makes sense to not trick the caller into having results when it couldn't
find any.
If the caller really wanted this functionality,
return s->filename; /* File not found. Just use short name */
I believe it should be the caller's responsibility.
if ( symtab_to_fullname ( s ) == NULL )
/* use symtab->filename */
else
/* use symtab->fullname */
It doesn't really make sense to return the filename and not state that
it is not really the fullname. Also, if the caller tries to access
s->fullname, it will not be successful, because the file simply isn't
there.
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.49
> > diff -w -u -r1.49 source.c
> > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > @@ -805,30 +805,47 @@
> > return 1;
> > }
> >
> > -
> > -/* Open a source file given a symtab S. Returns a file descriptor or
> > - negative number for error. */
> > -
> > +/* 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.
> > +
> > + 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.
> > + FULLNAME can be the last known absolute path to the file in question.
> > +
> > + On Success
> > + A valid file descriptor is returned. ( the return value is positive )
> > + FULLNAME is set to the absolute path to the file just opened.
> > +
> > + On Failure
> > + A non valid file descriptor is returned. ( the return value is negitive )
> > + FULLNAME is set to NULL. */
> > int
> > -open_source_file (struct symtab *s)
> > +find_and_open_source (
> > + struct objfile *objfile,
> > + const char *filename,
> > + const char *dirname,
> > + char **fullname )
> > {
>
> coding standards....
Ok.
> > char *path = source_path;
> > const char *p;
> > int result;
> > - char *fullname;
> >
> > /* Quick way out if we already know its full name */
> > - if (s->fullname)
> > + if (*fullname)
> > {
> > - result = open (s->fullname, OPEN_MODE);
> > + result = open (*fullname, OPEN_MODE);
> > if (result >= 0)
> > return result;
> > /* Didn't work -- free old one, try again. */
> > - xmfree (s->objfile->md, s->fullname);
> > - s->fullname = NULL;
> > + xmfree (objfile->md, *fullname);
> > + *fullname = NULL;
> > }
> >
> > - if (s->dirname != NULL)
> > + if (dirname != NULL)
> > {
> > /* Replace a path entry of $cdir with the compilation directory name */
> > #define cdir_len 5
> > @@ -841,60 +858,102 @@
> > int len;
> >
> > path = (char *)
> > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > len = p - source_path;
> > strncpy (path, source_path, len); /* Before $cdir */
> > - strcpy (path + len, s->dirname); /* new stuff */
> > + strcpy (path + len, dirname); /* new stuff */
> > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > }
> > }
> >
> > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > if (result < 0)
> > {
> > /* Didn't work. Try using just the basename. */
> > - p = lbasename (s->filename);
> > - if (p != s->filename)
> > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > + p = lbasename (filename);
> > + if (p != filename)
> > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > }
> >
> > if (result >= 0)
> > {
> > - fullname = s->fullname;
> > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > - xfree (fullname);
> > + char *tmp_fullname;
> > + tmp_fullname = *fullname;
> > + *fullname = mstrsave (objfile->md, *fullname);
> > + xfree (tmp_fullname);
> > }
> > return result;
> > }
> >
> > -/* Return the path to the source file associated with symtab. Returns NULL
> > - if no symtab. */
> > +/* Open a source file given a symtab S. Returns a file descriptor or
> > + negative number for error.
> > +
> > + This function is a convience function to find_and_open_source. */
> > +
> > +int
> > +open_source_file (struct symtab *s)
> > +{
> > + if (!s)
> > + return -1;
> > +
> > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > +}
> > +
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
> > char *
> > -symtab_to_filename (struct symtab *s)
> > +symtab_to_fullname (struct symtab *s)
> > {
> > - int fd;
> > + int r;
> >
> > if (!s)
> > return NULL;
> >
> > - /* If we've seen the file before, just return fullname. */
> > + /* 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);
> >
> > - if (s->fullname)
> > + if (r)
> > + {
> > + close (r);
> > return s->fullname;
> > + }
> >
> > - /* Try opening the file to setup fullname */
> > + return NULL;
> > +}
> >
> > - fd = open_source_file (s);
> > - if (fd < 0)
> > - return s->filename; /* File not found. Just use short name */
> > +/* Finds the fullname that a partial_symtab represents.
> >
> > - /* Found the file. Cleanup and return the full name */
> > + If this functions finds the fullname, it will save it in ps->fullname
> > + and it will also return the value.
> >
> > - close (fd);
> > - return s->fullname;
> > + 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)
> > + return NULL;
> > +
> > + /* 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);
> > +
> > + if (r)
> > + {
> > + close (r);
> > + return ps->fullname;
> > }
> > \f
> > + return NULL;
> > +}
> >
> > /* Create and initialize the table S->line_charpos that records
> > the positions of the lines in the source file, which is assumed
>
>
>
> > Index: gdb/source.h
> > ===================================================================
> > Index: gdb/symtab.c
> > ===================================================================
>
> These are obvious if the rest goes in.
>
>
> > Index: gdb/symtab.h
> > ===================================================================
>
> OK.
>
>
> > Index: gdb/mi/mi-cmd-file.c
> > ===================================================================
>
>
> > +static const char * const FILENAME = "filename";
> > +static const char * const FULLNAME = "fullname";
>
> I don't think these are necessary.
It just unifies the output convention I am using in the
mi-cmd-file unit. What would you prefer to see?
> >
> > /* Return to the client the absolute path and line number of the
> > current file being executed. */
> > @@ -39,7 +43,6 @@
> > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> >
> > -
> > /* Set the default file and line, also get them */
> > set_default_source_symtab_and_line();
> > st = get_current_source_symtab_and_line();
> > @@ -51,17 +54,67 @@
> > error ("mi_cmd_file_list_exec_source_file: No symtab");
> >
> > /* Extract the fullname if it is not known yet */
> > - if (st.symtab->fullname == NULL)
> > - symtab_to_filename (st.symtab);
> > -
> > - /* We may not be able to open the file (not available). */
> > - if (st.symtab->fullname == NULL)
> > - error ("mi_cmd_file_list_exec_source_file: File not found");
>
> Why get rid of the error message?
Ok.
> > + symtab_to_fullname (st.symtab);
> >
> > /* 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, "fullname", st.symtab->fullname);
> > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
I don't know. I am thinking that GDB should just return the absolute
path to all of the source files it can find. If it can not find some,
should it issue a warning? That way the front end could say, "you need
to add a directory to the source search path".
> > + return MI_CMD_DONE;
> > +}
> > +
> > +enum mi_cmd_result
> > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > +{
> > + struct symtab *s;
> > + struct partial_symtab *ps;
> > + struct objfile *objfile;
> > +
> > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > +
> > + /* Print the table header */
> > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > +
> > + /* Look at all of the symtabs */
> > + ALL_SYMTABS (objfile, s)
> > + {
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, s->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > +
> > + /* Look at all of the psymtabs */
> > + ALL_PSYMTABS (objfile, ps)
> > + {
> > + if (!ps->readin) {
>
> coding standards....
Ok.
> > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, FILENAME, ps->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);
> > +
> > + ui_out_end ( uiout, ui_out_type_tuple );
> > + }
> > + }
> > +
> > + ui_out_end ( uiout, ui_out_type_list );
> >
> > return MI_CMD_DONE;
> > }
>
>
>
> > Index: gdb/mi/mi-cmds.c
> > ===================================================================
>
> > Index: gdb/mi/mi-cmds.h
> > ===================================================================
>
> these changes are ok.
Great!
> > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi-file.exp
> > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -55,7 +55,7 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
>
> Wouldn't this break existing MI parsers?
Yes. I figured it could be mi2. Also, for some reason, I thought no one
would be using this function since I wrote it for CGDB, and I haven't
used it yet. I have a larger plan in mind for MI, than just these 2
commands (-file-list-exec-source-file and -file-list-exec-source-files).
I would like to add the fullname to a lot of commands. However, I think
'filename' and 'fullname' should be standardized, so that front end
writers immediatly understand what they are. It is awkard to have 1
function say "file=" and another say "filename=", when those 2 words
mean the same thing.
However, if this changes isn't acceptable, I can change it back.
> > "request path info of current source file (${srcfile})"
> > }
> >
> > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi2-file.exp
> > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > @@ -47,7 +47,7 @@
> > mi_gdb_reinitialize_dir $srcdir/$subdir
> > mi_gdb_load ${binfile}
> >
> > -proc test_tbreak_creation_and_listing {} {
> > +proc test_file_list_exec_source_file {} {
> > global srcfile
> > global srcdir
> > global subdir
> > @@ -55,11 +55,21 @@
> >
> > # get the path and absolute path to the current executable
> > mi_gdb_test "111-file-list-exec-source-file" \
> > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > "request path info of current source file (${srcfile})"
> > }
> >
> > -test_tbreak_creation_and_listing
> > +proc test_file_list_exec_source_files {} {
> > + global srcfile
> > +
> > + # get the path and absolute path to the current executable
> > + mi_gdb_test "222-file-list-exec-source-files" \
> > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
>
> > + "Getting a list of source files failed."
> ^^^^^^^
> why failed?
OOO, That isn't an error condition, it's just a comment. I see.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-06 15:57 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-11 13:25 ` Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-29 20:55 ` -file-list-exec-source-files Bob Rossi
1 sibling, 2 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-11 13:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Elena Zannoni
What do you think?
Bob Rossi
On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> Elena, thanks for taking the time to review my patch.
>
> When is a good point to resubmit a patch? After every review, or after
> all the issues are ironed out?
>
> > > Here is an initial patch for -file-list-exec-source-files.
> > > Some feedback would be appreciated.
> > >
> > > I ran the testsuite and the results are the same before and after this
> > > patch.
> > >
> > > Index: gdb/ChangeLog
> > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> >
> > Each entry should start with capital letter and end with period.
> >
> > I see some coding standards are not adhered to throughout the code.
> > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > calls.
>
> Ok, I will try to fix all of the coding standard errors. Is there a
> program I can run on the source files before I create the diff that
> formats the code according to the standard?
>
> >
> > >
> > > Index: gdb/dbxread.c
> > > ===================================================================
> > > Index: gdb/dwarf2read.c
> > > ===================================================================
> >
> > These are ok
>
> Great!
>
> > >
> > > Index: gdb/defs.h
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > retrieving revision 1.143
> > > diff -w -u -r1.143 defs.h
> > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > @@ -616,8 +616,6 @@
> > >
> > > extern void init_last_source_visited (void);
> > >
> > > -extern char *symtab_to_filename (struct symtab *);
> > > -
> > > /* From exec.c */
> > >
> > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > Index: gdb/dwarf2read.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > retrieving revision 1.135
> > > diff -w -u -r1.135 dwarf2read.c
> > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > @@ -316,6 +316,7 @@
> > > unsigned int offset;
> > > unsigned int abbrev;
> > > char *name;
> > > + char *dirname;
> > > int has_pc_info;
> > > CORE_ADDR lowpc;
> > > CORE_ADDR highpc;
> > > @@ -1254,6 +1255,8 @@
> > > objfile->global_psymbols.next,
> > > objfile->static_psymbols.next);
> > >
> > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > +
> > > pst->read_symtab_private = (char *)
> > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > @@ -4326,6 +4329,10 @@
> > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > if (part_die->name == NULL)
> > > part_die->name = DW_STRING (&attr);
> > > + break;
> > > + case DW_AT_comp_dir:
> > > + if (part_die->dirname == NULL)
> > > + part_die->dirname = DW_STRING (&attr);
> >
> > The dwarf2 specs say that the name is in the form ":pathname" or
> > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > that? I have looked at a few executables and didn't see the hostname
> > part.
>
> It would probably just be best if you told me what case's you want me to
> implement here. It seems that Jason Molenda understodd most of the
> cases. I really don't know anything about what GCC emits and would would
> be practical to implement.
>
> > > Index: gdb/source.c
> > > ===================================================================
> >
> > this part I am not clear about.
>
> Ok, Ok. I thought about this a lot. I think I made the best decision and
> can describe why.
>
> A few assumptions are in order. In order to get the fullname (abs path)
> to a file, GDB need's three things. The directory the file was compiled
> in (dirname), the filename in question (filename) and a list of paths
> to search.
>
> > There is already a function called source_full_path_of() would it help
> > if you used it?
>
> The function source_full_path_of does not take into account 'dirname'.
> It calls openp, which is not capable of finding the fullname of a file,
> since it doesn't understand what dirname is. Basically, I don't even
> think this function (source_full_path_of) is "truly" capable of
> finding the fullpath to a file. However, instead of removing it,
> I left it, since caller's of this function might be using for something
> I know nothing about.
>
> > What is the difference between find_and_open_source and
> > open_source_file? I.e. why did you need to introduce it. I think it's
> > not clear just from your comments about the file possibly baing moved
> > around.
>
> open_source_file was left around for backwards compatibility. The unit
> source.c was used to calling a function, with just passing the symtab,
> and getting back the symtab with a valid fullname. I could remove all
> occurences of this function and replace it with symtab_to_fullname.
>
> > I am a bit worried about the substitution of symtab_to_filename with
> > symtab_to_fullname. The former returns null only if there is no
> > symtab. The latter returns null when there is no symtab OR when it
> > cannot find the file. So the behavior is slightly different.
>
> I basically think that the call -file-list-exec-source-files shouldn't
> 'cache' it's results. GDB looks for each file, every time it is
> requested to get the fullname. This is because, the user could have
> changed the path, or moved/deleted the file. I don't think GDB should
> just return the filename instead, of the fullname.
>
> So, if find_and_open_source couldn't "find and open the source file", it
> returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> get's set to NULL.
>
> The testsuite didn't seem to have a problem with this, and I think it
> makes sense to not trick the caller into having results when it couldn't
> find any.
>
> If the caller really wanted this functionality,
> return s->filename; /* File not found. Just use short name */
> I believe it should be the caller's responsibility.
>
> if ( symtab_to_fullname ( s ) == NULL )
> /* use symtab->filename */
> else
> /* use symtab->fullname */
>
> It doesn't really make sense to return the filename and not state that
> it is not really the fullname. Also, if the caller tries to access
> s->fullname, it will not be successful, because the file simply isn't
> there.
>
> > > RCS file: /cvs/src/src/gdb/source.c,v
> > > retrieving revision 1.49
> > > diff -w -u -r1.49 source.c
> > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > @@ -805,30 +805,47 @@
> > > return 1;
> > > }
> > >
> > > -
> > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > - negative number for error. */
> > > -
> > > +/* 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.
> > > +
> > > + 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.
> > > + FULLNAME can be the last known absolute path to the file in question.
> > > +
> > > + On Success
> > > + A valid file descriptor is returned. ( the return value is positive )
> > > + FULLNAME is set to the absolute path to the file just opened.
> > > +
> > > + On Failure
> > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > + FULLNAME is set to NULL. */
> > > int
> > > -open_source_file (struct symtab *s)
> > > +find_and_open_source (
> > > + struct objfile *objfile,
> > > + const char *filename,
> > > + const char *dirname,
> > > + char **fullname )
> > > {
> >
> > coding standards....
>
> Ok.
>
> > > char *path = source_path;
> > > const char *p;
> > > int result;
> > > - char *fullname;
> > >
> > > /* Quick way out if we already know its full name */
> > > - if (s->fullname)
> > > + if (*fullname)
> > > {
> > > - result = open (s->fullname, OPEN_MODE);
> > > + result = open (*fullname, OPEN_MODE);
> > > if (result >= 0)
> > > return result;
> > > /* Didn't work -- free old one, try again. */
> > > - xmfree (s->objfile->md, s->fullname);
> > > - s->fullname = NULL;
> > > + xmfree (objfile->md, *fullname);
> > > + *fullname = NULL;
> > > }
> > >
> > > - if (s->dirname != NULL)
> > > + if (dirname != NULL)
> > > {
> > > /* Replace a path entry of $cdir with the compilation directory name */
> > > #define cdir_len 5
> > > @@ -841,60 +858,102 @@
> > > int len;
> > >
> > > path = (char *)
> > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > len = p - source_path;
> > > strncpy (path, source_path, len); /* Before $cdir */
> > > - strcpy (path + len, s->dirname); /* new stuff */
> > > + strcpy (path + len, dirname); /* new stuff */
> > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > }
> > > }
> > >
> > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > if (result < 0)
> > > {
> > > /* Didn't work. Try using just the basename. */
> > > - p = lbasename (s->filename);
> > > - if (p != s->filename)
> > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > + p = lbasename (filename);
> > > + if (p != filename)
> > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > }
> > >
> > > if (result >= 0)
> > > {
> > > - fullname = s->fullname;
> > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > - xfree (fullname);
> > > + char *tmp_fullname;
> > > + tmp_fullname = *fullname;
> > > + *fullname = mstrsave (objfile->md, *fullname);
> > > + xfree (tmp_fullname);
> > > }
> > > return result;
> > > }
> > >
> > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > - if no symtab. */
> > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > + negative number for error.
> > > +
> > > + This function is a convience function to find_and_open_source. */
> > > +
> > > +int
> > > +open_source_file (struct symtab *s)
> > > +{
> > > + if (!s)
> > > + return -1;
> > > +
> > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > +}
> > > +
> > > +/* Finds the fullname that a 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 symtab represents,
> > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > char *
> > > -symtab_to_filename (struct symtab *s)
> > > +symtab_to_fullname (struct symtab *s)
> > > {
> > > - int fd;
> > > + int r;
> > >
> > > if (!s)
> > > return NULL;
> > >
> > > - /* If we've seen the file before, just return fullname. */
> > > + /* 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);
> > >
> > > - if (s->fullname)
> > > + if (r)
> > > + {
> > > + close (r);
> > > return s->fullname;
> > > + }
> > >
> > > - /* Try opening the file to setup fullname */
> > > + return NULL;
> > > +}
> > >
> > > - fd = open_source_file (s);
> > > - if (fd < 0)
> > > - return s->filename; /* File not found. Just use short name */
> > > +/* Finds the fullname that a partial_symtab represents.
> > >
> > > - /* Found the file. Cleanup and return the full name */
> > > + If this functions finds the fullname, it will save it in ps->fullname
> > > + and it will also return the value.
> > >
> > > - close (fd);
> > > - return s->fullname;
> > > + 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)
> > > + return NULL;
> > > +
> > > + /* 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);
> > > +
> > > + if (r)
> > > + {
> > > + close (r);
> > > + return ps->fullname;
> > > }
> > > \f
> > > + return NULL;
> > > +}
> > >
> > > /* Create and initialize the table S->line_charpos that records
> > > the positions of the lines in the source file, which is assumed
> >
> >
> >
> > > Index: gdb/source.h
> > > ===================================================================
> > > Index: gdb/symtab.c
> > > ===================================================================
> >
> > These are obvious if the rest goes in.
> >
> >
> > > Index: gdb/symtab.h
> > > ===================================================================
> >
> > OK.
> >
> >
> > > Index: gdb/mi/mi-cmd-file.c
> > > ===================================================================
> >
> >
> > > +static const char * const FILENAME = "filename";
> > > +static const char * const FULLNAME = "fullname";
> >
> > I don't think these are necessary.
>
> It just unifies the output convention I am using in the
> mi-cmd-file unit. What would you prefer to see?
>
> > >
> > > /* Return to the client the absolute path and line number of the
> > > current file being executed. */
> > > @@ -39,7 +43,6 @@
> > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > >
> > > -
> > > /* Set the default file and line, also get them */
> > > set_default_source_symtab_and_line();
> > > st = get_current_source_symtab_and_line();
> > > @@ -51,17 +54,67 @@
> > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > >
> > > /* Extract the fullname if it is not known yet */
> > > - if (st.symtab->fullname == NULL)
> > > - symtab_to_filename (st.symtab);
> > > -
> > > - /* We may not be able to open the file (not available). */
> > > - if (st.symtab->fullname == NULL)
> > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> >
> > Why get rid of the error message?
>
> Ok.
>
> > > + symtab_to_fullname (st.symtab);
> > >
> > > /* 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, "fullname", st.symtab->fullname);
> > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
>
> I don't know. I am thinking that GDB should just return the absolute
> path to all of the source files it can find. If it can not find some,
> should it issue a warning? That way the front end could say, "you need
> to add a directory to the source search path".
>
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > +enum mi_cmd_result
> > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > +{
> > > + struct symtab *s;
> > > + struct partial_symtab *ps;
> > > + struct objfile *objfile;
> > > +
> > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > +
> > > + /* Print the table header */
> > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > +
> > > + /* Look at all of the symtabs */
> > > + ALL_SYMTABS (objfile, s)
> > > + {
> > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > +
> > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > +
> > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > + }
> > > +
> > > + /* Look at all of the psymtabs */
> > > + ALL_PSYMTABS (objfile, ps)
> > > + {
> > > + if (!ps->readin) {
> >
> > coding standards....
>
> Ok.
>
> > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > +
> > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > +
> > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > + }
> > > + }
> > > +
> > > + ui_out_end ( uiout, ui_out_type_list );
> > >
> > > return MI_CMD_DONE;
> > > }
> >
> >
> >
> > > Index: gdb/mi/mi-cmds.c
> > > ===================================================================
> >
> > > Index: gdb/mi/mi-cmds.h
> > > ===================================================================
> >
> > these changes are ok.
>
> Great!
>
> > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > retrieving revision 1.1
> > > diff -w -u -r1.1 mi-file.exp
> > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > @@ -55,7 +55,7 @@
> > >
> > > # get the path and absolute path to the current executable
> > > mi_gdb_test "111-file-list-exec-source-file" \
> > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> >
> > Wouldn't this break existing MI parsers?
>
> Yes. I figured it could be mi2. Also, for some reason, I thought no one
> would be using this function since I wrote it for CGDB, and I haven't
> used it yet. I have a larger plan in mind for MI, than just these 2
> commands (-file-list-exec-source-file and -file-list-exec-source-files).
> I would like to add the fullname to a lot of commands. However, I think
> 'filename' and 'fullname' should be standardized, so that front end
> writers immediatly understand what they are. It is awkard to have 1
> function say "file=" and another say "filename=", when those 2 words
> mean the same thing.
>
> However, if this changes isn't acceptable, I can change it back.
>
> > > "request path info of current source file (${srcfile})"
> > > }
> > >
> > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > retrieving revision 1.1
> > > diff -w -u -r1.1 mi2-file.exp
> > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > @@ -47,7 +47,7 @@
> > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > mi_gdb_load ${binfile}
> > >
> > > -proc test_tbreak_creation_and_listing {} {
> > > +proc test_file_list_exec_source_file {} {
> > > global srcfile
> > > global srcdir
> > > global subdir
> > > @@ -55,11 +55,21 @@
> > >
> > > # get the path and absolute path to the current executable
> > > mi_gdb_test "111-file-list-exec-source-file" \
> > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > "request path info of current source file (${srcfile})"
> > > }
> > >
> > > -test_tbreak_creation_and_listing
> > > +proc test_file_list_exec_source_files {} {
> > > + global srcfile
> > > +
> > > + # get the path and absolute path to the current executable
> > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> >
> > > + "Getting a list of source files failed."
> > ^^^^^^^
> > why failed?
>
> OOO, That isn't an error condition, it's just a comment. I see.
>
> Thanks,
> Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-11 13:25 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-19 0:09 ` Bob Rossi
2004-03-29 20:55 ` -file-list-exec-source-files Bob Rossi
1 sibling, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Elena Zannoni
What do you think?
Bob Rossi
On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> Elena, thanks for taking the time to review my patch.
>
> When is a good point to resubmit a patch? After every review, or after
> all the issues are ironed out?
>
> > > Here is an initial patch for -file-list-exec-source-files.
> > > Some feedback would be appreciated.
> > >
> > > I ran the testsuite and the results are the same before and after this
> > > patch.
> > >
> > > Index: gdb/ChangeLog
> > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> >
> > Each entry should start with capital letter and end with period.
> >
> > I see some coding standards are not adhered to throughout the code.
> > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > calls.
>
> Ok, I will try to fix all of the coding standard errors. Is there a
> program I can run on the source files before I create the diff that
> formats the code according to the standard?
>
> >
> > >
> > > Index: gdb/dbxread.c
> > > ===================================================================
> > > Index: gdb/dwarf2read.c
> > > ===================================================================
> >
> > These are ok
>
> Great!
>
> > >
> > > Index: gdb/defs.h
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > retrieving revision 1.143
> > > diff -w -u -r1.143 defs.h
> > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > @@ -616,8 +616,6 @@
> > >
> > > extern void init_last_source_visited (void);
> > >
> > > -extern char *symtab_to_filename (struct symtab *);
> > > -
> > > /* From exec.c */
> > >
> > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > Index: gdb/dwarf2read.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > retrieving revision 1.135
> > > diff -w -u -r1.135 dwarf2read.c
> > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > @@ -316,6 +316,7 @@
> > > unsigned int offset;
> > > unsigned int abbrev;
> > > char *name;
> > > + char *dirname;
> > > int has_pc_info;
> > > CORE_ADDR lowpc;
> > > CORE_ADDR highpc;
> > > @@ -1254,6 +1255,8 @@
> > > objfile->global_psymbols.next,
> > > objfile->static_psymbols.next);
> > >
> > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > +
> > > pst->read_symtab_private = (char *)
> > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > @@ -4326,6 +4329,10 @@
> > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > if (part_die->name == NULL)
> > > part_die->name = DW_STRING (&attr);
> > > + break;
> > > + case DW_AT_comp_dir:
> > > + if (part_die->dirname == NULL)
> > > + part_die->dirname = DW_STRING (&attr);
> >
> > The dwarf2 specs say that the name is in the form ":pathname" or
> > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > that? I have looked at a few executables and didn't see the hostname
> > part.
>
> It would probably just be best if you told me what case's you want me to
> implement here. It seems that Jason Molenda understodd most of the
> cases. I really don't know anything about what GCC emits and would would
> be practical to implement.
>
> > > Index: gdb/source.c
> > > ===================================================================
> >
> > this part I am not clear about.
>
> Ok, Ok. I thought about this a lot. I think I made the best decision and
> can describe why.
>
> A few assumptions are in order. In order to get the fullname (abs path)
> to a file, GDB need's three things. The directory the file was compiled
> in (dirname), the filename in question (filename) and a list of paths
> to search.
>
> > There is already a function called source_full_path_of() would it help
> > if you used it?
>
> The function source_full_path_of does not take into account 'dirname'.
> It calls openp, which is not capable of finding the fullname of a file,
> since it doesn't understand what dirname is. Basically, I don't even
> think this function (source_full_path_of) is "truly" capable of
> finding the fullpath to a file. However, instead of removing it,
> I left it, since caller's of this function might be using for something
> I know nothing about.
>
> > What is the difference between find_and_open_source and
> > open_source_file? I.e. why did you need to introduce it. I think it's
> > not clear just from your comments about the file possibly baing moved
> > around.
>
> open_source_file was left around for backwards compatibility. The unit
> source.c was used to calling a function, with just passing the symtab,
> and getting back the symtab with a valid fullname. I could remove all
> occurences of this function and replace it with symtab_to_fullname.
>
> > I am a bit worried about the substitution of symtab_to_filename with
> > symtab_to_fullname. The former returns null only if there is no
> > symtab. The latter returns null when there is no symtab OR when it
> > cannot find the file. So the behavior is slightly different.
>
> I basically think that the call -file-list-exec-source-files shouldn't
> 'cache' it's results. GDB looks for each file, every time it is
> requested to get the fullname. This is because, the user could have
> changed the path, or moved/deleted the file. I don't think GDB should
> just return the filename instead, of the fullname.
>
> So, if find_and_open_source couldn't "find and open the source file", it
> returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> get's set to NULL.
>
> The testsuite didn't seem to have a problem with this, and I think it
> makes sense to not trick the caller into having results when it couldn't
> find any.
>
> If the caller really wanted this functionality,
> return s->filename; /* File not found. Just use short name */
> I believe it should be the caller's responsibility.
>
> if ( symtab_to_fullname ( s ) == NULL )
> /* use symtab->filename */
> else
> /* use symtab->fullname */
>
> It doesn't really make sense to return the filename and not state that
> it is not really the fullname. Also, if the caller tries to access
> s->fullname, it will not be successful, because the file simply isn't
> there.
>
> > > RCS file: /cvs/src/src/gdb/source.c,v
> > > retrieving revision 1.49
> > > diff -w -u -r1.49 source.c
> > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > @@ -805,30 +805,47 @@
> > > return 1;
> > > }
> > >
> > > -
> > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > - negative number for error. */
> > > -
> > > +/* 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.
> > > +
> > > + 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.
> > > + FULLNAME can be the last known absolute path to the file in question.
> > > +
> > > + On Success
> > > + A valid file descriptor is returned. ( the return value is positive )
> > > + FULLNAME is set to the absolute path to the file just opened.
> > > +
> > > + On Failure
> > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > + FULLNAME is set to NULL. */
> > > int
> > > -open_source_file (struct symtab *s)
> > > +find_and_open_source (
> > > + struct objfile *objfile,
> > > + const char *filename,
> > > + const char *dirname,
> > > + char **fullname )
> > > {
> >
> > coding standards....
>
> Ok.
>
> > > char *path = source_path;
> > > const char *p;
> > > int result;
> > > - char *fullname;
> > >
> > > /* Quick way out if we already know its full name */
> > > - if (s->fullname)
> > > + if (*fullname)
> > > {
> > > - result = open (s->fullname, OPEN_MODE);
> > > + result = open (*fullname, OPEN_MODE);
> > > if (result >= 0)
> > > return result;
> > > /* Didn't work -- free old one, try again. */
> > > - xmfree (s->objfile->md, s->fullname);
> > > - s->fullname = NULL;
> > > + xmfree (objfile->md, *fullname);
> > > + *fullname = NULL;
> > > }
> > >
> > > - if (s->dirname != NULL)
> > > + if (dirname != NULL)
> > > {
> > > /* Replace a path entry of $cdir with the compilation directory name */
> > > #define cdir_len 5
> > > @@ -841,60 +858,102 @@
> > > int len;
> > >
> > > path = (char *)
> > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > len = p - source_path;
> > > strncpy (path, source_path, len); /* Before $cdir */
> > > - strcpy (path + len, s->dirname); /* new stuff */
> > > + strcpy (path + len, dirname); /* new stuff */
> > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > }
> > > }
> > >
> > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > if (result < 0)
> > > {
> > > /* Didn't work. Try using just the basename. */
> > > - p = lbasename (s->filename);
> > > - if (p != s->filename)
> > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > + p = lbasename (filename);
> > > + if (p != filename)
> > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > }
> > >
> > > if (result >= 0)
> > > {
> > > - fullname = s->fullname;
> > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > - xfree (fullname);
> > > + char *tmp_fullname;
> > > + tmp_fullname = *fullname;
> > > + *fullname = mstrsave (objfile->md, *fullname);
> > > + xfree (tmp_fullname);
> > > }
> > > return result;
> > > }
> > >
> > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > - if no symtab. */
> > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > + negative number for error.
> > > +
> > > + This function is a convience function to find_and_open_source. */
> > > +
> > > +int
> > > +open_source_file (struct symtab *s)
> > > +{
> > > + if (!s)
> > > + return -1;
> > > +
> > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > +}
> > > +
> > > +/* Finds the fullname that a 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 symtab represents,
> > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > char *
> > > -symtab_to_filename (struct symtab *s)
> > > +symtab_to_fullname (struct symtab *s)
> > > {
> > > - int fd;
> > > + int r;
> > >
> > > if (!s)
> > > return NULL;
> > >
> > > - /* If we've seen the file before, just return fullname. */
> > > + /* 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);
> > >
> > > - if (s->fullname)
> > > + if (r)
> > > + {
> > > + close (r);
> > > return s->fullname;
> > > + }
> > >
> > > - /* Try opening the file to setup fullname */
> > > + return NULL;
> > > +}
> > >
> > > - fd = open_source_file (s);
> > > - if (fd < 0)
> > > - return s->filename; /* File not found. Just use short name */
> > > +/* Finds the fullname that a partial_symtab represents.
> > >
> > > - /* Found the file. Cleanup and return the full name */
> > > + If this functions finds the fullname, it will save it in ps->fullname
> > > + and it will also return the value.
> > >
> > > - close (fd);
> > > - return s->fullname;
> > > + 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)
> > > + return NULL;
> > > +
> > > + /* 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);
> > > +
> > > + if (r)
> > > + {
> > > + close (r);
> > > + return ps->fullname;
> > > }
> > > \f
> > > + return NULL;
> > > +}
> > >
> > > /* Create and initialize the table S->line_charpos that records
> > > the positions of the lines in the source file, which is assumed
> >
> >
> >
> > > Index: gdb/source.h
> > > ===================================================================
> > > Index: gdb/symtab.c
> > > ===================================================================
> >
> > These are obvious if the rest goes in.
> >
> >
> > > Index: gdb/symtab.h
> > > ===================================================================
> >
> > OK.
> >
> >
> > > Index: gdb/mi/mi-cmd-file.c
> > > ===================================================================
> >
> >
> > > +static const char * const FILENAME = "filename";
> > > +static const char * const FULLNAME = "fullname";
> >
> > I don't think these are necessary.
>
> It just unifies the output convention I am using in the
> mi-cmd-file unit. What would you prefer to see?
>
> > >
> > > /* Return to the client the absolute path and line number of the
> > > current file being executed. */
> > > @@ -39,7 +43,6 @@
> > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > >
> > > -
> > > /* Set the default file and line, also get them */
> > > set_default_source_symtab_and_line();
> > > st = get_current_source_symtab_and_line();
> > > @@ -51,17 +54,67 @@
> > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > >
> > > /* Extract the fullname if it is not known yet */
> > > - if (st.symtab->fullname == NULL)
> > > - symtab_to_filename (st.symtab);
> > > -
> > > - /* We may not be able to open the file (not available). */
> > > - if (st.symtab->fullname == NULL)
> > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> >
> > Why get rid of the error message?
>
> Ok.
>
> > > + symtab_to_fullname (st.symtab);
> > >
> > > /* 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, "fullname", st.symtab->fullname);
> > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
>
> I don't know. I am thinking that GDB should just return the absolute
> path to all of the source files it can find. If it can not find some,
> should it issue a warning? That way the front end could say, "you need
> to add a directory to the source search path".
>
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > +enum mi_cmd_result
> > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > +{
> > > + struct symtab *s;
> > > + struct partial_symtab *ps;
> > > + struct objfile *objfile;
> > > +
> > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > +
> > > + /* Print the table header */
> > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > +
> > > + /* Look at all of the symtabs */
> > > + ALL_SYMTABS (objfile, s)
> > > + {
> > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > +
> > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > +
> > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > + }
> > > +
> > > + /* Look at all of the psymtabs */
> > > + ALL_PSYMTABS (objfile, ps)
> > > + {
> > > + if (!ps->readin) {
> >
> > coding standards....
>
> Ok.
>
> > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > +
> > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > +
> > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > + }
> > > + }
> > > +
> > > + ui_out_end ( uiout, ui_out_type_list );
> > >
> > > return MI_CMD_DONE;
> > > }
> >
> >
> >
> > > Index: gdb/mi/mi-cmds.c
> > > ===================================================================
> >
> > > Index: gdb/mi/mi-cmds.h
> > > ===================================================================
> >
> > these changes are ok.
>
> Great!
>
> > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > retrieving revision 1.1
> > > diff -w -u -r1.1 mi-file.exp
> > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > @@ -55,7 +55,7 @@
> > >
> > > # get the path and absolute path to the current executable
> > > mi_gdb_test "111-file-list-exec-source-file" \
> > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> >
> > Wouldn't this break existing MI parsers?
>
> Yes. I figured it could be mi2. Also, for some reason, I thought no one
> would be using this function since I wrote it for CGDB, and I haven't
> used it yet. I have a larger plan in mind for MI, than just these 2
> commands (-file-list-exec-source-file and -file-list-exec-source-files).
> I would like to add the fullname to a lot of commands. However, I think
> 'filename' and 'fullname' should be standardized, so that front end
> writers immediatly understand what they are. It is awkard to have 1
> function say "file=" and another say "filename=", when those 2 words
> mean the same thing.
>
> However, if this changes isn't acceptable, I can change it back.
>
> > > "request path info of current source file (${srcfile})"
> > > }
> > >
> > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > retrieving revision 1.1
> > > diff -w -u -r1.1 mi2-file.exp
> > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > @@ -47,7 +47,7 @@
> > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > mi_gdb_load ${binfile}
> > >
> > > -proc test_tbreak_creation_and_listing {} {
> > > +proc test_file_list_exec_source_file {} {
> > > global srcfile
> > > global srcdir
> > > global subdir
> > > @@ -55,11 +55,21 @@
> > >
> > > # get the path and absolute path to the current executable
> > > mi_gdb_test "111-file-list-exec-source-file" \
> > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > "request path info of current source file (${srcfile})"
> > > }
> > >
> > > -test_tbreak_creation_and_listing
> > > +proc test_file_list_exec_source_files {} {
> > > + global srcfile
> > > +
> > > + # get the path and absolute path to the current executable
> > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> >
> > > + "Getting a list of source files failed."
> > ^^^^^^^
> > why failed?
>
> OOO, That isn't an error condition, it's just a comment. I see.
>
> Thanks,
> Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-11 13:25 ` -file-list-exec-source-files Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
@ 2004-03-29 20:55 ` Bob Rossi
2004-04-05 21:40 ` -file-list-exec-source-files Bob Rossi
1 sibling, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-03-29 20:55 UTC (permalink / raw)
To: gdb-patches, Elena Zannoni
What do you think?
On Thu, Mar 11, 2004 at 08:25:08AM -0500, Bob Rossi wrote:
> What do you think?
>
> Bob Rossi
>
> On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> > Elena, thanks for taking the time to review my patch.
> >
> > When is a good point to resubmit a patch? After every review, or after
> > all the issues are ironed out?
> >
> > > > Here is an initial patch for -file-list-exec-source-files.
> > > > Some feedback would be appreciated.
> > > >
> > > > I ran the testsuite and the results are the same before and after this
> > > > patch.
> > > >
> > > > Index: gdb/ChangeLog
> > > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> > >
> > > Each entry should start with capital letter and end with period.
> > >
> > > I see some coding standards are not adhered to throughout the code.
> > > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > > calls.
> >
> > Ok, I will try to fix all of the coding standard errors. Is there a
> > program I can run on the source files before I create the diff that
> > formats the code according to the standard?
> >
> > >
> > > >
> > > > Index: gdb/dbxread.c
> > > > ===================================================================
> > > > Index: gdb/dwarf2read.c
> > > > ===================================================================
> > >
> > > These are ok
> >
> > Great!
> >
> > > >
> > > > Index: gdb/defs.h
> > > > ===================================================================
> > > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > > retrieving revision 1.143
> > > > diff -w -u -r1.143 defs.h
> > > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > > @@ -616,8 +616,6 @@
> > > >
> > > > extern void init_last_source_visited (void);
> > > >
> > > > -extern char *symtab_to_filename (struct symtab *);
> > > > -
> > > > /* From exec.c */
> > > >
> > > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > > Index: gdb/dwarf2read.c
> > > > ===================================================================
> > > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > > retrieving revision 1.135
> > > > diff -w -u -r1.135 dwarf2read.c
> > > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > > @@ -316,6 +316,7 @@
> > > > unsigned int offset;
> > > > unsigned int abbrev;
> > > > char *name;
> > > > + char *dirname;
> > > > int has_pc_info;
> > > > CORE_ADDR lowpc;
> > > > CORE_ADDR highpc;
> > > > @@ -1254,6 +1255,8 @@
> > > > objfile->global_psymbols.next,
> > > > objfile->static_psymbols.next);
> > > >
> > > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > > +
> > > > pst->read_symtab_private = (char *)
> > > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > > @@ -4326,6 +4329,10 @@
> > > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > > if (part_die->name == NULL)
> > > > part_die->name = DW_STRING (&attr);
> > > > + break;
> > > > + case DW_AT_comp_dir:
> > > > + if (part_die->dirname == NULL)
> > > > + part_die->dirname = DW_STRING (&attr);
> > >
> > > The dwarf2 specs say that the name is in the form ":pathname" or
> > > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > > that? I have looked at a few executables and didn't see the hostname
> > > part.
> >
> > It would probably just be best if you told me what case's you want me to
> > implement here. It seems that Jason Molenda understodd most of the
> > cases. I really don't know anything about what GCC emits and would would
> > be practical to implement.
> >
> > > > Index: gdb/source.c
> > > > ===================================================================
> > >
> > > this part I am not clear about.
> >
> > Ok, Ok. I thought about this a lot. I think I made the best decision and
> > can describe why.
> >
> > A few assumptions are in order. In order to get the fullname (abs path)
> > to a file, GDB need's three things. The directory the file was compiled
> > in (dirname), the filename in question (filename) and a list of paths
> > to search.
> >
> > > There is already a function called source_full_path_of() would it help
> > > if you used it?
> >
> > The function source_full_path_of does not take into account 'dirname'.
> > It calls openp, which is not capable of finding the fullname of a file,
> > since it doesn't understand what dirname is. Basically, I don't even
> > think this function (source_full_path_of) is "truly" capable of
> > finding the fullpath to a file. However, instead of removing it,
> > I left it, since caller's of this function might be using for something
> > I know nothing about.
> >
> > > What is the difference between find_and_open_source and
> > > open_source_file? I.e. why did you need to introduce it. I think it's
> > > not clear just from your comments about the file possibly baing moved
> > > around.
> >
> > open_source_file was left around for backwards compatibility. The unit
> > source.c was used to calling a function, with just passing the symtab,
> > and getting back the symtab with a valid fullname. I could remove all
> > occurences of this function and replace it with symtab_to_fullname.
> >
> > > I am a bit worried about the substitution of symtab_to_filename with
> > > symtab_to_fullname. The former returns null only if there is no
> > > symtab. The latter returns null when there is no symtab OR when it
> > > cannot find the file. So the behavior is slightly different.
> >
> > I basically think that the call -file-list-exec-source-files shouldn't
> > 'cache' it's results. GDB looks for each file, every time it is
> > requested to get the fullname. This is because, the user could have
> > changed the path, or moved/deleted the file. I don't think GDB should
> > just return the filename instead, of the fullname.
> >
> > So, if find_and_open_source couldn't "find and open the source file", it
> > returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> > get's set to NULL.
> >
> > The testsuite didn't seem to have a problem with this, and I think it
> > makes sense to not trick the caller into having results when it couldn't
> > find any.
> >
> > If the caller really wanted this functionality,
> > return s->filename; /* File not found. Just use short name */
> > I believe it should be the caller's responsibility.
> >
> > if ( symtab_to_fullname ( s ) == NULL )
> > /* use symtab->filename */
> > else
> > /* use symtab->fullname */
> >
> > It doesn't really make sense to return the filename and not state that
> > it is not really the fullname. Also, if the caller tries to access
> > s->fullname, it will not be successful, because the file simply isn't
> > there.
> >
> > > > RCS file: /cvs/src/src/gdb/source.c,v
> > > > retrieving revision 1.49
> > > > diff -w -u -r1.49 source.c
> > > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > > @@ -805,30 +805,47 @@
> > > > return 1;
> > > > }
> > > >
> > > > -
> > > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > > - negative number for error. */
> > > > -
> > > > +/* 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.
> > > > +
> > > > + 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.
> > > > + FULLNAME can be the last known absolute path to the file in question.
> > > > +
> > > > + On Success
> > > > + A valid file descriptor is returned. ( the return value is positive )
> > > > + FULLNAME is set to the absolute path to the file just opened.
> > > > +
> > > > + On Failure
> > > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > > + FULLNAME is set to NULL. */
> > > > int
> > > > -open_source_file (struct symtab *s)
> > > > +find_and_open_source (
> > > > + struct objfile *objfile,
> > > > + const char *filename,
> > > > + const char *dirname,
> > > > + char **fullname )
> > > > {
> > >
> > > coding standards....
> >
> > Ok.
> >
> > > > char *path = source_path;
> > > > const char *p;
> > > > int result;
> > > > - char *fullname;
> > > >
> > > > /* Quick way out if we already know its full name */
> > > > - if (s->fullname)
> > > > + if (*fullname)
> > > > {
> > > > - result = open (s->fullname, OPEN_MODE);
> > > > + result = open (*fullname, OPEN_MODE);
> > > > if (result >= 0)
> > > > return result;
> > > > /* Didn't work -- free old one, try again. */
> > > > - xmfree (s->objfile->md, s->fullname);
> > > > - s->fullname = NULL;
> > > > + xmfree (objfile->md, *fullname);
> > > > + *fullname = NULL;
> > > > }
> > > >
> > > > - if (s->dirname != NULL)
> > > > + if (dirname != NULL)
> > > > {
> > > > /* Replace a path entry of $cdir with the compilation directory name */
> > > > #define cdir_len 5
> > > > @@ -841,60 +858,102 @@
> > > > int len;
> > > >
> > > > path = (char *)
> > > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > > len = p - source_path;
> > > > strncpy (path, source_path, len); /* Before $cdir */
> > > > - strcpy (path + len, s->dirname); /* new stuff */
> > > > + strcpy (path + len, dirname); /* new stuff */
> > > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > > }
> > > > }
> > > >
> > > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > > if (result < 0)
> > > > {
> > > > /* Didn't work. Try using just the basename. */
> > > > - p = lbasename (s->filename);
> > > > - if (p != s->filename)
> > > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > > + p = lbasename (filename);
> > > > + if (p != filename)
> > > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > > }
> > > >
> > > > if (result >= 0)
> > > > {
> > > > - fullname = s->fullname;
> > > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > > - xfree (fullname);
> > > > + char *tmp_fullname;
> > > > + tmp_fullname = *fullname;
> > > > + *fullname = mstrsave (objfile->md, *fullname);
> > > > + xfree (tmp_fullname);
> > > > }
> > > > return result;
> > > > }
> > > >
> > > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > > - if no symtab. */
> > > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > > + negative number for error.
> > > > +
> > > > + This function is a convience function to find_and_open_source. */
> > > > +
> > > > +int
> > > > +open_source_file (struct symtab *s)
> > > > +{
> > > > + if (!s)
> > > > + return -1;
> > > > +
> > > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > > +}
> > > > +
> > > > +/* Finds the fullname that a 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 symtab represents,
> > > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > > char *
> > > > -symtab_to_filename (struct symtab *s)
> > > > +symtab_to_fullname (struct symtab *s)
> > > > {
> > > > - int fd;
> > > > + int r;
> > > >
> > > > if (!s)
> > > > return NULL;
> > > >
> > > > - /* If we've seen the file before, just return fullname. */
> > > > + /* 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);
> > > >
> > > > - if (s->fullname)
> > > > + if (r)
> > > > + {
> > > > + close (r);
> > > > return s->fullname;
> > > > + }
> > > >
> > > > - /* Try opening the file to setup fullname */
> > > > + return NULL;
> > > > +}
> > > >
> > > > - fd = open_source_file (s);
> > > > - if (fd < 0)
> > > > - return s->filename; /* File not found. Just use short name */
> > > > +/* Finds the fullname that a partial_symtab represents.
> > > >
> > > > - /* Found the file. Cleanup and return the full name */
> > > > + If this functions finds the fullname, it will save it in ps->fullname
> > > > + and it will also return the value.
> > > >
> > > > - close (fd);
> > > > - return s->fullname;
> > > > + 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)
> > > > + return NULL;
> > > > +
> > > > + /* 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);
> > > > +
> > > > + if (r)
> > > > + {
> > > > + close (r);
> > > > + return ps->fullname;
> > > > }
> > > > \f
> > > > + return NULL;
> > > > +}
> > > >
> > > > /* Create and initialize the table S->line_charpos that records
> > > > the positions of the lines in the source file, which is assumed
> > >
> > >
> > >
> > > > Index: gdb/source.h
> > > > ===================================================================
> > > > Index: gdb/symtab.c
> > > > ===================================================================
> > >
> > > These are obvious if the rest goes in.
> > >
> > >
> > > > Index: gdb/symtab.h
> > > > ===================================================================
> > >
> > > OK.
> > >
> > >
> > > > Index: gdb/mi/mi-cmd-file.c
> > > > ===================================================================
> > >
> > >
> > > > +static const char * const FILENAME = "filename";
> > > > +static const char * const FULLNAME = "fullname";
> > >
> > > I don't think these are necessary.
> >
> > It just unifies the output convention I am using in the
> > mi-cmd-file unit. What would you prefer to see?
> >
> > > >
> > > > /* Return to the client the absolute path and line number of the
> > > > current file being executed. */
> > > > @@ -39,7 +43,6 @@
> > > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > > >
> > > > -
> > > > /* Set the default file and line, also get them */
> > > > set_default_source_symtab_and_line();
> > > > st = get_current_source_symtab_and_line();
> > > > @@ -51,17 +54,67 @@
> > > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > > >
> > > > /* Extract the fullname if it is not known yet */
> > > > - if (st.symtab->fullname == NULL)
> > > > - symtab_to_filename (st.symtab);
> > > > -
> > > > - /* We may not be able to open the file (not available). */
> > > > - if (st.symtab->fullname == NULL)
> > > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> > >
> > > Why get rid of the error message?
> >
> > Ok.
> >
> > > > + symtab_to_fullname (st.symtab);
> > > >
> > > > /* 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, "fullname", st.symtab->fullname);
> > > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> >
> > I don't know. I am thinking that GDB should just return the absolute
> > path to all of the source files it can find. If it can not find some,
> > should it issue a warning? That way the front end could say, "you need
> > to add a directory to the source search path".
> >
> > > > + return MI_CMD_DONE;
> > > > +}
> > > > +
> > > > +enum mi_cmd_result
> > > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > > +{
> > > > + struct symtab *s;
> > > > + struct partial_symtab *ps;
> > > > + struct objfile *objfile;
> > > > +
> > > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > > +
> > > > + /* Print the table header */
> > > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > > +
> > > > + /* Look at all of the symtabs */
> > > > + ALL_SYMTABS (objfile, s)
> > > > + {
> > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > +
> > > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > > +
> > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > + }
> > > > +
> > > > + /* Look at all of the psymtabs */
> > > > + ALL_PSYMTABS (objfile, ps)
> > > > + {
> > > > + if (!ps->readin) {
> > >
> > > coding standards....
> >
> > Ok.
> >
> > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > +
> > > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > > +
> > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > + }
> > > > + }
> > > > +
> > > > + ui_out_end ( uiout, ui_out_type_list );
> > > >
> > > > return MI_CMD_DONE;
> > > > }
> > >
> > >
> > >
> > > > Index: gdb/mi/mi-cmds.c
> > > > ===================================================================
> > >
> > > > Index: gdb/mi/mi-cmds.h
> > > > ===================================================================
> > >
> > > these changes are ok.
> >
> > Great!
> >
> > > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > > ===================================================================
> > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > > retrieving revision 1.1
> > > > diff -w -u -r1.1 mi-file.exp
> > > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > > @@ -55,7 +55,7 @@
> > > >
> > > > # get the path and absolute path to the current executable
> > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > >
> > > Wouldn't this break existing MI parsers?
> >
> > Yes. I figured it could be mi2. Also, for some reason, I thought no one
> > would be using this function since I wrote it for CGDB, and I haven't
> > used it yet. I have a larger plan in mind for MI, than just these 2
> > commands (-file-list-exec-source-file and -file-list-exec-source-files).
> > I would like to add the fullname to a lot of commands. However, I think
> > 'filename' and 'fullname' should be standardized, so that front end
> > writers immediatly understand what they are. It is awkard to have 1
> > function say "file=" and another say "filename=", when those 2 words
> > mean the same thing.
> >
> > However, if this changes isn't acceptable, I can change it back.
> >
> > > > "request path info of current source file (${srcfile})"
> > > > }
> > > >
> > > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > > ===================================================================
> > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > > retrieving revision 1.1
> > > > diff -w -u -r1.1 mi2-file.exp
> > > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > > @@ -47,7 +47,7 @@
> > > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > > mi_gdb_load ${binfile}
> > > >
> > > > -proc test_tbreak_creation_and_listing {} {
> > > > +proc test_file_list_exec_source_file {} {
> > > > global srcfile
> > > > global srcdir
> > > > global subdir
> > > > @@ -55,11 +55,21 @@
> > > >
> > > > # get the path and absolute path to the current executable
> > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > "request path info of current source file (${srcfile})"
> > > > }
> > > >
> > > > -test_tbreak_creation_and_listing
> > > > +proc test_file_list_exec_source_files {} {
> > > > + global srcfile
> > > > +
> > > > + # get the path and absolute path to the current executable
> > > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> > >
> > > > + "Getting a list of source files failed."
> > > ^^^^^^^
> > > why failed?
> >
> > OOO, That isn't an error condition, it's just a comment. I see.
> >
> > Thanks,
> > Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-03-29 20:55 ` -file-list-exec-source-files Bob Rossi
@ 2004-04-05 21:40 ` Bob Rossi
2004-04-12 15:06 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-04-05 21:40 UTC (permalink / raw)
To: gdb-patches, Elena Zannoni
Could someone please review this patch?
It has been 6 weeks. Pinging has not got me very far.
Bob Rossi
On Mon, Mar 29, 2004 at 03:55:46PM -0500, Bob Rossi wrote:
> What do you think?
>
> On Thu, Mar 11, 2004 at 08:25:08AM -0500, Bob Rossi wrote:
> > What do you think?
> >
> > Bob Rossi
> >
> > On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> > > Elena, thanks for taking the time to review my patch.
> > >
> > > When is a good point to resubmit a patch? After every review, or after
> > > all the issues are ironed out?
> > >
> > > > > Here is an initial patch for -file-list-exec-source-files.
> > > > > Some feedback would be appreciated.
> > > > >
> > > > > I ran the testsuite and the results are the same before and after this
> > > > > patch.
> > > > >
> > > > > Index: gdb/ChangeLog
> > > > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> > > >
> > > > Each entry should start with capital letter and end with period.
> > > >
> > > > I see some coding standards are not adhered to throughout the code.
> > > > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > > > calls.
> > >
> > > Ok, I will try to fix all of the coding standard errors. Is there a
> > > program I can run on the source files before I create the diff that
> > > formats the code according to the standard?
> > >
> > > >
> > > > >
> > > > > Index: gdb/dbxread.c
> > > > > ===================================================================
> > > > > Index: gdb/dwarf2read.c
> > > > > ===================================================================
> > > >
> > > > These are ok
> > >
> > > Great!
> > >
> > > > >
> > > > > Index: gdb/defs.h
> > > > > ===================================================================
> > > > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > > > retrieving revision 1.143
> > > > > diff -w -u -r1.143 defs.h
> > > > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > > > @@ -616,8 +616,6 @@
> > > > >
> > > > > extern void init_last_source_visited (void);
> > > > >
> > > > > -extern char *symtab_to_filename (struct symtab *);
> > > > > -
> > > > > /* From exec.c */
> > > > >
> > > > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > > > Index: gdb/dwarf2read.c
> > > > > ===================================================================
> > > > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > > > retrieving revision 1.135
> > > > > diff -w -u -r1.135 dwarf2read.c
> > > > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > > > @@ -316,6 +316,7 @@
> > > > > unsigned int offset;
> > > > > unsigned int abbrev;
> > > > > char *name;
> > > > > + char *dirname;
> > > > > int has_pc_info;
> > > > > CORE_ADDR lowpc;
> > > > > CORE_ADDR highpc;
> > > > > @@ -1254,6 +1255,8 @@
> > > > > objfile->global_psymbols.next,
> > > > > objfile->static_psymbols.next);
> > > > >
> > > > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > > > +
> > > > > pst->read_symtab_private = (char *)
> > > > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > > > @@ -4326,6 +4329,10 @@
> > > > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > > > if (part_die->name == NULL)
> > > > > part_die->name = DW_STRING (&attr);
> > > > > + break;
> > > > > + case DW_AT_comp_dir:
> > > > > + if (part_die->dirname == NULL)
> > > > > + part_die->dirname = DW_STRING (&attr);
> > > >
> > > > The dwarf2 specs say that the name is in the form ":pathname" or
> > > > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > > > that? I have looked at a few executables and didn't see the hostname
> > > > part.
> > >
> > > It would probably just be best if you told me what case's you want me to
> > > implement here. It seems that Jason Molenda understodd most of the
> > > cases. I really don't know anything about what GCC emits and would would
> > > be practical to implement.
> > >
> > > > > Index: gdb/source.c
> > > > > ===================================================================
> > > >
> > > > this part I am not clear about.
> > >
> > > Ok, Ok. I thought about this a lot. I think I made the best decision and
> > > can describe why.
> > >
> > > A few assumptions are in order. In order to get the fullname (abs path)
> > > to a file, GDB need's three things. The directory the file was compiled
> > > in (dirname), the filename in question (filename) and a list of paths
> > > to search.
> > >
> > > > There is already a function called source_full_path_of() would it help
> > > > if you used it?
> > >
> > > The function source_full_path_of does not take into account 'dirname'.
> > > It calls openp, which is not capable of finding the fullname of a file,
> > > since it doesn't understand what dirname is. Basically, I don't even
> > > think this function (source_full_path_of) is "truly" capable of
> > > finding the fullpath to a file. However, instead of removing it,
> > > I left it, since caller's of this function might be using for something
> > > I know nothing about.
> > >
> > > > What is the difference between find_and_open_source and
> > > > open_source_file? I.e. why did you need to introduce it. I think it's
> > > > not clear just from your comments about the file possibly baing moved
> > > > around.
> > >
> > > open_source_file was left around for backwards compatibility. The unit
> > > source.c was used to calling a function, with just passing the symtab,
> > > and getting back the symtab with a valid fullname. I could remove all
> > > occurences of this function and replace it with symtab_to_fullname.
> > >
> > > > I am a bit worried about the substitution of symtab_to_filename with
> > > > symtab_to_fullname. The former returns null only if there is no
> > > > symtab. The latter returns null when there is no symtab OR when it
> > > > cannot find the file. So the behavior is slightly different.
> > >
> > > I basically think that the call -file-list-exec-source-files shouldn't
> > > 'cache' it's results. GDB looks for each file, every time it is
> > > requested to get the fullname. This is because, the user could have
> > > changed the path, or moved/deleted the file. I don't think GDB should
> > > just return the filename instead, of the fullname.
> > >
> > > So, if find_and_open_source couldn't "find and open the source file", it
> > > returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> > > get's set to NULL.
> > >
> > > The testsuite didn't seem to have a problem with this, and I think it
> > > makes sense to not trick the caller into having results when it couldn't
> > > find any.
> > >
> > > If the caller really wanted this functionality,
> > > return s->filename; /* File not found. Just use short name */
> > > I believe it should be the caller's responsibility.
> > >
> > > if ( symtab_to_fullname ( s ) == NULL )
> > > /* use symtab->filename */
> > > else
> > > /* use symtab->fullname */
> > >
> > > It doesn't really make sense to return the filename and not state that
> > > it is not really the fullname. Also, if the caller tries to access
> > > s->fullname, it will not be successful, because the file simply isn't
> > > there.
> > >
> > > > > RCS file: /cvs/src/src/gdb/source.c,v
> > > > > retrieving revision 1.49
> > > > > diff -w -u -r1.49 source.c
> > > > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > > > @@ -805,30 +805,47 @@
> > > > > return 1;
> > > > > }
> > > > >
> > > > > -
> > > > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > - negative number for error. */
> > > > > -
> > > > > +/* 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.
> > > > > +
> > > > > + 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.
> > > > > + FULLNAME can be the last known absolute path to the file in question.
> > > > > +
> > > > > + On Success
> > > > > + A valid file descriptor is returned. ( the return value is positive )
> > > > > + FULLNAME is set to the absolute path to the file just opened.
> > > > > +
> > > > > + On Failure
> > > > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > > > + FULLNAME is set to NULL. */
> > > > > int
> > > > > -open_source_file (struct symtab *s)
> > > > > +find_and_open_source (
> > > > > + struct objfile *objfile,
> > > > > + const char *filename,
> > > > > + const char *dirname,
> > > > > + char **fullname )
> > > > > {
> > > >
> > > > coding standards....
> > >
> > > Ok.
> > >
> > > > > char *path = source_path;
> > > > > const char *p;
> > > > > int result;
> > > > > - char *fullname;
> > > > >
> > > > > /* Quick way out if we already know its full name */
> > > > > - if (s->fullname)
> > > > > + if (*fullname)
> > > > > {
> > > > > - result = open (s->fullname, OPEN_MODE);
> > > > > + result = open (*fullname, OPEN_MODE);
> > > > > if (result >= 0)
> > > > > return result;
> > > > > /* Didn't work -- free old one, try again. */
> > > > > - xmfree (s->objfile->md, s->fullname);
> > > > > - s->fullname = NULL;
> > > > > + xmfree (objfile->md, *fullname);
> > > > > + *fullname = NULL;
> > > > > }
> > > > >
> > > > > - if (s->dirname != NULL)
> > > > > + if (dirname != NULL)
> > > > > {
> > > > > /* Replace a path entry of $cdir with the compilation directory name */
> > > > > #define cdir_len 5
> > > > > @@ -841,60 +858,102 @@
> > > > > int len;
> > > > >
> > > > > path = (char *)
> > > > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > > > len = p - source_path;
> > > > > strncpy (path, source_path, len); /* Before $cdir */
> > > > > - strcpy (path + len, s->dirname); /* new stuff */
> > > > > + strcpy (path + len, dirname); /* new stuff */
> > > > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > > > }
> > > > > }
> > > > >
> > > > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > > > if (result < 0)
> > > > > {
> > > > > /* Didn't work. Try using just the basename. */
> > > > > - p = lbasename (s->filename);
> > > > > - if (p != s->filename)
> > > > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > > > + p = lbasename (filename);
> > > > > + if (p != filename)
> > > > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > > > }
> > > > >
> > > > > if (result >= 0)
> > > > > {
> > > > > - fullname = s->fullname;
> > > > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > > > - xfree (fullname);
> > > > > + char *tmp_fullname;
> > > > > + tmp_fullname = *fullname;
> > > > > + *fullname = mstrsave (objfile->md, *fullname);
> > > > > + xfree (tmp_fullname);
> > > > > }
> > > > > return result;
> > > > > }
> > > > >
> > > > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > > > - if no symtab. */
> > > > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > + negative number for error.
> > > > > +
> > > > > + This function is a convience function to find_and_open_source. */
> > > > > +
> > > > > +int
> > > > > +open_source_file (struct symtab *s)
> > > > > +{
> > > > > + if (!s)
> > > > > + return -1;
> > > > > +
> > > > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > > > +}
> > > > > +
> > > > > +/* Finds the fullname that a 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 symtab represents,
> > > > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > > > char *
> > > > > -symtab_to_filename (struct symtab *s)
> > > > > +symtab_to_fullname (struct symtab *s)
> > > > > {
> > > > > - int fd;
> > > > > + int r;
> > > > >
> > > > > if (!s)
> > > > > return NULL;
> > > > >
> > > > > - /* If we've seen the file before, just return fullname. */
> > > > > + /* 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);
> > > > >
> > > > > - if (s->fullname)
> > > > > + if (r)
> > > > > + {
> > > > > + close (r);
> > > > > return s->fullname;
> > > > > + }
> > > > >
> > > > > - /* Try opening the file to setup fullname */
> > > > > + return NULL;
> > > > > +}
> > > > >
> > > > > - fd = open_source_file (s);
> > > > > - if (fd < 0)
> > > > > - return s->filename; /* File not found. Just use short name */
> > > > > +/* Finds the fullname that a partial_symtab represents.
> > > > >
> > > > > - /* Found the file. Cleanup and return the full name */
> > > > > + If this functions finds the fullname, it will save it in ps->fullname
> > > > > + and it will also return the value.
> > > > >
> > > > > - close (fd);
> > > > > - return s->fullname;
> > > > > + 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)
> > > > > + return NULL;
> > > > > +
> > > > > + /* 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);
> > > > > +
> > > > > + if (r)
> > > > > + {
> > > > > + close (r);
> > > > > + return ps->fullname;
> > > > > }
> > > > > \f
> > > > > + return NULL;
> > > > > +}
> > > > >
> > > > > /* Create and initialize the table S->line_charpos that records
> > > > > the positions of the lines in the source file, which is assumed
> > > >
> > > >
> > > >
> > > > > Index: gdb/source.h
> > > > > ===================================================================
> > > > > Index: gdb/symtab.c
> > > > > ===================================================================
> > > >
> > > > These are obvious if the rest goes in.
> > > >
> > > >
> > > > > Index: gdb/symtab.h
> > > > > ===================================================================
> > > >
> > > > OK.
> > > >
> > > >
> > > > > Index: gdb/mi/mi-cmd-file.c
> > > > > ===================================================================
> > > >
> > > >
> > > > > +static const char * const FILENAME = "filename";
> > > > > +static const char * const FULLNAME = "fullname";
> > > >
> > > > I don't think these are necessary.
> > >
> > > It just unifies the output convention I am using in the
> > > mi-cmd-file unit. What would you prefer to see?
> > >
> > > > >
> > > > > /* Return to the client the absolute path and line number of the
> > > > > current file being executed. */
> > > > > @@ -39,7 +43,6 @@
> > > > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > > > >
> > > > > -
> > > > > /* Set the default file and line, also get them */
> > > > > set_default_source_symtab_and_line();
> > > > > st = get_current_source_symtab_and_line();
> > > > > @@ -51,17 +54,67 @@
> > > > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > > > >
> > > > > /* Extract the fullname if it is not known yet */
> > > > > - if (st.symtab->fullname == NULL)
> > > > > - symtab_to_filename (st.symtab);
> > > > > -
> > > > > - /* We may not be able to open the file (not available). */
> > > > > - if (st.symtab->fullname == NULL)
> > > > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> > > >
> > > > Why get rid of the error message?
> > >
> > > Ok.
> > >
> > > > > + symtab_to_fullname (st.symtab);
> > > > >
> > > > > /* 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, "fullname", st.symtab->fullname);
> > > > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> > >
> > > I don't know. I am thinking that GDB should just return the absolute
> > > path to all of the source files it can find. If it can not find some,
> > > should it issue a warning? That way the front end could say, "you need
> > > to add a directory to the source search path".
> > >
> > > > > + return MI_CMD_DONE;
> > > > > +}
> > > > > +
> > > > > +enum mi_cmd_result
> > > > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > > > +{
> > > > > + struct symtab *s;
> > > > > + struct partial_symtab *ps;
> > > > > + struct objfile *objfile;
> > > > > +
> > > > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > > > +
> > > > > + /* Print the table header */
> > > > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > > > +
> > > > > + /* Look at all of the symtabs */
> > > > > + ALL_SYMTABS (objfile, s)
> > > > > + {
> > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > +
> > > > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > > > +
> > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > + }
> > > > > +
> > > > > + /* Look at all of the psymtabs */
> > > > > + ALL_PSYMTABS (objfile, ps)
> > > > > + {
> > > > > + if (!ps->readin) {
> > > >
> > > > coding standards....
> > >
> > > Ok.
> > >
> > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > +
> > > > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > > > +
> > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > + }
> > > > > + }
> > > > > +
> > > > > + ui_out_end ( uiout, ui_out_type_list );
> > > > >
> > > > > return MI_CMD_DONE;
> > > > > }
> > > >
> > > >
> > > >
> > > > > Index: gdb/mi/mi-cmds.c
> > > > > ===================================================================
> > > >
> > > > > Index: gdb/mi/mi-cmds.h
> > > > > ===================================================================
> > > >
> > > > these changes are ok.
> > >
> > > Great!
> > >
> > > > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > > > ===================================================================
> > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > > > retrieving revision 1.1
> > > > > diff -w -u -r1.1 mi-file.exp
> > > > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > @@ -55,7 +55,7 @@
> > > > >
> > > > > # get the path and absolute path to the current executable
> > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > >
> > > > Wouldn't this break existing MI parsers?
> > >
> > > Yes. I figured it could be mi2. Also, for some reason, I thought no one
> > > would be using this function since I wrote it for CGDB, and I haven't
> > > used it yet. I have a larger plan in mind for MI, than just these 2
> > > commands (-file-list-exec-source-file and -file-list-exec-source-files).
> > > I would like to add the fullname to a lot of commands. However, I think
> > > 'filename' and 'fullname' should be standardized, so that front end
> > > writers immediatly understand what they are. It is awkard to have 1
> > > function say "file=" and another say "filename=", when those 2 words
> > > mean the same thing.
> > >
> > > However, if this changes isn't acceptable, I can change it back.
> > >
> > > > > "request path info of current source file (${srcfile})"
> > > > > }
> > > > >
> > > > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > > > ===================================================================
> > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > > > retrieving revision 1.1
> > > > > diff -w -u -r1.1 mi2-file.exp
> > > > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > @@ -47,7 +47,7 @@
> > > > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > > > mi_gdb_load ${binfile}
> > > > >
> > > > > -proc test_tbreak_creation_and_listing {} {
> > > > > +proc test_file_list_exec_source_file {} {
> > > > > global srcfile
> > > > > global srcdir
> > > > > global subdir
> > > > > @@ -55,11 +55,21 @@
> > > > >
> > > > > # get the path and absolute path to the current executable
> > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > "request path info of current source file (${srcfile})"
> > > > > }
> > > > >
> > > > > -test_tbreak_creation_and_listing
> > > > > +proc test_file_list_exec_source_files {} {
> > > > > + global srcfile
> > > > > +
> > > > > + # get the path and absolute path to the current executable
> > > > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> > > >
> > > > > + "Getting a list of source files failed."
> > > > ^^^^^^^
> > > > why failed?
> > >
> > > OOO, That isn't an error condition, it's just a comment. I see.
> > >
> > > Thanks,
> > > Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-04-05 21:40 ` -file-list-exec-source-files Bob Rossi
@ 2004-04-12 15:06 ` Bob Rossi
2004-04-21 1:10 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-04-12 15:06 UTC (permalink / raw)
To: gdb-patches, Elena Zannoni
haha. 7 weeks.
Could someone please review this patch.
Bob Rossi
On Mon, Apr 05, 2004 at 05:40:44PM -0400, Bob Rossi wrote:
> Could someone please review this patch?
>
> It has been 6 weeks. Pinging has not got me very far.
>
> Bob Rossi
>
> On Mon, Mar 29, 2004 at 03:55:46PM -0500, Bob Rossi wrote:
> > What do you think?
> >
> > On Thu, Mar 11, 2004 at 08:25:08AM -0500, Bob Rossi wrote:
> > > What do you think?
> > >
> > > Bob Rossi
> > >
> > > On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> > > > Elena, thanks for taking the time to review my patch.
> > > >
> > > > When is a good point to resubmit a patch? After every review, or after
> > > > all the issues are ironed out?
> > > >
> > > > > > Here is an initial patch for -file-list-exec-source-files.
> > > > > > Some feedback would be appreciated.
> > > > > >
> > > > > > I ran the testsuite and the results are the same before and after this
> > > > > > patch.
> > > > > >
> > > > > > Index: gdb/ChangeLog
> > > > > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> > > > >
> > > > > Each entry should start with capital letter and end with period.
> > > > >
> > > > > I see some coding standards are not adhered to throughout the code.
> > > > > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > > > > calls.
> > > >
> > > > Ok, I will try to fix all of the coding standard errors. Is there a
> > > > program I can run on the source files before I create the diff that
> > > > formats the code according to the standard?
> > > >
> > > > >
> > > > > >
> > > > > > Index: gdb/dbxread.c
> > > > > > ===================================================================
> > > > > > Index: gdb/dwarf2read.c
> > > > > > ===================================================================
> > > > >
> > > > > These are ok
> > > >
> > > > Great!
> > > >
> > > > > >
> > > > > > Index: gdb/defs.h
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > > > > retrieving revision 1.143
> > > > > > diff -w -u -r1.143 defs.h
> > > > > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > > > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > > > > @@ -616,8 +616,6 @@
> > > > > >
> > > > > > extern void init_last_source_visited (void);
> > > > > >
> > > > > > -extern char *symtab_to_filename (struct symtab *);
> > > > > > -
> > > > > > /* From exec.c */
> > > > > >
> > > > > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > > > > Index: gdb/dwarf2read.c
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > > > > retrieving revision 1.135
> > > > > > diff -w -u -r1.135 dwarf2read.c
> > > > > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > > > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > > > > @@ -316,6 +316,7 @@
> > > > > > unsigned int offset;
> > > > > > unsigned int abbrev;
> > > > > > char *name;
> > > > > > + char *dirname;
> > > > > > int has_pc_info;
> > > > > > CORE_ADDR lowpc;
> > > > > > CORE_ADDR highpc;
> > > > > > @@ -1254,6 +1255,8 @@
> > > > > > objfile->global_psymbols.next,
> > > > > > objfile->static_psymbols.next);
> > > > > >
> > > > > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > > > > +
> > > > > > pst->read_symtab_private = (char *)
> > > > > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > > > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > > > > @@ -4326,6 +4329,10 @@
> > > > > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > > > > if (part_die->name == NULL)
> > > > > > part_die->name = DW_STRING (&attr);
> > > > > > + break;
> > > > > > + case DW_AT_comp_dir:
> > > > > > + if (part_die->dirname == NULL)
> > > > > > + part_die->dirname = DW_STRING (&attr);
> > > > >
> > > > > The dwarf2 specs say that the name is in the form ":pathname" or
> > > > > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > > > > that? I have looked at a few executables and didn't see the hostname
> > > > > part.
> > > >
> > > > It would probably just be best if you told me what case's you want me to
> > > > implement here. It seems that Jason Molenda understodd most of the
> > > > cases. I really don't know anything about what GCC emits and would would
> > > > be practical to implement.
> > > >
> > > > > > Index: gdb/source.c
> > > > > > ===================================================================
> > > > >
> > > > > this part I am not clear about.
> > > >
> > > > Ok, Ok. I thought about this a lot. I think I made the best decision and
> > > > can describe why.
> > > >
> > > > A few assumptions are in order. In order to get the fullname (abs path)
> > > > to a file, GDB need's three things. The directory the file was compiled
> > > > in (dirname), the filename in question (filename) and a list of paths
> > > > to search.
> > > >
> > > > > There is already a function called source_full_path_of() would it help
> > > > > if you used it?
> > > >
> > > > The function source_full_path_of does not take into account 'dirname'.
> > > > It calls openp, which is not capable of finding the fullname of a file,
> > > > since it doesn't understand what dirname is. Basically, I don't even
> > > > think this function (source_full_path_of) is "truly" capable of
> > > > finding the fullpath to a file. However, instead of removing it,
> > > > I left it, since caller's of this function might be using for something
> > > > I know nothing about.
> > > >
> > > > > What is the difference between find_and_open_source and
> > > > > open_source_file? I.e. why did you need to introduce it. I think it's
> > > > > not clear just from your comments about the file possibly baing moved
> > > > > around.
> > > >
> > > > open_source_file was left around for backwards compatibility. The unit
> > > > source.c was used to calling a function, with just passing the symtab,
> > > > and getting back the symtab with a valid fullname. I could remove all
> > > > occurences of this function and replace it with symtab_to_fullname.
> > > >
> > > > > I am a bit worried about the substitution of symtab_to_filename with
> > > > > symtab_to_fullname. The former returns null only if there is no
> > > > > symtab. The latter returns null when there is no symtab OR when it
> > > > > cannot find the file. So the behavior is slightly different.
> > > >
> > > > I basically think that the call -file-list-exec-source-files shouldn't
> > > > 'cache' it's results. GDB looks for each file, every time it is
> > > > requested to get the fullname. This is because, the user could have
> > > > changed the path, or moved/deleted the file. I don't think GDB should
> > > > just return the filename instead, of the fullname.
> > > >
> > > > So, if find_and_open_source couldn't "find and open the source file", it
> > > > returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> > > > get's set to NULL.
> > > >
> > > > The testsuite didn't seem to have a problem with this, and I think it
> > > > makes sense to not trick the caller into having results when it couldn't
> > > > find any.
> > > >
> > > > If the caller really wanted this functionality,
> > > > return s->filename; /* File not found. Just use short name */
> > > > I believe it should be the caller's responsibility.
> > > >
> > > > if ( symtab_to_fullname ( s ) == NULL )
> > > > /* use symtab->filename */
> > > > else
> > > > /* use symtab->fullname */
> > > >
> > > > It doesn't really make sense to return the filename and not state that
> > > > it is not really the fullname. Also, if the caller tries to access
> > > > s->fullname, it will not be successful, because the file simply isn't
> > > > there.
> > > >
> > > > > > RCS file: /cvs/src/src/gdb/source.c,v
> > > > > > retrieving revision 1.49
> > > > > > diff -w -u -r1.49 source.c
> > > > > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > > > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > > > > @@ -805,30 +805,47 @@
> > > > > > return 1;
> > > > > > }
> > > > > >
> > > > > > -
> > > > > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > > - negative number for error. */
> > > > > > -
> > > > > > +/* 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.
> > > > > > +
> > > > > > + 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.
> > > > > > + FULLNAME can be the last known absolute path to the file in question.
> > > > > > +
> > > > > > + On Success
> > > > > > + A valid file descriptor is returned. ( the return value is positive )
> > > > > > + FULLNAME is set to the absolute path to the file just opened.
> > > > > > +
> > > > > > + On Failure
> > > > > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > > > > + FULLNAME is set to NULL. */
> > > > > > int
> > > > > > -open_source_file (struct symtab *s)
> > > > > > +find_and_open_source (
> > > > > > + struct objfile *objfile,
> > > > > > + const char *filename,
> > > > > > + const char *dirname,
> > > > > > + char **fullname )
> > > > > > {
> > > > >
> > > > > coding standards....
> > > >
> > > > Ok.
> > > >
> > > > > > char *path = source_path;
> > > > > > const char *p;
> > > > > > int result;
> > > > > > - char *fullname;
> > > > > >
> > > > > > /* Quick way out if we already know its full name */
> > > > > > - if (s->fullname)
> > > > > > + if (*fullname)
> > > > > > {
> > > > > > - result = open (s->fullname, OPEN_MODE);
> > > > > > + result = open (*fullname, OPEN_MODE);
> > > > > > if (result >= 0)
> > > > > > return result;
> > > > > > /* Didn't work -- free old one, try again. */
> > > > > > - xmfree (s->objfile->md, s->fullname);
> > > > > > - s->fullname = NULL;
> > > > > > + xmfree (objfile->md, *fullname);
> > > > > > + *fullname = NULL;
> > > > > > }
> > > > > >
> > > > > > - if (s->dirname != NULL)
> > > > > > + if (dirname != NULL)
> > > > > > {
> > > > > > /* Replace a path entry of $cdir with the compilation directory name */
> > > > > > #define cdir_len 5
> > > > > > @@ -841,60 +858,102 @@
> > > > > > int len;
> > > > > >
> > > > > > path = (char *)
> > > > > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > > > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > > > > len = p - source_path;
> > > > > > strncpy (path, source_path, len); /* Before $cdir */
> > > > > > - strcpy (path + len, s->dirname); /* new stuff */
> > > > > > + strcpy (path + len, dirname); /* new stuff */
> > > > > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > > > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > > > > if (result < 0)
> > > > > > {
> > > > > > /* Didn't work. Try using just the basename. */
> > > > > > - p = lbasename (s->filename);
> > > > > > - if (p != s->filename)
> > > > > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > > > > + p = lbasename (filename);
> > > > > > + if (p != filename)
> > > > > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > > > > }
> > > > > >
> > > > > > if (result >= 0)
> > > > > > {
> > > > > > - fullname = s->fullname;
> > > > > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > > > > - xfree (fullname);
> > > > > > + char *tmp_fullname;
> > > > > > + tmp_fullname = *fullname;
> > > > > > + *fullname = mstrsave (objfile->md, *fullname);
> > > > > > + xfree (tmp_fullname);
> > > > > > }
> > > > > > return result;
> > > > > > }
> > > > > >
> > > > > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > > > > - if no symtab. */
> > > > > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > > + negative number for error.
> > > > > > +
> > > > > > + This function is a convience function to find_and_open_source. */
> > > > > > +
> > > > > > +int
> > > > > > +open_source_file (struct symtab *s)
> > > > > > +{
> > > > > > + if (!s)
> > > > > > + return -1;
> > > > > > +
> > > > > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > > > > +}
> > > > > > +
> > > > > > +/* Finds the fullname that a 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 symtab represents,
> > > > > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > > > > char *
> > > > > > -symtab_to_filename (struct symtab *s)
> > > > > > +symtab_to_fullname (struct symtab *s)
> > > > > > {
> > > > > > - int fd;
> > > > > > + int r;
> > > > > >
> > > > > > if (!s)
> > > > > > return NULL;
> > > > > >
> > > > > > - /* If we've seen the file before, just return fullname. */
> > > > > > + /* 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);
> > > > > >
> > > > > > - if (s->fullname)
> > > > > > + if (r)
> > > > > > + {
> > > > > > + close (r);
> > > > > > return s->fullname;
> > > > > > + }
> > > > > >
> > > > > > - /* Try opening the file to setup fullname */
> > > > > > + return NULL;
> > > > > > +}
> > > > > >
> > > > > > - fd = open_source_file (s);
> > > > > > - if (fd < 0)
> > > > > > - return s->filename; /* File not found. Just use short name */
> > > > > > +/* Finds the fullname that a partial_symtab represents.
> > > > > >
> > > > > > - /* Found the file. Cleanup and return the full name */
> > > > > > + If this functions finds the fullname, it will save it in ps->fullname
> > > > > > + and it will also return the value.
> > > > > >
> > > > > > - close (fd);
> > > > > > - return s->fullname;
> > > > > > + 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)
> > > > > > + return NULL;
> > > > > > +
> > > > > > + /* 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);
> > > > > > +
> > > > > > + if (r)
> > > > > > + {
> > > > > > + close (r);
> > > > > > + return ps->fullname;
> > > > > > }
> > > > > > \f
> > > > > > + return NULL;
> > > > > > +}
> > > > > >
> > > > > > /* Create and initialize the table S->line_charpos that records
> > > > > > the positions of the lines in the source file, which is assumed
> > > > >
> > > > >
> > > > >
> > > > > > Index: gdb/source.h
> > > > > > ===================================================================
> > > > > > Index: gdb/symtab.c
> > > > > > ===================================================================
> > > > >
> > > > > These are obvious if the rest goes in.
> > > > >
> > > > >
> > > > > > Index: gdb/symtab.h
> > > > > > ===================================================================
> > > > >
> > > > > OK.
> > > > >
> > > > >
> > > > > > Index: gdb/mi/mi-cmd-file.c
> > > > > > ===================================================================
> > > > >
> > > > >
> > > > > > +static const char * const FILENAME = "filename";
> > > > > > +static const char * const FULLNAME = "fullname";
> > > > >
> > > > > I don't think these are necessary.
> > > >
> > > > It just unifies the output convention I am using in the
> > > > mi-cmd-file unit. What would you prefer to see?
> > > >
> > > > > >
> > > > > > /* Return to the client the absolute path and line number of the
> > > > > > current file being executed. */
> > > > > > @@ -39,7 +43,6 @@
> > > > > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > > > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > > > > >
> > > > > > -
> > > > > > /* Set the default file and line, also get them */
> > > > > > set_default_source_symtab_and_line();
> > > > > > st = get_current_source_symtab_and_line();
> > > > > > @@ -51,17 +54,67 @@
> > > > > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > > > > >
> > > > > > /* Extract the fullname if it is not known yet */
> > > > > > - if (st.symtab->fullname == NULL)
> > > > > > - symtab_to_filename (st.symtab);
> > > > > > -
> > > > > > - /* We may not be able to open the file (not available). */
> > > > > > - if (st.symtab->fullname == NULL)
> > > > > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> > > > >
> > > > > Why get rid of the error message?
> > > >
> > > > Ok.
> > > >
> > > > > > + symtab_to_fullname (st.symtab);
> > > > > >
> > > > > > /* 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, "fullname", st.symtab->fullname);
> > > > > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> > > >
> > > > I don't know. I am thinking that GDB should just return the absolute
> > > > path to all of the source files it can find. If it can not find some,
> > > > should it issue a warning? That way the front end could say, "you need
> > > > to add a directory to the source search path".
> > > >
> > > > > > + return MI_CMD_DONE;
> > > > > > +}
> > > > > > +
> > > > > > +enum mi_cmd_result
> > > > > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > > > > +{
> > > > > > + struct symtab *s;
> > > > > > + struct partial_symtab *ps;
> > > > > > + struct objfile *objfile;
> > > > > > +
> > > > > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > > > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > > > > +
> > > > > > + /* Print the table header */
> > > > > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > > > > +
> > > > > > + /* Look at all of the symtabs */
> > > > > > + ALL_SYMTABS (objfile, s)
> > > > > > + {
> > > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > > +
> > > > > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > > > > +
> > > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > > + }
> > > > > > +
> > > > > > + /* Look at all of the psymtabs */
> > > > > > + ALL_PSYMTABS (objfile, ps)
> > > > > > + {
> > > > > > + if (!ps->readin) {
> > > > >
> > > > > coding standards....
> > > >
> > > > Ok.
> > > >
> > > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > > +
> > > > > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > > > > +
> > > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > > + }
> > > > > > + }
> > > > > > +
> > > > > > + ui_out_end ( uiout, ui_out_type_list );
> > > > > >
> > > > > > return MI_CMD_DONE;
> > > > > > }
> > > > >
> > > > >
> > > > >
> > > > > > Index: gdb/mi/mi-cmds.c
> > > > > > ===================================================================
> > > > >
> > > > > > Index: gdb/mi/mi-cmds.h
> > > > > > ===================================================================
> > > > >
> > > > > these changes are ok.
> > > >
> > > > Great!
> > > >
> > > > > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > > > > retrieving revision 1.1
> > > > > > diff -w -u -r1.1 mi-file.exp
> > > > > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > > > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > > @@ -55,7 +55,7 @@
> > > > > >
> > > > > > # get the path and absolute path to the current executable
> > > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > >
> > > > > Wouldn't this break existing MI parsers?
> > > >
> > > > Yes. I figured it could be mi2. Also, for some reason, I thought no one
> > > > would be using this function since I wrote it for CGDB, and I haven't
> > > > used it yet. I have a larger plan in mind for MI, than just these 2
> > > > commands (-file-list-exec-source-file and -file-list-exec-source-files).
> > > > I would like to add the fullname to a lot of commands. However, I think
> > > > 'filename' and 'fullname' should be standardized, so that front end
> > > > writers immediatly understand what they are. It is awkard to have 1
> > > > function say "file=" and another say "filename=", when those 2 words
> > > > mean the same thing.
> > > >
> > > > However, if this changes isn't acceptable, I can change it back.
> > > >
> > > > > > "request path info of current source file (${srcfile})"
> > > > > > }
> > > > > >
> > > > > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > > > > retrieving revision 1.1
> > > > > > diff -w -u -r1.1 mi2-file.exp
> > > > > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > > > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > > @@ -47,7 +47,7 @@
> > > > > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > > > > mi_gdb_load ${binfile}
> > > > > >
> > > > > > -proc test_tbreak_creation_and_listing {} {
> > > > > > +proc test_file_list_exec_source_file {} {
> > > > > > global srcfile
> > > > > > global srcdir
> > > > > > global subdir
> > > > > > @@ -55,11 +55,21 @@
> > > > > >
> > > > > > # get the path and absolute path to the current executable
> > > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > "request path info of current source file (${srcfile})"
> > > > > > }
> > > > > >
> > > > > > -test_tbreak_creation_and_listing
> > > > > > +proc test_file_list_exec_source_files {} {
> > > > > > + global srcfile
> > > > > > +
> > > > > > + # get the path and absolute path to the current executable
> > > > > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > > > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> > > > >
> > > > > > + "Getting a list of source files failed."
> > > > > ^^^^^^^
> > > > > why failed?
> > > >
> > > > OOO, That isn't an error condition, it's just a comment. I see.
> > > >
> > > > Thanks,
> > > > Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-04-12 15:06 ` -file-list-exec-source-files Bob Rossi
@ 2004-04-21 1:10 ` Bob Rossi
2004-04-21 4:52 ` -file-list-exec-source-files Eli Zaretskii
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-04-21 1:10 UTC (permalink / raw)
To: gdb-patches, Elena Zannoni
Honestly, will someone please review this patch.
Seriously, why is no one looking at this patch?
It's been over 2 months now!
Bob Rossi
On Mon, Apr 12, 2004 at 11:06:20AM -0400, Bob Rossi wrote:
> haha. 7 weeks.
>
> Could someone please review this patch.
>
> Bob Rossi
>
> On Mon, Apr 05, 2004 at 05:40:44PM -0400, Bob Rossi wrote:
> > Could someone please review this patch?
> >
> > It has been 6 weeks. Pinging has not got me very far.
> >
> > Bob Rossi
> >
> > On Mon, Mar 29, 2004 at 03:55:46PM -0500, Bob Rossi wrote:
> > > What do you think?
> > >
> > > On Thu, Mar 11, 2004 at 08:25:08AM -0500, Bob Rossi wrote:
> > > > What do you think?
> > > >
> > > > Bob Rossi
> > > >
> > > > On Sat, Mar 06, 2004 at 10:57:00AM -0500, Bob Rossi wrote:
> > > > > Elena, thanks for taking the time to review my patch.
> > > > >
> > > > > When is a good point to resubmit a patch? After every review, or after
> > > > > all the issues are ironed out?
> > > > >
> > > > > > > Here is an initial patch for -file-list-exec-source-files.
> > > > > > > Some feedback would be appreciated.
> > > > > > >
> > > > > > > I ran the testsuite and the results are the same before and after this
> > > > > > > patch.
> > > > > > >
> > > > > > > Index: gdb/ChangeLog
> > > > > > > * dbxread.c (read_dbx_symtab): set pst->dirname when known
> > > > > >
> > > > > > Each entry should start with capital letter and end with period.
> > > > > >
> > > > > > I see some coding standards are not adhered to throughout the code.
> > > > > > Most noticeably "foo ( int a )" should be "foo (int a)". Similarly for
> > > > > > calls.
> > > > >
> > > > > Ok, I will try to fix all of the coding standard errors. Is there a
> > > > > program I can run on the source files before I create the diff that
> > > > > formats the code according to the standard?
> > > > >
> > > > > >
> > > > > > >
> > > > > > > Index: gdb/dbxread.c
> > > > > > > ===================================================================
> > > > > > > Index: gdb/dwarf2read.c
> > > > > > > ===================================================================
> > > > > >
> > > > > > These are ok
> > > > >
> > > > > Great!
> > > > >
> > > > > > >
> > > > > > > Index: gdb/defs.h
> > > > > > > ===================================================================
> > > > > > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > > > > > retrieving revision 1.143
> > > > > > > diff -w -u -r1.143 defs.h
> > > > > > > --- gdb/defs.h 23 Feb 2004 19:26:14 -0000 1.143
> > > > > > > +++ gdb/defs.h 25 Feb 2004 03:51:35 -0000
> > > > > > > @@ -616,8 +616,6 @@
> > > > > > >
> > > > > > > extern void init_last_source_visited (void);
> > > > > > >
> > > > > > > -extern char *symtab_to_filename (struct symtab *);
> > > > > > > -
> > > > > > > /* From exec.c */
> > > > > > >
> > > > > > > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > > > > > > Index: gdb/dwarf2read.c
> > > > > > > ===================================================================
> > > > > > > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > > > > > > retrieving revision 1.135
> > > > > > > diff -w -u -r1.135 dwarf2read.c
> > > > > > > --- gdb/dwarf2read.c 21 Feb 2004 02:13:35 -0000 1.135
> > > > > > > +++ gdb/dwarf2read.c 25 Feb 2004 03:51:43 -0000
> > > > > > > @@ -316,6 +316,7 @@
> > > > > > > unsigned int offset;
> > > > > > > unsigned int abbrev;
> > > > > > > char *name;
> > > > > > > + char *dirname;
> > > > > > > int has_pc_info;
> > > > > > > CORE_ADDR lowpc;
> > > > > > > CORE_ADDR highpc;
> > > > > > > @@ -1254,6 +1255,8 @@
> > > > > > > objfile->global_psymbols.next,
> > > > > > > objfile->static_psymbols.next);
> > > > > > >
> > > > > > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > > > > > +
> > > > > > > pst->read_symtab_private = (char *)
> > > > > > > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > > > > > > DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
> > > > > > > @@ -4326,6 +4329,10 @@
> > > > > > > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > > > > > > if (part_die->name == NULL)
> > > > > > > part_die->name = DW_STRING (&attr);
> > > > > > > + break;
> > > > > > > + case DW_AT_comp_dir:
> > > > > > > + if (part_die->dirname == NULL)
> > > > > > > + part_die->dirname = DW_STRING (&attr);
> > > > > >
> > > > > > The dwarf2 specs say that the name is in the form ":pathname" or
> > > > > > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > > > > > that? I have looked at a few executables and didn't see the hostname
> > > > > > part.
> > > > >
> > > > > It would probably just be best if you told me what case's you want me to
> > > > > implement here. It seems that Jason Molenda understodd most of the
> > > > > cases. I really don't know anything about what GCC emits and would would
> > > > > be practical to implement.
> > > > >
> > > > > > > Index: gdb/source.c
> > > > > > > ===================================================================
> > > > > >
> > > > > > this part I am not clear about.
> > > > >
> > > > > Ok, Ok. I thought about this a lot. I think I made the best decision and
> > > > > can describe why.
> > > > >
> > > > > A few assumptions are in order. In order to get the fullname (abs path)
> > > > > to a file, GDB need's three things. The directory the file was compiled
> > > > > in (dirname), the filename in question (filename) and a list of paths
> > > > > to search.
> > > > >
> > > > > > There is already a function called source_full_path_of() would it help
> > > > > > if you used it?
> > > > >
> > > > > The function source_full_path_of does not take into account 'dirname'.
> > > > > It calls openp, which is not capable of finding the fullname of a file,
> > > > > since it doesn't understand what dirname is. Basically, I don't even
> > > > > think this function (source_full_path_of) is "truly" capable of
> > > > > finding the fullpath to a file. However, instead of removing it,
> > > > > I left it, since caller's of this function might be using for something
> > > > > I know nothing about.
> > > > >
> > > > > > What is the difference between find_and_open_source and
> > > > > > open_source_file? I.e. why did you need to introduce it. I think it's
> > > > > > not clear just from your comments about the file possibly baing moved
> > > > > > around.
> > > > >
> > > > > open_source_file was left around for backwards compatibility. The unit
> > > > > source.c was used to calling a function, with just passing the symtab,
> > > > > and getting back the symtab with a valid fullname. I could remove all
> > > > > occurences of this function and replace it with symtab_to_fullname.
> > > > >
> > > > > > I am a bit worried about the substitution of symtab_to_filename with
> > > > > > symtab_to_fullname. The former returns null only if there is no
> > > > > > symtab. The latter returns null when there is no symtab OR when it
> > > > > > cannot find the file. So the behavior is slightly different.
> > > > >
> > > > > I basically think that the call -file-list-exec-source-files shouldn't
> > > > > 'cache' it's results. GDB looks for each file, every time it is
> > > > > requested to get the fullname. This is because, the user could have
> > > > > changed the path, or moved/deleted the file. I don't think GDB should
> > > > > just return the filename instead, of the fullname.
> > > > >
> > > > > So, if find_and_open_source couldn't "find and open the source file", it
> > > > > returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> > > > > get's set to NULL.
> > > > >
> > > > > The testsuite didn't seem to have a problem with this, and I think it
> > > > > makes sense to not trick the caller into having results when it couldn't
> > > > > find any.
> > > > >
> > > > > If the caller really wanted this functionality,
> > > > > return s->filename; /* File not found. Just use short name */
> > > > > I believe it should be the caller's responsibility.
> > > > >
> > > > > if ( symtab_to_fullname ( s ) == NULL )
> > > > > /* use symtab->filename */
> > > > > else
> > > > > /* use symtab->fullname */
> > > > >
> > > > > It doesn't really make sense to return the filename and not state that
> > > > > it is not really the fullname. Also, if the caller tries to access
> > > > > s->fullname, it will not be successful, because the file simply isn't
> > > > > there.
> > > > >
> > > > > > > RCS file: /cvs/src/src/gdb/source.c,v
> > > > > > > retrieving revision 1.49
> > > > > > > diff -w -u -r1.49 source.c
> > > > > > > --- gdb/source.c 27 Jan 2004 23:19:51 -0000 1.49
> > > > > > > +++ gdb/source.c 25 Feb 2004 03:51:45 -0000
> > > > > > > @@ -805,30 +805,47 @@
> > > > > > > return 1;
> > > > > > > }
> > > > > > >
> > > > > > > -
> > > > > > > -/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > > > - negative number for error. */
> > > > > > > -
> > > > > > > +/* 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.
> > > > > > > +
> > > > > > > + 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.
> > > > > > > + FULLNAME can be the last known absolute path to the file in question.
> > > > > > > +
> > > > > > > + On Success
> > > > > > > + A valid file descriptor is returned. ( the return value is positive )
> > > > > > > + FULLNAME is set to the absolute path to the file just opened.
> > > > > > > +
> > > > > > > + On Failure
> > > > > > > + A non valid file descriptor is returned. ( the return value is negitive )
> > > > > > > + FULLNAME is set to NULL. */
> > > > > > > int
> > > > > > > -open_source_file (struct symtab *s)
> > > > > > > +find_and_open_source (
> > > > > > > + struct objfile *objfile,
> > > > > > > + const char *filename,
> > > > > > > + const char *dirname,
> > > > > > > + char **fullname )
> > > > > > > {
> > > > > >
> > > > > > coding standards....
> > > > >
> > > > > Ok.
> > > > >
> > > > > > > char *path = source_path;
> > > > > > > const char *p;
> > > > > > > int result;
> > > > > > > - char *fullname;
> > > > > > >
> > > > > > > /* Quick way out if we already know its full name */
> > > > > > > - if (s->fullname)
> > > > > > > + if (*fullname)
> > > > > > > {
> > > > > > > - result = open (s->fullname, OPEN_MODE);
> > > > > > > + result = open (*fullname, OPEN_MODE);
> > > > > > > if (result >= 0)
> > > > > > > return result;
> > > > > > > /* Didn't work -- free old one, try again. */
> > > > > > > - xmfree (s->objfile->md, s->fullname);
> > > > > > > - s->fullname = NULL;
> > > > > > > + xmfree (objfile->md, *fullname);
> > > > > > > + *fullname = NULL;
> > > > > > > }
> > > > > > >
> > > > > > > - if (s->dirname != NULL)
> > > > > > > + if (dirname != NULL)
> > > > > > > {
> > > > > > > /* Replace a path entry of $cdir with the compilation directory name */
> > > > > > > #define cdir_len 5
> > > > > > > @@ -841,60 +858,102 @@
> > > > > > > int len;
> > > > > > >
> > > > > > > path = (char *)
> > > > > > > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > > > > > > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > > > > > > len = p - source_path;
> > > > > > > strncpy (path, source_path, len); /* Before $cdir */
> > > > > > > - strcpy (path + len, s->dirname); /* new stuff */
> > > > > > > + strcpy (path + len, dirname); /* new stuff */
> > > > > > > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > > > > > > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > > > > > > if (result < 0)
> > > > > > > {
> > > > > > > /* Didn't work. Try using just the basename. */
> > > > > > > - p = lbasename (s->filename);
> > > > > > > - if (p != s->filename)
> > > > > > > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > > > > > > + p = lbasename (filename);
> > > > > > > + if (p != filename)
> > > > > > > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > > > > > > }
> > > > > > >
> > > > > > > if (result >= 0)
> > > > > > > {
> > > > > > > - fullname = s->fullname;
> > > > > > > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > > > > > > - xfree (fullname);
> > > > > > > + char *tmp_fullname;
> > > > > > > + tmp_fullname = *fullname;
> > > > > > > + *fullname = mstrsave (objfile->md, *fullname);
> > > > > > > + xfree (tmp_fullname);
> > > > > > > }
> > > > > > > return result;
> > > > > > > }
> > > > > > >
> > > > > > > -/* Return the path to the source file associated with symtab. Returns NULL
> > > > > > > - if no symtab. */
> > > > > > > +/* Open a source file given a symtab S. Returns a file descriptor or
> > > > > > > + negative number for error.
> > > > > > > +
> > > > > > > + This function is a convience function to find_and_open_source. */
> > > > > > > +
> > > > > > > +int
> > > > > > > +open_source_file (struct symtab *s)
> > > > > > > +{
> > > > > > > + if (!s)
> > > > > > > + return -1;
> > > > > > > +
> > > > > > > + return find_and_open_source ( s->objfile, s->filename, s->dirname, &s->fullname );
> > > > > > > +}
> > > > > > > +
> > > > > > > +/* Finds the fullname that a 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 symtab represents,
> > > > > > > + NULL will be returned and ps->fullname will be set to NULL. */
> > > > > > > char *
> > > > > > > -symtab_to_filename (struct symtab *s)
> > > > > > > +symtab_to_fullname (struct symtab *s)
> > > > > > > {
> > > > > > > - int fd;
> > > > > > > + int r;
> > > > > > >
> > > > > > > if (!s)
> > > > > > > return NULL;
> > > > > > >
> > > > > > > - /* If we've seen the file before, just return fullname. */
> > > > > > > + /* 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);
> > > > > > >
> > > > > > > - if (s->fullname)
> > > > > > > + if (r)
> > > > > > > + {
> > > > > > > + close (r);
> > > > > > > return s->fullname;
> > > > > > > + }
> > > > > > >
> > > > > > > - /* Try opening the file to setup fullname */
> > > > > > > + return NULL;
> > > > > > > +}
> > > > > > >
> > > > > > > - fd = open_source_file (s);
> > > > > > > - if (fd < 0)
> > > > > > > - return s->filename; /* File not found. Just use short name */
> > > > > > > +/* Finds the fullname that a partial_symtab represents.
> > > > > > >
> > > > > > > - /* Found the file. Cleanup and return the full name */
> > > > > > > + If this functions finds the fullname, it will save it in ps->fullname
> > > > > > > + and it will also return the value.
> > > > > > >
> > > > > > > - close (fd);
> > > > > > > - return s->fullname;
> > > > > > > + 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)
> > > > > > > + return NULL;
> > > > > > > +
> > > > > > > + /* 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);
> > > > > > > +
> > > > > > > + if (r)
> > > > > > > + {
> > > > > > > + close (r);
> > > > > > > + return ps->fullname;
> > > > > > > }
> > > > > > > \f
> > > > > > > + return NULL;
> > > > > > > +}
> > > > > > >
> > > > > > > /* Create and initialize the table S->line_charpos that records
> > > > > > > the positions of the lines in the source file, which is assumed
> > > > > >
> > > > > >
> > > > > >
> > > > > > > Index: gdb/source.h
> > > > > > > ===================================================================
> > > > > > > Index: gdb/symtab.c
> > > > > > > ===================================================================
> > > > > >
> > > > > > These are obvious if the rest goes in.
> > > > > >
> > > > > >
> > > > > > > Index: gdb/symtab.h
> > > > > > > ===================================================================
> > > > > >
> > > > > > OK.
> > > > > >
> > > > > >
> > > > > > > Index: gdb/mi/mi-cmd-file.c
> > > > > > > ===================================================================
> > > > > >
> > > > > >
> > > > > > > +static const char * const FILENAME = "filename";
> > > > > > > +static const char * const FULLNAME = "fullname";
> > > > > >
> > > > > > I don't think these are necessary.
> > > > >
> > > > > It just unifies the output convention I am using in the
> > > > > mi-cmd-file unit. What would you prefer to see?
> > > > >
> > > > > > >
> > > > > > > /* Return to the client the absolute path and line number of the
> > > > > > > current file being executed. */
> > > > > > > @@ -39,7 +43,6 @@
> > > > > > > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > > > > > > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> > > > > > >
> > > > > > > -
> > > > > > > /* Set the default file and line, also get them */
> > > > > > > set_default_source_symtab_and_line();
> > > > > > > st = get_current_source_symtab_and_line();
> > > > > > > @@ -51,17 +54,67 @@
> > > > > > > error ("mi_cmd_file_list_exec_source_file: No symtab");
> > > > > > >
> > > > > > > /* Extract the fullname if it is not known yet */
> > > > > > > - if (st.symtab->fullname == NULL)
> > > > > > > - symtab_to_filename (st.symtab);
> > > > > > > -
> > > > > > > - /* We may not be able to open the file (not available). */
> > > > > > > - if (st.symtab->fullname == NULL)
> > > > > > > - error ("mi_cmd_file_list_exec_source_file: File not found");
> > > > > >
> > > > > > Why get rid of the error message?
> > > > >
> > > > > Ok.
> > > > >
> > > > > > > + symtab_to_fullname (st.symtab);
> > > > > > >
> > > > > > > /* 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, "fullname", st.symtab->fullname);
> > > > > > > + ui_out_field_string (uiout, FILENAME, st.symtab->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 this test fails shouldn't some warning/error be issued?
> > > > >
> > > > > I don't know. I am thinking that GDB should just return the absolute
> > > > > path to all of the source files it can find. If it can not find some,
> > > > > should it issue a warning? That way the front end could say, "you need
> > > > > to add a directory to the source search path".
> > > > >
> > > > > > > + return MI_CMD_DONE;
> > > > > > > +}
> > > > > > > +
> > > > > > > +enum mi_cmd_result
> > > > > > > +mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
> > > > > > > +{
> > > > > > > + struct symtab *s;
> > > > > > > + struct partial_symtab *ps;
> > > > > > > + struct objfile *objfile;
> > > > > > > +
> > > > > > > + if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_files", argc, argv) )
> > > > > > > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > > > > > > +
> > > > > > > + /* Print the table header */
> > > > > > > + ui_out_begin ( uiout, ui_out_type_list, "files");
> > > > > > > +
> > > > > > > + /* Look at all of the symtabs */
> > > > > > > + ALL_SYMTABS (objfile, s)
> > > > > > > + {
> > > > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > > > +
> > > > > > > + ui_out_field_string (uiout, FILENAME, s->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);
> > > > > > > +
> > > > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > > > + }
> > > > > > > +
> > > > > > > + /* Look at all of the psymtabs */
> > > > > > > + ALL_PSYMTABS (objfile, ps)
> > > > > > > + {
> > > > > > > + if (!ps->readin) {
> > > > > >
> > > > > > coding standards....
> > > > >
> > > > > Ok.
> > > > >
> > > > > > > + ui_out_begin ( uiout, ui_out_type_tuple, NULL);
> > > > > > > +
> > > > > > > + ui_out_field_string (uiout, FILENAME, ps->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);
> > > > > > > +
> > > > > > > + ui_out_end ( uiout, ui_out_type_tuple );
> > > > > > > + }
> > > > > > > + }
> > > > > > > +
> > > > > > > + ui_out_end ( uiout, ui_out_type_list );
> > > > > > >
> > > > > > > return MI_CMD_DONE;
> > > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > > > Index: gdb/mi/mi-cmds.c
> > > > > > > ===================================================================
> > > > > >
> > > > > > > Index: gdb/mi/mi-cmds.h
> > > > > > > ===================================================================
> > > > > >
> > > > > > these changes are ok.
> > > > >
> > > > > Great!
> > > > >
> > > > > > > Index: gdb/testsuite/gdb.mi/mi-file.exp
> > > > > > > ===================================================================
> > > > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
> > > > > > > retrieving revision 1.1
> > > > > > > diff -w -u -r1.1 mi-file.exp
> > > > > > > --- gdb/testsuite/gdb.mi/mi-file.exp 2 Apr 2003 22:10:35 -0000 1.1
> > > > > > > +++ gdb/testsuite/gdb.mi/mi-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > > > @@ -55,7 +55,7 @@
> > > > > > >
> > > > > > > # get the path and absolute path to the current executable
> > > > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > >
> > > > > > Wouldn't this break existing MI parsers?
> > > > >
> > > > > Yes. I figured it could be mi2. Also, for some reason, I thought no one
> > > > > would be using this function since I wrote it for CGDB, and I haven't
> > > > > used it yet. I have a larger plan in mind for MI, than just these 2
> > > > > commands (-file-list-exec-source-file and -file-list-exec-source-files).
> > > > > I would like to add the fullname to a lot of commands. However, I think
> > > > > 'filename' and 'fullname' should be standardized, so that front end
> > > > > writers immediatly understand what they are. It is awkard to have 1
> > > > > function say "file=" and another say "filename=", when those 2 words
> > > > > mean the same thing.
> > > > >
> > > > > However, if this changes isn't acceptable, I can change it back.
> > > > >
> > > > > > > "request path info of current source file (${srcfile})"
> > > > > > > }
> > > > > > >
> > > > > > > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > > > > > > ===================================================================
> > > > > > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > > > > > > retrieving revision 1.1
> > > > > > > diff -w -u -r1.1 mi2-file.exp
> > > > > > > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > > > > > > +++ gdb/testsuite/gdb.mi/mi2-file.exp 25 Feb 2004 03:52:36 -0000
> > > > > > > @@ -47,7 +47,7 @@
> > > > > > > mi_gdb_reinitialize_dir $srcdir/$subdir
> > > > > > > mi_gdb_load ${binfile}
> > > > > > >
> > > > > > > -proc test_tbreak_creation_and_listing {} {
> > > > > > > +proc test_file_list_exec_source_file {} {
> > > > > > > global srcfile
> > > > > > > global srcdir
> > > > > > > global subdir
> > > > > > > @@ -55,11 +55,21 @@
> > > > > > >
> > > > > > > # get the path and absolute path to the current executable
> > > > > > > mi_gdb_test "111-file-list-exec-source-file" \
> > > > > > > - "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > > + "111\\\^done,line=\"23\",filename=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
> > > > > > > "request path info of current source file (${srcfile})"
> > > > > > > }
> > > > > > >
> > > > > > > -test_tbreak_creation_and_listing
> > > > > > > +proc test_file_list_exec_source_files {} {
> > > > > > > + global srcfile
> > > > > > > +
> > > > > > > + # get the path and absolute path to the current executable
> > > > > > > + mi_gdb_test "222-file-list-exec-source-files" \
> > > > > > > + "222\\\^done,files=\\\[\{filename=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\},\{filename=\".*\"\}\\\]" \
> > > > > >
> > > > > > > + "Getting a list of source files failed."
> > > > > > ^^^^^^^
> > > > > > why failed?
> > > > >
> > > > > OOO, That isn't an error condition, it's just a comment. I see.
> > > > >
> > > > > Thanks,
> > > > > Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-04-21 1:10 ` -file-list-exec-source-files Bob Rossi
@ 2004-04-21 4:52 ` Eli Zaretskii
2004-04-21 12:20 ` -file-list-exec-source-files Bob Rossi
2004-04-22 15:43 ` -file-list-exec-source-files Elena Zannoni
0 siblings, 2 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-04-21 4:52 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches, ezannoni
> Date: Tue, 20 Apr 2004 10:10:01 -0400
> From: Bob Rossi <bob@brasko.net>
>
> Honestly, will someone please review this patch.
>
> Seriously, why is no one looking at this patch?
> It's been over 2 months now!
Bob, I suggest that you submit another patch that takes into account
all the comments, mainly by Elena and Jason, that still stand after
the discussions back then. Right now, your followups are just
reiterations of Elena's comments and your counter-comments; it's hard
to look at the patch whose many parts are invalidated by discussions.
If I missed a newer patch you've already sent, please tell me its URL
in the archives, and I will look at it.
In any case, I think Elena should have the final word, since she is
both responsible for gdb/mi and was the original reviewer of your
submission. But I will try to help her by taking another look at your
code.
Thanks.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-04-21 4:52 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-04-21 12:20 ` Bob Rossi
2004-04-21 18:41 ` -file-list-exec-source-files Eli Zaretskii
2004-04-22 15:43 ` -file-list-exec-source-files Elena Zannoni
1 sibling, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-04-21 12:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, ezannoni
On Wed, Apr 21, 2004 at 07:52:44AM +0200, Eli Zaretskii wrote:
> > Date: Tue, 20 Apr 2004 10:10:01 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > Honestly, will someone please review this patch.
> >
> > Seriously, why is no one looking at this patch?
> > It's been over 2 months now!
>
> Bob, I suggest that you submit another patch that takes into account
> all the comments, mainly by Elena and Jason, that still stand after
> the discussions back then. Right now, your followups are just
> reiterations of Elena's comments and your counter-comments; it's hard
> to look at the patch whose many parts are invalidated by discussions.
>
> If I missed a newer patch you've already sent, please tell me its URL
> in the archives, and I will look at it.
>
> In any case, I think Elena should have the final word, since she is
> both responsible for gdb/mi and was the original reviewer of your
> submission. But I will try to help her by taking another look at your
> code.
Thanks, I will do so right away. BTW, is there a program I can run on
the patch, to gnuify it?
If so, where do I get it?
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-04-21 4:52 ` -file-list-exec-source-files Eli Zaretskii
2004-04-21 12:20 ` -file-list-exec-source-files Bob Rossi
@ 2004-04-22 15:43 ` Elena Zannoni
2004-04-27 0:05 ` -file-list-exec-source-files Bob Rossi
1 sibling, 1 reply; 69+ messages in thread
From: Elena Zannoni @ 2004-04-22 15:43 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Bob Rossi, gdb-patches, ezannoni
Eli Zaretskii writes:
> > Date: Tue, 20 Apr 2004 10:10:01 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > Honestly, will someone please review this patch.
> >
> > Seriously, why is no one looking at this patch?
> > It's been over 2 months now!
>
> Bob, I suggest that you submit another patch that takes into account
> all the comments, mainly by Elena and Jason, that still stand after
> the discussions back then. Right now, your followups are just
> reiterations of Elena's comments and your counter-comments; it's hard
> to look at the patch whose many parts are invalidated by discussions.
>
> If I missed a newer patch you've already sent, please tell me its URL
> in the archives, and I will look at it.
>
> In any case, I think Elena should have the final word, since she is
> both responsible for gdb/mi and was the original reviewer of your
> submission. But I will try to help her by taking another look at your
> code.
>
Thank you Eli for helping in this, I appreciate the help. Bob, please
run gdb_indent.sh (found in the gdb source directory) on your code to
make it conform to gnu standards. Also address the issues you feel
comfortable fixing. Once that's done we can have another look.
> Thanks.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-04-22 15:43 ` -file-list-exec-source-files Elena Zannoni
@ 2004-04-27 0:05 ` Bob Rossi
2004-05-06 22:13 ` -file-list-exec-source-files Bob Rossi
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
0 siblings, 2 replies; 69+ messages in thread
From: Bob Rossi @ 2004-04-27 0:05 UTC (permalink / raw)
To: Elena Zannoni; +Cc: Eli Zaretskii, gdb-patches
On Thu, Apr 22, 2004 at 11:40:31AM -0400, Elena Zannoni wrote:
> Eli Zaretskii writes:
> > > Date: Tue, 20 Apr 2004 10:10:01 -0400
> > > From: Bob Rossi <bob@brasko.net>
> > >
> > > Honestly, will someone please review this patch.
> > >
> > > Seriously, why is no one looking at this patch?
> > > It's been over 2 months now!
> >
> > Bob, I suggest that you submit another patch that takes into account
> > all the comments, mainly by Elena and Jason, that still stand after
> > the discussions back then. Right now, your followups are just
> > reiterations of Elena's comments and your counter-comments; it's hard
> > to look at the patch whose many parts are invalidated by discussions.
> >
> > If I missed a newer patch you've already sent, please tell me its URL
> > in the archives, and I will look at it.
> >
> > In any case, I think Elena should have the final word, since she is
> > both responsible for gdb/mi and was the original reviewer of your
> > submission. But I will try to help her by taking another look at your
> > code.
> >
>
> Thank you Eli for helping in this, I appreciate the help. Bob, please
> run gdb_indent.sh (found in the gdb source directory) on your code to
> make it conform to gnu standards. Also address the issues you feel
> comfortable fixing. Once that's done we can have another look.
Thanks, here is a new patch. The testsuite is still passing with this
change.
I hopefully fixed the formatting problems and most of the other issues
you brought up. The only 2 known issues are the
1. dwarf2 specs about :pathname or hostname:pathname
2. comments about source.c
Here were your comments with my respone,
> this part I am not clear about.
Ok, Ok. I thought about this a lot. I think I made the best decision and
can describe why.
A few assumptions are in order. In order to get the fullname (abs path)
to a file, GDB need's three things. The directory the file was compiled
in (dirname), the filename in question (filename) and a list of paths
to search.
> There is already a function called source_full_path_of() would it help
> if you used it?
The function source_full_path_of does not take into account 'dirname'.
It calls openp, which is not capable of finding the fullname of a file,
since it doesn't understand what dirname is. Basically, I don't even
think this function (source_full_path_of) is "truly" capable of
finding the fullpath to a file. However, instead of removing it,
I left it, since caller's of this function might be using for something
I know nothing about.
> What is the difference between find_and_open_source and
> open_source_file? I.e. why did you need to introduce it. I think it's
> not clear just from your comments about the file possibly baing moved
> around.
open_source_file was left around for backwards compatibility. The unit
source.c was used to calling a function, with just passing the symtab,
and getting back the symtab with a valid fullname. I could remove all
occurences of this function and replace it with symtab_to_fullname.
> I am a bit worried about the substitution of symtab_to_filename with
> symtab_to_fullname. The former returns null only if there is no
> symtab. The latter returns null when there is no symtab OR when it
> cannot find the file. So the behavior is slightly different.
I basically think that the call -file-list-exec-source-files shouldn't
'cache' it's results. GDB looks for each file, every time it is
requested to get the fullname. This is because, the user could have
changed the path, or moved/deleted the file. I don't think GDB should
just return the filename instead, of the fullname.
So, if find_and_open_source couldn't "find and open the source file", it
returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
get's set to NULL.
The testsuite didn't seem to have a problem with this, and I think it
makes sense to not trick the caller into having results when it couldn't
find any.
If the caller really wanted this functionality,
return s->filename; /* File not found. Just use short name */
I believe it should be the caller's responsibility.
if ( symtab_to_fullname ( s ) == NULL )
/* use symtab->filename */
else
/* use symtab->fullname */
It doesn't really make sense to return the filename and not state that
it is not really the fullname. Also, if the caller tries to access
s->fullname, it will not be successful, because the file simply isn't
there.
Bob Rossi
Index: gdb/dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.64
diff -w -u -r1.64 dbxread.c
--- gdb/dbxread.c 14 Feb 2004 15:46:32 -0000 1.64
+++ gdb/dbxread.c 26 Apr 2004 23:54:42 -0000
@@ -1463,6 +1463,7 @@
static int prev_so_symnum = -10;
static int first_so_symnum;
char *p;
+ static char *dirname_nso;
int prev_textlow_not_set;
valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -1520,18 +1521,27 @@
p = strrchr (namestring, '/');
if (p && *(p + 1) == '\000')
- continue; /* Simply ignore directory name SOs */
+ {
+ /* Save the directory name SOs locally, then save it into
+ the psymtab when it's created below. */
+ dirname_nso = namestring;
+ continue;
+ }
/* Some other compilers (C++ ones in particular) emit useless
SOs for non-existant .c files. We ignore all subsequent SOs that
immediately follow the first. */
if (!pst)
+ {
pst = start_psymtab (objfile,
namestring, valu,
first_so_symnum * symbol_size,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = dirname_nso;
+ dirname_nso = NULL;
+ }
continue;
}
Index: gdb/defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.144
diff -w -u -r1.144 defs.h
--- gdb/defs.h 21 Apr 2004 23:52:20 -0000 1.144
+++ gdb/defs.h 26 Apr 2004 23:54:44 -0000
@@ -616,8 +616,6 @@
extern void init_last_source_visited (void);
-extern char *symtab_to_filename (struct symtab *);
-
/* From exec.c */
extern void exec_set_section_offsets (bfd_signed_vma text_off,
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.148
diff -w -u -r1.148 dwarf2read.c
--- gdb/dwarf2read.c 19 Apr 2004 18:20:50 -0000 1.148
+++ gdb/dwarf2read.c 26 Apr 2004 23:54:52 -0000
@@ -378,6 +378,7 @@
sometimes DW_TAG_MIPS_linkage_name or a string computed in some
other fashion. */
char *name;
+ char *dirname;
/* The scope to prepend to our children. This is generally
allocated on the comp_unit_obstack, so will disappear
@@ -1272,6 +1273,8 @@
objfile->global_psymbols.next,
objfile->static_psymbols.next);
+ pst->dirname = xstrdup ( comp_unit_die.dirname );
+
pst->read_symtab_private = (char *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf2_per_objfile->info_buffer;
@@ -4771,6 +4774,10 @@
/* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
if (part_die->name == NULL)
part_die->name = DW_STRING (&attr);
+ break;
+ case DW_AT_comp_dir:
+ if (part_die->dirname == NULL)
+ part_die->dirname = DW_STRING (&attr);
break;
case DW_AT_MIPS_linkage_name:
part_die->name = DW_STRING (&attr);
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.50
diff -w -u -r1.50 source.c
--- gdb/source.c 28 Feb 2004 18:04:37 -0000 1.50
+++ gdb/source.c 26 Apr 2004 23:54:54 -0000
@@ -805,30 +805,45 @@
return 1;
}
-
-/* Open a source file given a symtab S. Returns a file descriptor or
- negative number for error. */
-
+/* 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.
+
+ 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.
+ FULLNAME can be the last known absolute path to the file in question.
+
+ On Success
+ A valid file descriptor is returned. ( the return value is positive )
+ FULLNAME is set to the absolute path to the file just opened.
+
+ On Failure
+ A non valid file descriptor is returned. ( the return value is negitive )
+ FULLNAME is set to NULL. */
int
-open_source_file (struct symtab *s)
+find_and_open_source (struct objfile *objfile,
+ const char *filename,
+ const char *dirname, char **fullname)
{
char *path = source_path;
const char *p;
int result;
- char *fullname;
/* Quick way out if we already know its full name */
- if (s->fullname)
+ if (*fullname)
{
- result = open (s->fullname, OPEN_MODE);
+ result = open (*fullname, OPEN_MODE);
if (result >= 0)
return result;
/* Didn't work -- free old one, try again. */
- xmfree (s->objfile->md, s->fullname);
- s->fullname = NULL;
+ xmfree (objfile->md, *fullname);
+ *fullname = NULL;
}
- if (s->dirname != NULL)
+ if (dirname != NULL)
{
/* Replace a path entry of $cdir with the compilation directory name */
#define cdir_len 5
@@ -841,60 +856,106 @@
int len;
path = (char *)
- alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
+ alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
len = p - source_path;
strncpy (path, source_path, len); /* Before $cdir */
- strcpy (path + len, s->dirname); /* new stuff */
+ strcpy (path + len, dirname); /* new stuff */
strcat (path + len, source_path + len + cdir_len); /* After $cdir */
}
}
- result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
+ result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
- p = lbasename (s->filename);
- if (p != s->filename)
- result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
+ p = lbasename (filename);
+ if (p != filename)
+ result = openp (path, 0, p, OPEN_MODE, 0, fullname);
}
if (result >= 0)
{
- fullname = s->fullname;
- s->fullname = mstrsave (s->objfile->md, s->fullname);
- xfree (fullname);
+ char *tmp_fullname;
+ tmp_fullname = *fullname;
+ *fullname = mstrsave (objfile->md, *fullname);
+ xfree (tmp_fullname);
}
return result;
}
-/* Return the path to the source file associated with symtab. Returns NULL
- if no symtab. */
+/* Open a source file given a symtab S. Returns a file descriptor or
+ negative number for error.
+
+ This function is a convience function to find_and_open_source. */
+
+int
+open_source_file (struct symtab *s)
+{
+ if (!s)
+ return -1;
+
+ return find_and_open_source (s->objfile, s->filename, s->dirname,
+ &s->fullname);
+}
+
+/* Finds the fullname that a 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 symtab represents,
+ NULL will be returned and ps->fullname will be set to NULL. */
char *
-symtab_to_filename (struct symtab *s)
+symtab_to_fullname (struct symtab *s)
{
- int fd;
+ int r;
if (!s)
return NULL;
- /* If we've seen the file before, just return fullname. */
+ /* 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);
- if (s->fullname)
+ if (r)
+ {
+ close (r);
return s->fullname;
+ }
- /* Try opening the file to setup fullname */
+ return NULL;
+}
- fd = open_source_file (s);
- if (fd < 0)
- return s->filename; /* File not found. Just use short name */
+/* Finds the fullname that a partial_symtab represents.
- /* Found the file. Cleanup and return the full name */
+ If this functions finds the fullname, it will save it in ps->fullname
+ and it will also return the value.
- close (fd);
- return s->fullname;
+ 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)
+ return NULL;
+
+ /* 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);
+
+ if (r)
+ {
+ close (r);
+ return ps->fullname;
}
\f
+ return NULL;
+}
/* Create and initialize the table S->line_charpos that records
the positions of the lines in the source file, which is assumed
Index: gdb/source.h
===================================================================
RCS file: /cvs/src/src/gdb/source.h,v
retrieving revision 1.4
diff -w -u -r1.4 source.h
--- gdb/source.h 12 Apr 2003 17:41:25 -0000 1.4
+++ gdb/source.h 26 Apr 2004 23:54:54 -0000
@@ -27,6 +27,9 @@
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 );
+
/* 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
Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.129
diff -w -u -r1.129 symtab.c
--- gdb/symtab.c 8 Apr 2004 21:18:13 -0000 1.129
+++ gdb/symtab.c 26 Apr 2004 23:54:58 -0000
@@ -181,7 +181,7 @@
if (full_path != NULL)
{
- const char *fp = symtab_to_filename (s);
+ const char *fp = symtab_to_fullname (s);
if (FILENAME_CMP (full_path, fp) == 0)
{
return s;
@@ -190,7 +190,7 @@
if (real_path != NULL)
{
- char *rp = gdb_realpath (symtab_to_filename (s));
+ char *rp = gdb_realpath (symtab_to_fullname (s));
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
Index: gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.90
diff -w -u -r1.90 symtab.h
--- gdb/symtab.h 8 Apr 2004 21:18:13 -0000 1.90
+++ gdb/symtab.h 26 Apr 2004 23:55:01 -0000
@@ -877,6 +877,10 @@
char *fullname;
+ /* Directory in which it was compiled, or NULL if we don't know. */
+
+ char *dirname;
+
/* Information about the object file from which symbols should be read. */
struct objfile *objfile;
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.202
diff -w -u -r1.202 gdb.texinfo
--- gdb/doc/gdb.texinfo 28 Mar 2004 12:22:55 -0000 1.202
+++ gdb/doc/gdb.texinfo 26 Apr 2004 23:55:26 -0000
@@ -16805,14 +16805,24 @@
List the source files for the current executable.
+It will always output the filename, but only when GDB can find the absolute
+path to a source file, will it output the fullname.
+
@subsubheading @value{GDBN} Command
There's no @value{GDBN} command which directly corresponds to this one.
@code{gdbtk} has an analogous command @samp{gdb_listfiles}.
@subsubheading Example
-N.A.
-
+@smallexample
+(@value{GDBP})
+-file-list-exec-source-files
+^done,files=[
+@{file=foo.c,fullname=/home/foo.c@},
+@{file=/home/bar.c,fullname=/home/bar.c@},
+@{file=gdb_could_not_find_fullpath.c@}]
+(@value{GDBP})
+@end smallexample
@subheading The @code{-file-list-shared-libraries} Command
@findex -file-list-shared-libraries
Index: gdb/mi/mi-cmd-file.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
retrieving revision 1.1
diff -w -u -r1.1 mi-cmd-file.c
--- gdb/mi/mi-cmd-file.c 2 Apr 2003 22:10:35 -0000 1.1
+++ gdb/mi/mi-cmd-file.c 26 Apr 2004 23:55:26 -0000
@@ -25,6 +25,7 @@
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
+#include "objfiles.h"
/* Return to the client the absolute path and line number of the
current file being executed. */
@@ -39,7 +40,6 @@
if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
-
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
@@ -51,17 +51,68 @@
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
- if (st.symtab->fullname == NULL)
- symtab_to_filename (st.symtab);
-
- /* We may not be able to open the file (not available). */
- if (st.symtab->fullname == NULL)
- error ("mi_cmd_file_list_exec_source_file: File not found");
+ symtab_to_fullname (st.symtab);
/* 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);
+
+ /* We may not be able to open the file (not available). */
+ if (st.symtab->fullname)
ui_out_field_string (uiout, "fullname", st.symtab->fullname);
+
+ return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
+{
+ struct symtab *s;
+ struct partial_symtab *ps;
+ struct objfile *objfile;
+
+ if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv))
+ error ("mi_cmd_file_list_exec_source_files: Usage: No args");
+
+ /* Print the table header */
+ ui_out_begin (uiout, ui_out_type_list, "files");
+
+ /* Look at all of the symtabs */
+ ALL_SYMTABS (objfile, s)
+ {
+ ui_out_begin (uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, "file", s->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);
+
+ ui_out_end (uiout, ui_out_type_tuple);
+ }
+
+ /* Look at all of the psymtabs */
+ ALL_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin)
+ {
+ ui_out_begin (uiout, ui_out_type_tuple, NULL);
+
+ ui_out_field_string (uiout, "file", ps->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);
+
+ ui_out_end (uiout, ui_out_type_tuple);
+ }
+ }
+
+ ui_out_end (uiout, ui_out_type_list);
return MI_CMD_DONE;
}
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.14
diff -w -u -r1.14 mi-cmds.c
--- gdb/mi/mi-cmds.c 4 Aug 2003 23:18:50 -0000 1.14
+++ gdb/mi/mi-cmds.c 26 Apr 2004 23:55:26 -0000
@@ -81,7 +81,7 @@
{ "file-exec-file", { "exec-file", 1 }, NULL, NULL },
{ "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
{ "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
- { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
+ { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
{ "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
{ "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
{ "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
Index: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.12
diff -w -u -r1.12 mi-cmds.h
--- gdb/mi/mi-cmds.h 24 Jan 2004 04:21:43 -0000 1.12
+++ gdb/mi/mi-cmds.h 26 Apr 2004 23:55:26 -0000
@@ -87,6 +87,7 @@
extern mi_cmd_args_ftype mi_cmd_exec_until;
extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
+extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
Index: gdb/testsuite/gdb.mi/mi2-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi2-file.exp
--- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
+++ gdb/testsuite/gdb.mi/mi2-file.exp 26 Apr 2004 23:55:27 -0000
@@ -47,7 +47,7 @@
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-proc test_tbreak_creation_and_listing {} {
+proc test_file_list_exec_source_file {} {
global srcfile
global srcdir
global subdir
@@ -59,7 +59,17 @@
"request path info of current source file (${srcfile})"
}
-test_tbreak_creation_and_listing
+proc test_file_list_exec_source_files {} {
+ global srcfile
+
+ # get the path and absolute path to the current executable
+ mi_gdb_test "222-file-list-exec-source-files" \
+ "222\\\^done,files=\\\[\{file=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\}\\\]" \
+ "Getting a list of source files."
+}
+
+test_file_list_exec_source_file
+test_file_list_exec_source_files
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-04-27 0:05 ` -file-list-exec-source-files Bob Rossi
@ 2004-05-06 22:13 ` Bob Rossi
2004-05-07 15:24 ` -file-list-exec-source-files Eli Zaretskii
` (2 more replies)
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
1 sibling, 3 replies; 69+ messages in thread
From: Bob Rossi @ 2004-05-06 22:13 UTC (permalink / raw)
To: Elena Zannoni, Eli Zaretskii, gdb-patches
Any comments?
Bob Rossi
On Mon, Apr 26, 2004 at 09:05:30AM -0400, Bob Rossi wrote:
> On Thu, Apr 22, 2004 at 11:40:31AM -0400, Elena Zannoni wrote:
> > Eli Zaretskii writes:
> > > > Date: Tue, 20 Apr 2004 10:10:01 -0400
> > > > From: Bob Rossi <bob@brasko.net>
> > > >
> > > > Honestly, will someone please review this patch.
> > > >
> > > > Seriously, why is no one looking at this patch?
> > > > It's been over 2 months now!
> > >
> > > Bob, I suggest that you submit another patch that takes into account
> > > all the comments, mainly by Elena and Jason, that still stand after
> > > the discussions back then. Right now, your followups are just
> > > reiterations of Elena's comments and your counter-comments; it's hard
> > > to look at the patch whose many parts are invalidated by discussions.
> > >
> > > If I missed a newer patch you've already sent, please tell me its URL
> > > in the archives, and I will look at it.
> > >
> > > In any case, I think Elena should have the final word, since she is
> > > both responsible for gdb/mi and was the original reviewer of your
> > > submission. But I will try to help her by taking another look at your
> > > code.
> > >
> >
> > Thank you Eli for helping in this, I appreciate the help. Bob, please
> > run gdb_indent.sh (found in the gdb source directory) on your code to
> > make it conform to gnu standards. Also address the issues you feel
> > comfortable fixing. Once that's done we can have another look.
>
> Thanks, here is a new patch. The testsuite is still passing with this
> change.
>
> I hopefully fixed the formatting problems and most of the other issues
> you brought up. The only 2 known issues are the
> 1. dwarf2 specs about :pathname or hostname:pathname
> 2. comments about source.c
>
> Here were your comments with my respone,
>
> > this part I am not clear about.
>
> Ok, Ok. I thought about this a lot. I think I made the best decision and
> can describe why.
>
> A few assumptions are in order. In order to get the fullname (abs path)
> to a file, GDB need's three things. The directory the file was compiled
> in (dirname), the filename in question (filename) and a list of paths
> to search.
>
> > There is already a function called source_full_path_of() would it help
> > if you used it?
>
> The function source_full_path_of does not take into account 'dirname'.
> It calls openp, which is not capable of finding the fullname of a file,
> since it doesn't understand what dirname is. Basically, I don't even
> think this function (source_full_path_of) is "truly" capable of
> finding the fullpath to a file. However, instead of removing it,
> I left it, since caller's of this function might be using for something
> I know nothing about.
>
> > What is the difference between find_and_open_source and
> > open_source_file? I.e. why did you need to introduce it. I think it's
> > not clear just from your comments about the file possibly baing moved
> > around.
>
> open_source_file was left around for backwards compatibility. The unit
> source.c was used to calling a function, with just passing the symtab,
> and getting back the symtab with a valid fullname. I could remove all
> occurences of this function and replace it with symtab_to_fullname.
>
> > I am a bit worried about the substitution of symtab_to_filename with
> > symtab_to_fullname. The former returns null only if there is no
> > symtab. The latter returns null when there is no symtab OR when it
> > cannot find the file. So the behavior is slightly different.
>
> I basically think that the call -file-list-exec-source-files shouldn't
> 'cache' it's results. GDB looks for each file, every time it is
> requested to get the fullname. This is because, the user could have
> changed the path, or moved/deleted the file. I don't think GDB should
> just return the filename instead, of the fullname.
>
> So, if find_and_open_source couldn't "find and open the source file", it
> returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> get's set to NULL.
>
> The testsuite didn't seem to have a problem with this, and I think it
> makes sense to not trick the caller into having results when it couldn't
> find any.
>
> If the caller really wanted this functionality,
> return s->filename; /* File not found. Just use short name */
> I believe it should be the caller's responsibility.
>
> if ( symtab_to_fullname ( s ) == NULL )
> /* use symtab->filename */
> else
> /* use symtab->fullname */
>
> It doesn't really make sense to return the filename and not state that
> it is not really the fullname. Also, if the caller tries to access
> s->fullname, it will not be successful, because the file simply isn't
> there.
>
> Bob Rossi
>
> Index: gdb/dbxread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dbxread.c,v
> retrieving revision 1.64
> diff -w -u -r1.64 dbxread.c
> --- gdb/dbxread.c 14 Feb 2004 15:46:32 -0000 1.64
> +++ gdb/dbxread.c 26 Apr 2004 23:54:42 -0000
> @@ -1463,6 +1463,7 @@
> static int prev_so_symnum = -10;
> static int first_so_symnum;
> char *p;
> + static char *dirname_nso;
> int prev_textlow_not_set;
>
> valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
> @@ -1520,18 +1521,27 @@
>
> p = strrchr (namestring, '/');
> if (p && *(p + 1) == '\000')
> - continue; /* Simply ignore directory name SOs */
> + {
> + /* Save the directory name SOs locally, then save it into
> + the psymtab when it's created below. */
> + dirname_nso = namestring;
> + continue;
> + }
>
> /* Some other compilers (C++ ones in particular) emit useless
> SOs for non-existant .c files. We ignore all subsequent SOs that
> immediately follow the first. */
>
> if (!pst)
> + {
> pst = start_psymtab (objfile,
> namestring, valu,
> first_so_symnum * symbol_size,
> objfile->global_psymbols.next,
> objfile->static_psymbols.next);
> + pst->dirname = dirname_nso;
> + dirname_nso = NULL;
> + }
> continue;
> }
>
> Index: gdb/defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.144
> diff -w -u -r1.144 defs.h
> --- gdb/defs.h 21 Apr 2004 23:52:20 -0000 1.144
> +++ gdb/defs.h 26 Apr 2004 23:54:44 -0000
> @@ -616,8 +616,6 @@
>
> extern void init_last_source_visited (void);
>
> -extern char *symtab_to_filename (struct symtab *);
> -
> /* From exec.c */
>
> extern void exec_set_section_offsets (bfd_signed_vma text_off,
> Index: gdb/dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.148
> diff -w -u -r1.148 dwarf2read.c
> --- gdb/dwarf2read.c 19 Apr 2004 18:20:50 -0000 1.148
> +++ gdb/dwarf2read.c 26 Apr 2004 23:54:52 -0000
> @@ -378,6 +378,7 @@
> sometimes DW_TAG_MIPS_linkage_name or a string computed in some
> other fashion. */
> char *name;
> + char *dirname;
>
> /* The scope to prepend to our children. This is generally
> allocated on the comp_unit_obstack, so will disappear
> @@ -1272,6 +1273,8 @@
> objfile->global_psymbols.next,
> objfile->static_psymbols.next);
>
> + pst->dirname = xstrdup ( comp_unit_die.dirname );
> +
> pst->read_symtab_private = (char *)
> obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf2_per_objfile->info_buffer;
> @@ -4771,6 +4774,10 @@
> /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> if (part_die->name == NULL)
> part_die->name = DW_STRING (&attr);
> + break;
> + case DW_AT_comp_dir:
> + if (part_die->dirname == NULL)
> + part_die->dirname = DW_STRING (&attr);
> break;
> case DW_AT_MIPS_linkage_name:
> part_die->name = DW_STRING (&attr);
> Index: gdb/source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.50
> diff -w -u -r1.50 source.c
> --- gdb/source.c 28 Feb 2004 18:04:37 -0000 1.50
> +++ gdb/source.c 26 Apr 2004 23:54:54 -0000
> @@ -805,30 +805,45 @@
> return 1;
> }
>
> -
> -/* Open a source file given a symtab S. Returns a file descriptor or
> - negative number for error. */
> -
> +/* 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.
> +
> + 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.
> + FULLNAME can be the last known absolute path to the file in question.
> +
> + On Success
> + A valid file descriptor is returned. ( the return value is positive )
> + FULLNAME is set to the absolute path to the file just opened.
> +
> + On Failure
> + A non valid file descriptor is returned. ( the return value is negitive )
> + FULLNAME is set to NULL. */
> int
> -open_source_file (struct symtab *s)
> +find_and_open_source (struct objfile *objfile,
> + const char *filename,
> + const char *dirname, char **fullname)
> {
> char *path = source_path;
> const char *p;
> int result;
> - char *fullname;
>
> /* Quick way out if we already know its full name */
> - if (s->fullname)
> + if (*fullname)
> {
> - result = open (s->fullname, OPEN_MODE);
> + result = open (*fullname, OPEN_MODE);
> if (result >= 0)
> return result;
> /* Didn't work -- free old one, try again. */
> - xmfree (s->objfile->md, s->fullname);
> - s->fullname = NULL;
> + xmfree (objfile->md, *fullname);
> + *fullname = NULL;
> }
>
> - if (s->dirname != NULL)
> + if (dirname != NULL)
> {
> /* Replace a path entry of $cdir with the compilation directory name */
> #define cdir_len 5
> @@ -841,60 +856,106 @@
> int len;
>
> path = (char *)
> - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> len = p - source_path;
> strncpy (path, source_path, len); /* Before $cdir */
> - strcpy (path + len, s->dirname); /* new stuff */
> + strcpy (path + len, dirname); /* new stuff */
> strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> }
> }
>
> - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> if (result < 0)
> {
> /* Didn't work. Try using just the basename. */
> - p = lbasename (s->filename);
> - if (p != s->filename)
> - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> + p = lbasename (filename);
> + if (p != filename)
> + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> }
>
> if (result >= 0)
> {
> - fullname = s->fullname;
> - s->fullname = mstrsave (s->objfile->md, s->fullname);
> - xfree (fullname);
> + char *tmp_fullname;
> + tmp_fullname = *fullname;
> + *fullname = mstrsave (objfile->md, *fullname);
> + xfree (tmp_fullname);
> }
> return result;
> }
>
> -/* Return the path to the source file associated with symtab. Returns NULL
> - if no symtab. */
> +/* Open a source file given a symtab S. Returns a file descriptor or
> + negative number for error.
> +
> + This function is a convience function to find_and_open_source. */
> +
> +int
> +open_source_file (struct symtab *s)
> +{
> + if (!s)
> + return -1;
> +
> + return find_and_open_source (s->objfile, s->filename, s->dirname,
> + &s->fullname);
> +}
> +
> +/* Finds the fullname that a 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 symtab represents,
> + NULL will be returned and ps->fullname will be set to NULL. */
> char *
> -symtab_to_filename (struct symtab *s)
> +symtab_to_fullname (struct symtab *s)
> {
> - int fd;
> + int r;
>
> if (!s)
> return NULL;
>
> - /* If we've seen the file before, just return fullname. */
> + /* 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);
>
> - if (s->fullname)
> + if (r)
> + {
> + close (r);
> return s->fullname;
> + }
>
> - /* Try opening the file to setup fullname */
> + return NULL;
> +}
>
> - fd = open_source_file (s);
> - if (fd < 0)
> - return s->filename; /* File not found. Just use short name */
> +/* Finds the fullname that a partial_symtab represents.
>
> - /* Found the file. Cleanup and return the full name */
> + If this functions finds the fullname, it will save it in ps->fullname
> + and it will also return the value.
>
> - close (fd);
> - return s->fullname;
> + 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)
> + return NULL;
> +
> + /* 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);
> +
> + if (r)
> + {
> + close (r);
> + return ps->fullname;
> }
> \f
> + return NULL;
> +}
>
> /* Create and initialize the table S->line_charpos that records
> the positions of the lines in the source file, which is assumed
> Index: gdb/source.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.h,v
> retrieving revision 1.4
> diff -w -u -r1.4 source.h
> --- gdb/source.h 12 Apr 2003 17:41:25 -0000 1.4
> +++ gdb/source.h 26 Apr 2004 23:54:54 -0000
> @@ -27,6 +27,9 @@
> 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 );
> +
> /* 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
> Index: gdb/symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.129
> diff -w -u -r1.129 symtab.c
> --- gdb/symtab.c 8 Apr 2004 21:18:13 -0000 1.129
> +++ gdb/symtab.c 26 Apr 2004 23:54:58 -0000
> @@ -181,7 +181,7 @@
>
> if (full_path != NULL)
> {
> - const char *fp = symtab_to_filename (s);
> + const char *fp = symtab_to_fullname (s);
> if (FILENAME_CMP (full_path, fp) == 0)
> {
> return s;
> @@ -190,7 +190,7 @@
>
> if (real_path != NULL)
> {
> - char *rp = gdb_realpath (symtab_to_filename (s));
> + char *rp = gdb_realpath (symtab_to_fullname (s));
> make_cleanup (xfree, rp);
> if (FILENAME_CMP (real_path, rp) == 0)
> {
> Index: gdb/symtab.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.h,v
> retrieving revision 1.90
> diff -w -u -r1.90 symtab.h
> --- gdb/symtab.h 8 Apr 2004 21:18:13 -0000 1.90
> +++ gdb/symtab.h 26 Apr 2004 23:55:01 -0000
> @@ -877,6 +877,10 @@
>
> char *fullname;
>
> + /* Directory in which it was compiled, or NULL if we don't know. */
> +
> + char *dirname;
> +
> /* Information about the object file from which symbols should be read. */
>
> struct objfile *objfile;
> Index: gdb/doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.202
> diff -w -u -r1.202 gdb.texinfo
> --- gdb/doc/gdb.texinfo 28 Mar 2004 12:22:55 -0000 1.202
> +++ gdb/doc/gdb.texinfo 26 Apr 2004 23:55:26 -0000
> @@ -16805,14 +16805,24 @@
>
> List the source files for the current executable.
>
> +It will always output the filename, but only when GDB can find the absolute
> +path to a source file, will it output the fullname.
> +
> @subsubheading @value{GDBN} Command
>
> There's no @value{GDBN} command which directly corresponds to this one.
> @code{gdbtk} has an analogous command @samp{gdb_listfiles}.
>
> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-file-list-exec-source-files
> +^done,files=[
> +@{file=foo.c,fullname=/home/foo.c@},
> +@{file=/home/bar.c,fullname=/home/bar.c@},
> +@{file=gdb_could_not_find_fullpath.c@}]
> +(@value{GDBP})
> +@end smallexample
>
> @subheading The @code{-file-list-shared-libraries} Command
> @findex -file-list-shared-libraries
> Index: gdb/mi/mi-cmd-file.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi-cmd-file.c
> --- gdb/mi/mi-cmd-file.c 2 Apr 2003 22:10:35 -0000 1.1
> +++ gdb/mi/mi-cmd-file.c 26 Apr 2004 23:55:26 -0000
> @@ -25,6 +25,7 @@
> #include "ui-out.h"
> #include "symtab.h"
> #include "source.h"
> +#include "objfiles.h"
>
> /* Return to the client the absolute path and line number of the
> current file being executed. */
> @@ -39,7 +40,6 @@
> if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> error ("mi_cmd_file_list_exec_source_file: Usage: No args");
>
> -
> /* Set the default file and line, also get them */
> set_default_source_symtab_and_line();
> st = get_current_source_symtab_and_line();
> @@ -51,17 +51,68 @@
> error ("mi_cmd_file_list_exec_source_file: No symtab");
>
> /* Extract the fullname if it is not known yet */
> - if (st.symtab->fullname == NULL)
> - symtab_to_filename (st.symtab);
> -
> - /* We may not be able to open the file (not available). */
> - if (st.symtab->fullname == NULL)
> - error ("mi_cmd_file_list_exec_source_file: File not found");
> + symtab_to_fullname (st.symtab);
>
> /* 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);
> +
> + /* We may not be able to open the file (not available). */
> + if (st.symtab->fullname)
> ui_out_field_string (uiout, "fullname", st.symtab->fullname);
> +
> + return MI_CMD_DONE;
> +}
> +
> +enum mi_cmd_result
> +mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
> +{
> + struct symtab *s;
> + struct partial_symtab *ps;
> + struct objfile *objfile;
> +
> + if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv))
> + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> +
> + /* Print the table header */
> + ui_out_begin (uiout, ui_out_type_list, "files");
> +
> + /* Look at all of the symtabs */
> + ALL_SYMTABS (objfile, s)
> + {
> + ui_out_begin (uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, "file", s->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);
> +
> + ui_out_end (uiout, ui_out_type_tuple);
> + }
> +
> + /* Look at all of the psymtabs */
> + ALL_PSYMTABS (objfile, ps)
> + {
> + if (!ps->readin)
> + {
> + ui_out_begin (uiout, ui_out_type_tuple, NULL);
> +
> + ui_out_field_string (uiout, "file", ps->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);
> +
> + ui_out_end (uiout, ui_out_type_tuple);
> + }
> + }
> +
> + ui_out_end (uiout, ui_out_type_list);
>
> return MI_CMD_DONE;
> }
> Index: gdb/mi/mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.14
> diff -w -u -r1.14 mi-cmds.c
> --- gdb/mi/mi-cmds.c 4 Aug 2003 23:18:50 -0000 1.14
> +++ gdb/mi/mi-cmds.c 26 Apr 2004 23:55:26 -0000
> @@ -81,7 +81,7 @@
> { "file-exec-file", { "exec-file", 1 }, NULL, NULL },
> { "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
> { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
> - { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
> + { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
> { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
> { "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
> { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
> Index: gdb/mi/mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.12
> diff -w -u -r1.12 mi-cmds.h
> --- gdb/mi/mi-cmds.h 24 Jan 2004 04:21:43 -0000 1.12
> +++ gdb/mi/mi-cmds.h 26 Apr 2004 23:55:26 -0000
> @@ -87,6 +87,7 @@
> extern mi_cmd_args_ftype mi_cmd_exec_until;
> extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
> extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
> +extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
> extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
> extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
> extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
> Index: gdb/testsuite/gdb.mi/mi2-file.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> retrieving revision 1.1
> diff -w -u -r1.1 mi2-file.exp
> --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> +++ gdb/testsuite/gdb.mi/mi2-file.exp 26 Apr 2004 23:55:27 -0000
> @@ -47,7 +47,7 @@
> mi_gdb_reinitialize_dir $srcdir/$subdir
> mi_gdb_load ${binfile}
>
> -proc test_tbreak_creation_and_listing {} {
> +proc test_file_list_exec_source_file {} {
> global srcfile
> global srcdir
> global subdir
> @@ -59,7 +59,17 @@
> "request path info of current source file (${srcfile})"
> }
>
> -test_tbreak_creation_and_listing
> +proc test_file_list_exec_source_files {} {
> + global srcfile
> +
> + # get the path and absolute path to the current executable
> + mi_gdb_test "222-file-list-exec-source-files" \
> + "222\\\^done,files=\\\[\{file=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\}\\\]" \
> + "Getting a list of source files."
> +}
> +
> +test_file_list_exec_source_file
> +test_file_list_exec_source_files
>
> mi_gdb_exit
> return 0
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-05-06 22:13 ` -file-list-exec-source-files Bob Rossi
@ 2004-05-07 15:24 ` Eli Zaretskii
[not found] ` <9743-Sat08May2004132930+0300-eliz@gnu.org>
2004-05-22 1:53 ` -file-list-exec-source-files Bob Rossi
2 siblings, 0 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-05-07 15:24 UTC (permalink / raw)
To: Bob Rossi; +Cc: ezannoni, gdb-patches
> Date: Thu, 6 May 2004 18:12:59 -0400
> From: Bob Rossi <bob@brasko.net>
>
> Any comments?
I hope to look at this VSN.
^ permalink raw reply [flat|nested] 69+ messages in thread[parent not found: <9743-Sat08May2004132930+0300-eliz@gnu.org>]
* Re: -file-list-exec-source-files
[not found] ` <9743-Sat08May2004132930+0300-eliz@gnu.org>
@ 2004-05-17 13:11 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-05-17 13:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ezannoni, gdb-patches
On Sat, May 08, 2004 at 01:29:30PM +0200, Eli Zaretskii wrote:
> > Date: Thu, 6 May 2004 18:12:59 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > Any comments?
>
> The patch looks fine to me. Elena, could you please look at it and
> give your blessing?
Elena, I guess your the one I should nag to look at this patch. Is there
any incentive I could send your way? A box of chocolates perhaps?
> > --- gdb/doc/gdb.texinfo 28 Mar 2004 12:22:55 -0000 1.202
> > +++ gdb/doc/gdb.texinfo 26 Apr 2004 23:55:26 -0000
> > @@ -16805,14 +16805,24 @@
> >
> > List the source files for the current executable.
> >
> > +It will always output the filename, but only when GDB can find the absolute
> > +path to a source file, will it output the fullname.
>
> Please say ``can find the absolute file name of a source file''. The
> word ``path'' is used in the GNU project's documentation for lists of
> directories used for file-searching, like the one in $PATH.
> Otherwise, the patch for documentation is approved.
Thanks, I changed the doc in my sandbox, next time I post the patch it
should be reflected.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-05-06 22:13 ` -file-list-exec-source-files Bob Rossi
2004-05-07 15:24 ` -file-list-exec-source-files Eli Zaretskii
[not found] ` <9743-Sat08May2004132930+0300-eliz@gnu.org>
@ 2004-05-22 1:53 ` Bob Rossi
2004-05-23 10:40 ` -file-list-exec-source-files Eli Zaretskii
` (2 more replies)
2 siblings, 3 replies; 69+ messages in thread
From: Bob Rossi @ 2004-05-22 1:53 UTC (permalink / raw)
To: Elena Zannoni, Eli Zaretskii, gdb-patches; +Cc: gdbheads, gdb-discuss
OK, I just finished ripping down the ceiling and walls in my kitchen.
Is there any chance my patch got reviewed in that time? There's an
outstanding bet between my wife and I that I will be able to completely
renovate my kitchen before this patch gets reviewed.
What does that say about the GDB patch review process?!?
Can I *even* get a response from someone capable of committing this
patch?
Someone with authority, pleeeaaassseeeee help me.
Thanks,
Bob Rossi
On Thu, May 06, 2004 at 06:12:59PM -0400, Bob Rossi wrote:
> Any comments?
>
> Bob Rossi
>
> On Mon, Apr 26, 2004 at 09:05:30AM -0400, Bob Rossi wrote:
> > On Thu, Apr 22, 2004 at 11:40:31AM -0400, Elena Zannoni wrote:
> > > Eli Zaretskii writes:
> > > > > Date: Tue, 20 Apr 2004 10:10:01 -0400
> > > > > From: Bob Rossi <bob@brasko.net>
> > > > >
> > > > > Honestly, will someone please review this patch.
> > > > >
> > > > > Seriously, why is no one looking at this patch?
> > > > > It's been over 2 months now!
> > > >
> > > > Bob, I suggest that you submit another patch that takes into account
> > > > all the comments, mainly by Elena and Jason, that still stand after
> > > > the discussions back then. Right now, your followups are just
> > > > reiterations of Elena's comments and your counter-comments; it's hard
> > > > to look at the patch whose many parts are invalidated by discussions.
> > > >
> > > > If I missed a newer patch you've already sent, please tell me its URL
> > > > in the archives, and I will look at it.
> > > >
> > > > In any case, I think Elena should have the final word, since she is
> > > > both responsible for gdb/mi and was the original reviewer of your
> > > > submission. But I will try to help her by taking another look at your
> > > > code.
> > > >
> > >
> > > Thank you Eli for helping in this, I appreciate the help. Bob, please
> > > run gdb_indent.sh (found in the gdb source directory) on your code to
> > > make it conform to gnu standards. Also address the issues you feel
> > > comfortable fixing. Once that's done we can have another look.
> >
> > Thanks, here is a new patch. The testsuite is still passing with this
> > change.
> >
> > I hopefully fixed the formatting problems and most of the other issues
> > you brought up. The only 2 known issues are the
> > 1. dwarf2 specs about :pathname or hostname:pathname
> > 2. comments about source.c
> >
> > Here were your comments with my respone,
> >
> > > this part I am not clear about.
> >
> > Ok, Ok. I thought about this a lot. I think I made the best decision and
> > can describe why.
> >
> > A few assumptions are in order. In order to get the fullname (abs path)
> > to a file, GDB need's three things. The directory the file was compiled
> > in (dirname), the filename in question (filename) and a list of paths
> > to search.
> >
> > > There is already a function called source_full_path_of() would it help
> > > if you used it?
> >
> > The function source_full_path_of does not take into account 'dirname'.
> > It calls openp, which is not capable of finding the fullname of a file,
> > since it doesn't understand what dirname is. Basically, I don't even
> > think this function (source_full_path_of) is "truly" capable of
> > finding the fullpath to a file. However, instead of removing it,
> > I left it, since caller's of this function might be using for something
> > I know nothing about.
> >
> > > What is the difference between find_and_open_source and
> > > open_source_file? I.e. why did you need to introduce it. I think it's
> > > not clear just from your comments about the file possibly baing moved
> > > around.
> >
> > open_source_file was left around for backwards compatibility. The unit
> > source.c was used to calling a function, with just passing the symtab,
> > and getting back the symtab with a valid fullname. I could remove all
> > occurences of this function and replace it with symtab_to_fullname.
> >
> > > I am a bit worried about the substitution of symtab_to_filename with
> > > symtab_to_fullname. The former returns null only if there is no
> > > symtab. The latter returns null when there is no symtab OR when it
> > > cannot find the file. So the behavior is slightly different.
> >
> > I basically think that the call -file-list-exec-source-files shouldn't
> > 'cache' it's results. GDB looks for each file, every time it is
> > requested to get the fullname. This is because, the user could have
> > changed the path, or moved/deleted the file. I don't think GDB should
> > just return the filename instead, of the fullname.
> >
> > So, if find_and_open_source couldn't "find and open the source file", it
> > returns NULL. Also, as a side effect, fullname in the [ps]ymtab also
> > get's set to NULL.
> >
> > The testsuite didn't seem to have a problem with this, and I think it
> > makes sense to not trick the caller into having results when it couldn't
> > find any.
> >
> > If the caller really wanted this functionality,
> > return s->filename; /* File not found. Just use short name */
> > I believe it should be the caller's responsibility.
> >
> > if ( symtab_to_fullname ( s ) == NULL )
> > /* use symtab->filename */
> > else
> > /* use symtab->fullname */
> >
> > It doesn't really make sense to return the filename and not state that
> > it is not really the fullname. Also, if the caller tries to access
> > s->fullname, it will not be successful, because the file simply isn't
> > there.
> >
> > Bob Rossi
> >
> > Index: gdb/dbxread.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dbxread.c,v
> > retrieving revision 1.64
> > diff -w -u -r1.64 dbxread.c
> > --- gdb/dbxread.c 14 Feb 2004 15:46:32 -0000 1.64
> > +++ gdb/dbxread.c 26 Apr 2004 23:54:42 -0000
> > @@ -1463,6 +1463,7 @@
> > static int prev_so_symnum = -10;
> > static int first_so_symnum;
> > char *p;
> > + static char *dirname_nso;
> > int prev_textlow_not_set;
> >
> > valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
> > @@ -1520,18 +1521,27 @@
> >
> > p = strrchr (namestring, '/');
> > if (p && *(p + 1) == '\000')
> > - continue; /* Simply ignore directory name SOs */
> > + {
> > + /* Save the directory name SOs locally, then save it into
> > + the psymtab when it's created below. */
> > + dirname_nso = namestring;
> > + continue;
> > + }
> >
> > /* Some other compilers (C++ ones in particular) emit useless
> > SOs for non-existant .c files. We ignore all subsequent SOs that
> > immediately follow the first. */
> >
> > if (!pst)
> > + {
> > pst = start_psymtab (objfile,
> > namestring, valu,
> > first_so_symnum * symbol_size,
> > objfile->global_psymbols.next,
> > objfile->static_psymbols.next);
> > + pst->dirname = dirname_nso;
> > + dirname_nso = NULL;
> > + }
> > continue;
> > }
> >
> > Index: gdb/defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.144
> > diff -w -u -r1.144 defs.h
> > --- gdb/defs.h 21 Apr 2004 23:52:20 -0000 1.144
> > +++ gdb/defs.h 26 Apr 2004 23:54:44 -0000
> > @@ -616,8 +616,6 @@
> >
> > extern void init_last_source_visited (void);
> >
> > -extern char *symtab_to_filename (struct symtab *);
> > -
> > /* From exec.c */
> >
> > extern void exec_set_section_offsets (bfd_signed_vma text_off,
> > Index: gdb/dwarf2read.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > retrieving revision 1.148
> > diff -w -u -r1.148 dwarf2read.c
> > --- gdb/dwarf2read.c 19 Apr 2004 18:20:50 -0000 1.148
> > +++ gdb/dwarf2read.c 26 Apr 2004 23:54:52 -0000
> > @@ -378,6 +378,7 @@
> > sometimes DW_TAG_MIPS_linkage_name or a string computed in some
> > other fashion. */
> > char *name;
> > + char *dirname;
> >
> > /* The scope to prepend to our children. This is generally
> > allocated on the comp_unit_obstack, so will disappear
> > @@ -1272,6 +1273,8 @@
> > objfile->global_psymbols.next,
> > objfile->static_psymbols.next);
> >
> > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > +
> > pst->read_symtab_private = (char *)
> > obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
> > DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf2_per_objfile->info_buffer;
> > @@ -4771,6 +4774,10 @@
> > /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
> > if (part_die->name == NULL)
> > part_die->name = DW_STRING (&attr);
> > + break;
> > + case DW_AT_comp_dir:
> > + if (part_die->dirname == NULL)
> > + part_die->dirname = DW_STRING (&attr);
> > break;
> > case DW_AT_MIPS_linkage_name:
> > part_die->name = DW_STRING (&attr);
> > Index: gdb/source.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.50
> > diff -w -u -r1.50 source.c
> > --- gdb/source.c 28 Feb 2004 18:04:37 -0000 1.50
> > +++ gdb/source.c 26 Apr 2004 23:54:54 -0000
> > @@ -805,30 +805,45 @@
> > return 1;
> > }
> >
> > -
> > -/* Open a source file given a symtab S. Returns a file descriptor or
> > - negative number for error. */
> > -
> > +/* 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.
> > +
> > + 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.
> > + FULLNAME can be the last known absolute path to the file in question.
> > +
> > + On Success
> > + A valid file descriptor is returned. ( the return value is positive )
> > + FULLNAME is set to the absolute path to the file just opened.
> > +
> > + On Failure
> > + A non valid file descriptor is returned. ( the return value is negitive )
> > + FULLNAME is set to NULL. */
> > int
> > -open_source_file (struct symtab *s)
> > +find_and_open_source (struct objfile *objfile,
> > + const char *filename,
> > + const char *dirname, char **fullname)
> > {
> > char *path = source_path;
> > const char *p;
> > int result;
> > - char *fullname;
> >
> > /* Quick way out if we already know its full name */
> > - if (s->fullname)
> > + if (*fullname)
> > {
> > - result = open (s->fullname, OPEN_MODE);
> > + result = open (*fullname, OPEN_MODE);
> > if (result >= 0)
> > return result;
> > /* Didn't work -- free old one, try again. */
> > - xmfree (s->objfile->md, s->fullname);
> > - s->fullname = NULL;
> > + xmfree (objfile->md, *fullname);
> > + *fullname = NULL;
> > }
> >
> > - if (s->dirname != NULL)
> > + if (dirname != NULL)
> > {
> > /* Replace a path entry of $cdir with the compilation directory name */
> > #define cdir_len 5
> > @@ -841,60 +856,106 @@
> > int len;
> >
> > path = (char *)
> > - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1);
> > + alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
> > len = p - source_path;
> > strncpy (path, source_path, len); /* Before $cdir */
> > - strcpy (path + len, s->dirname); /* new stuff */
> > + strcpy (path + len, dirname); /* new stuff */
> > strcat (path + len, source_path + len + cdir_len); /* After $cdir */
> > }
> > }
> >
> > - result = openp (path, 0, s->filename, OPEN_MODE, 0, &s->fullname);
> > + result = openp (path, 0, filename, OPEN_MODE, 0, fullname);
> > if (result < 0)
> > {
> > /* Didn't work. Try using just the basename. */
> > - p = lbasename (s->filename);
> > - if (p != s->filename)
> > - result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname);
> > + p = lbasename (filename);
> > + if (p != filename)
> > + result = openp (path, 0, p, OPEN_MODE, 0, fullname);
> > }
> >
> > if (result >= 0)
> > {
> > - fullname = s->fullname;
> > - s->fullname = mstrsave (s->objfile->md, s->fullname);
> > - xfree (fullname);
> > + char *tmp_fullname;
> > + tmp_fullname = *fullname;
> > + *fullname = mstrsave (objfile->md, *fullname);
> > + xfree (tmp_fullname);
> > }
> > return result;
> > }
> >
> > -/* Return the path to the source file associated with symtab. Returns NULL
> > - if no symtab. */
> > +/* Open a source file given a symtab S. Returns a file descriptor or
> > + negative number for error.
> > +
> > + This function is a convience function to find_and_open_source. */
> > +
> > +int
> > +open_source_file (struct symtab *s)
> > +{
> > + if (!s)
> > + return -1;
> > +
> > + return find_and_open_source (s->objfile, s->filename, s->dirname,
> > + &s->fullname);
> > +}
> > +
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
> > char *
> > -symtab_to_filename (struct symtab *s)
> > +symtab_to_fullname (struct symtab *s)
> > {
> > - int fd;
> > + int r;
> >
> > if (!s)
> > return NULL;
> >
> > - /* If we've seen the file before, just return fullname. */
> > + /* 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);
> >
> > - if (s->fullname)
> > + if (r)
> > + {
> > + close (r);
> > return s->fullname;
> > + }
> >
> > - /* Try opening the file to setup fullname */
> > + return NULL;
> > +}
> >
> > - fd = open_source_file (s);
> > - if (fd < 0)
> > - return s->filename; /* File not found. Just use short name */
> > +/* Finds the fullname that a partial_symtab represents.
> >
> > - /* Found the file. Cleanup and return the full name */
> > + If this functions finds the fullname, it will save it in ps->fullname
> > + and it will also return the value.
> >
> > - close (fd);
> > - return s->fullname;
> > + 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)
> > + return NULL;
> > +
> > + /* 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);
> > +
> > + if (r)
> > + {
> > + close (r);
> > + return ps->fullname;
> > }
> > \f
> > + return NULL;
> > +}
> >
> > /* Create and initialize the table S->line_charpos that records
> > the positions of the lines in the source file, which is assumed
> > Index: gdb/source.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/source.h,v
> > retrieving revision 1.4
> > diff -w -u -r1.4 source.h
> > --- gdb/source.h 12 Apr 2003 17:41:25 -0000 1.4
> > +++ gdb/source.h 26 Apr 2004 23:54:54 -0000
> > @@ -27,6 +27,9 @@
> > 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 );
> > +
> > /* 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
> > Index: gdb/symtab.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/symtab.c,v
> > retrieving revision 1.129
> > diff -w -u -r1.129 symtab.c
> > --- gdb/symtab.c 8 Apr 2004 21:18:13 -0000 1.129
> > +++ gdb/symtab.c 26 Apr 2004 23:54:58 -0000
> > @@ -181,7 +181,7 @@
> >
> > if (full_path != NULL)
> > {
> > - const char *fp = symtab_to_filename (s);
> > + const char *fp = symtab_to_fullname (s);
> > if (FILENAME_CMP (full_path, fp) == 0)
> > {
> > return s;
> > @@ -190,7 +190,7 @@
> >
> > if (real_path != NULL)
> > {
> > - char *rp = gdb_realpath (symtab_to_filename (s));
> > + char *rp = gdb_realpath (symtab_to_fullname (s));
> > make_cleanup (xfree, rp);
> > if (FILENAME_CMP (real_path, rp) == 0)
> > {
> > Index: gdb/symtab.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/symtab.h,v
> > retrieving revision 1.90
> > diff -w -u -r1.90 symtab.h
> > --- gdb/symtab.h 8 Apr 2004 21:18:13 -0000 1.90
> > +++ gdb/symtab.h 26 Apr 2004 23:55:01 -0000
> > @@ -877,6 +877,10 @@
> >
> > char *fullname;
> >
> > + /* Directory in which it was compiled, or NULL if we don't know. */
> > +
> > + char *dirname;
> > +
> > /* Information about the object file from which symbols should be read. */
> >
> > struct objfile *objfile;
> > Index: gdb/doc/gdb.texinfo
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> > retrieving revision 1.202
> > diff -w -u -r1.202 gdb.texinfo
> > --- gdb/doc/gdb.texinfo 28 Mar 2004 12:22:55 -0000 1.202
> > +++ gdb/doc/gdb.texinfo 26 Apr 2004 23:55:26 -0000
> > @@ -16805,14 +16805,24 @@
> >
> > List the source files for the current executable.
> >
> > +It will always output the filename, but only when GDB can find the absolute
> > +path to a source file, will it output the fullname.
> > +
> > @subsubheading @value{GDBN} Command
> >
> > There's no @value{GDBN} command which directly corresponds to this one.
> > @code{gdbtk} has an analogous command @samp{gdb_listfiles}.
> >
> > @subsubheading Example
> > -N.A.
> > -
> > +@smallexample
> > +(@value{GDBP})
> > +-file-list-exec-source-files
> > +^done,files=[
> > +@{file=foo.c,fullname=/home/foo.c@},
> > +@{file=/home/bar.c,fullname=/home/bar.c@},
> > +@{file=gdb_could_not_find_fullpath.c@}]
> > +(@value{GDBP})
> > +@end smallexample
> >
> > @subheading The @code{-file-list-shared-libraries} Command
> > @findex -file-list-shared-libraries
> > Index: gdb/mi/mi-cmd-file.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi-cmd-file.c
> > --- gdb/mi/mi-cmd-file.c 2 Apr 2003 22:10:35 -0000 1.1
> > +++ gdb/mi/mi-cmd-file.c 26 Apr 2004 23:55:26 -0000
> > @@ -25,6 +25,7 @@
> > #include "ui-out.h"
> > #include "symtab.h"
> > #include "source.h"
> > +#include "objfiles.h"
> >
> > /* Return to the client the absolute path and line number of the
> > current file being executed. */
> > @@ -39,7 +40,6 @@
> > if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
> > error ("mi_cmd_file_list_exec_source_file: Usage: No args");
> >
> > -
> > /* Set the default file and line, also get them */
> > set_default_source_symtab_and_line();
> > st = get_current_source_symtab_and_line();
> > @@ -51,17 +51,68 @@
> > error ("mi_cmd_file_list_exec_source_file: No symtab");
> >
> > /* Extract the fullname if it is not known yet */
> > - if (st.symtab->fullname == NULL)
> > - symtab_to_filename (st.symtab);
> > -
> > - /* We may not be able to open the file (not available). */
> > - if (st.symtab->fullname == NULL)
> > - error ("mi_cmd_file_list_exec_source_file: File not found");
> > + symtab_to_fullname (st.symtab);
> >
> > /* 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);
> > +
> > + /* We may not be able to open the file (not available). */
> > + if (st.symtab->fullname)
> > ui_out_field_string (uiout, "fullname", st.symtab->fullname);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +enum mi_cmd_result
> > +mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
> > +{
> > + struct symtab *s;
> > + struct partial_symtab *ps;
> > + struct objfile *objfile;
> > +
> > + if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv))
> > + error ("mi_cmd_file_list_exec_source_files: Usage: No args");
> > +
> > + /* Print the table header */
> > + ui_out_begin (uiout, ui_out_type_list, "files");
> > +
> > + /* Look at all of the symtabs */
> > + ALL_SYMTABS (objfile, s)
> > + {
> > + ui_out_begin (uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, "file", s->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);
> > +
> > + ui_out_end (uiout, ui_out_type_tuple);
> > + }
> > +
> > + /* Look at all of the psymtabs */
> > + ALL_PSYMTABS (objfile, ps)
> > + {
> > + if (!ps->readin)
> > + {
> > + ui_out_begin (uiout, ui_out_type_tuple, NULL);
> > +
> > + ui_out_field_string (uiout, "file", ps->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);
> > +
> > + ui_out_end (uiout, ui_out_type_tuple);
> > + }
> > + }
> > +
> > + ui_out_end (uiout, ui_out_type_list);
> >
> > return MI_CMD_DONE;
> > }
> > Index: gdb/mi/mi-cmds.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> > retrieving revision 1.14
> > diff -w -u -r1.14 mi-cmds.c
> > --- gdb/mi/mi-cmds.c 4 Aug 2003 23:18:50 -0000 1.14
> > +++ gdb/mi/mi-cmds.c 26 Apr 2004 23:55:26 -0000
> > @@ -81,7 +81,7 @@
> > { "file-exec-file", { "exec-file", 1 }, NULL, NULL },
> > { "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
> > { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
> > - { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
> > + { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
> > { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
> > { "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
> > { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
> > Index: gdb/mi/mi-cmds.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> > retrieving revision 1.12
> > diff -w -u -r1.12 mi-cmds.h
> > --- gdb/mi/mi-cmds.h 24 Jan 2004 04:21:43 -0000 1.12
> > +++ gdb/mi/mi-cmds.h 26 Apr 2004 23:55:26 -0000
> > @@ -87,6 +87,7 @@
> > extern mi_cmd_args_ftype mi_cmd_exec_until;
> > extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
> > extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
> > +extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
> > extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
> > extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
> > extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
> > Index: gdb/testsuite/gdb.mi/mi2-file.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-file.exp,v
> > retrieving revision 1.1
> > diff -w -u -r1.1 mi2-file.exp
> > --- gdb/testsuite/gdb.mi/mi2-file.exp 7 Aug 2003 17:47:42 -0000 1.1
> > +++ gdb/testsuite/gdb.mi/mi2-file.exp 26 Apr 2004 23:55:27 -0000
> > @@ -47,7 +47,7 @@
> > mi_gdb_reinitialize_dir $srcdir/$subdir
> > mi_gdb_load ${binfile}
> >
> > -proc test_tbreak_creation_and_listing {} {
> > +proc test_file_list_exec_source_file {} {
> > global srcfile
> > global srcdir
> > global subdir
> > @@ -59,7 +59,17 @@
> > "request path info of current source file (${srcfile})"
> > }
> >
> > -test_tbreak_creation_and_listing
> > +proc test_file_list_exec_source_files {} {
> > + global srcfile
> > +
> > + # get the path and absolute path to the current executable
> > + mi_gdb_test "222-file-list-exec-source-files" \
> > + "222\\\^done,files=\\\[\{file=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\}\\\]" \
> > + "Getting a list of source files."
> > +}
> > +
> > +test_file_list_exec_source_file
> > +test_file_list_exec_source_files
> >
> > mi_gdb_exit
> > return 0
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-05-22 1:53 ` -file-list-exec-source-files Bob Rossi
@ 2004-05-23 10:40 ` Eli Zaretskii
2004-05-23 10:51 ` -file-list-exec-source-files Eli Zaretskii
2004-06-01 16:07 ` -file-list-exec-source-files Elena Zannoni
2 siblings, 0 replies; 69+ messages in thread
From: Eli Zaretskii @ 2004-05-23 10:40 UTC (permalink / raw)
To: Bob Rossi; +Cc: ezannoni, gdb-patches, gdbheads, gdb-discuss
> Date: Fri, 21 May 2004 21:52:50 -0400
> From: Bob Rossi <bob@brasko.net>
>
> OK, I just finished ripping down the ceiling and walls in my kitchen.
> Is there any chance my patch got reviewed in that time? There's an
> outstanding bet between my wife and I that I will be able to completely
> renovate my kitchen before this patch gets reviewed.
>
> What does that say about the GDB patch review process?!?
>
> Can I *even* get a response from someone capable of committing this
> patch?
>
> Someone with authority, pleeeaaassseeeee help me.
I've reviewed your patch 2 weeks ago and approved the patch to
gdb.texinfo. I also okayed the other parts of your patch, but the
final approval should come from developers who are responsible for the
MI stuff: Andrew Cagney and Elena Zannoni (according to the
MAINTAINERS file).
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-05-22 1:53 ` -file-list-exec-source-files Bob Rossi
2004-05-23 10:40 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-05-23 10:51 ` Eli Zaretskii
2004-05-24 2:02 ` -file-list-exec-source-files Bob Rossi
2004-06-01 16:07 ` -file-list-exec-source-files Elena Zannoni
2 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-05-23 10:51 UTC (permalink / raw)
To: Bob Rossi; +Cc: ezannoni, gdb-patches, gdb-discuss
> Date: Fri, 21 May 2004 21:52:50 -0400
> From: Bob Rossi <bob@brasko.net>
>
> OK, I just finished ripping down the ceiling and walls in my kitchen.
> Is there any chance my patch got reviewed in that time? There's an
> outstanding bet between my wife and I that I will be able to completely
> renovate my kitchen before this patch gets reviewed.
>
> What does that say about the GDB patch review process?!?
>
> Can I *even* get a response from someone capable of committing this
> patch?
>
> Someone with authority, pleeeaaassseeeee help me.
I've reviewed your patch 2 weeks ago and approved the patch to
gdb.texinfo. I also okayed the other parts of your patch, but the
final approval should come from developers who are responsible for the
MI stuff: Andrew Cagney and Elena Zannoni (according to the
MAINTAINERS file).
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-05-23 10:51 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-05-24 2:02 ` Bob Rossi
2004-05-28 12:52 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-05-24 2:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ezannoni, gdb-patches, gdb-discuss
On Sun, May 23, 2004 at 01:46:09PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 21 May 2004 21:52:50 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > OK, I just finished ripping down the ceiling and walls in my kitchen.
> > Is there any chance my patch got reviewed in that time? There's an
> > outstanding bet between my wife and I that I will be able to completely
> > renovate my kitchen before this patch gets reviewed.
> >
> > What does that say about the GDB patch review process?!?
> >
> > Can I *even* get a response from someone capable of committing this
> > patch?
> >
> > Someone with authority, pleeeaaassseeeee help me.
>
> I've reviewed your patch 2 weeks ago and approved the patch to
> gdb.texinfo. I also okayed the other parts of your patch, but the
> final approval should come from developers who are responsible for the
> MI stuff:
Thank you very much Eli.
>Andrew Cagney and Elena Zannoni (according to the MAINTAINERS file).
Andrew or Elena, could you please approve this?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-05-24 2:02 ` -file-list-exec-source-files Bob Rossi
@ 2004-05-28 12:52 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-05-28 12:52 UTC (permalink / raw)
To: Eli Zaretskii, ezannoni, gdb-patches, Andrew Cagney, gdb-discuss
On Sun, May 23, 2004 at 09:35:42PM -0400, Bob Rossi wrote:
> On Sun, May 23, 2004 at 01:46:09PM +0200, Eli Zaretskii wrote:
> > > Date: Fri, 21 May 2004 21:52:50 -0400
> > > From: Bob Rossi <bob@brasko.net>
> > >
> > > OK, I just finished ripping down the ceiling and walls in my kitchen.
> > > Is there any chance my patch got reviewed in that time? There's an
> > > outstanding bet between my wife and I that I will be able to completely
> > > renovate my kitchen before this patch gets reviewed.
> > >
> > > What does that say about the GDB patch review process?!?
> > >
> > > Can I *even* get a response from someone capable of committing this
> > > patch?
> > >
> > > Someone with authority, pleeeaaassseeeee help me.
> >
> > I've reviewed your patch 2 weeks ago and approved the patch to
> > gdb.texinfo. I also okayed the other parts of your patch, but the
> > final approval should come from developers who are responsible for the
> > MI stuff:
>
> Thank you very much Eli.
>
> >Andrew Cagney and Elena Zannoni (according to the MAINTAINERS file).
>
> Andrew or Elena, could you please approve this?
Andrew or Elena, It's been over 3 months since I got a reasonable
response from either of you regarding this patch.
I get the feeling you are ignoring me, am I correct?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-05-22 1:53 ` -file-list-exec-source-files Bob Rossi
2004-05-23 10:40 ` -file-list-exec-source-files Eli Zaretskii
2004-05-23 10:51 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-06-01 16:07 ` Elena Zannoni
2004-06-01 18:01 ` -file-list-exec-source-files Bob Rossi
2 siblings, 1 reply; 69+ messages in thread
From: Elena Zannoni @ 2004-06-01 16:07 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > +
Forgot this bit.
otherwise ok
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-01 16:07 ` -file-list-exec-source-files Elena Zannoni
@ 2004-06-01 18:01 ` Bob Rossi
2004-06-01 18:56 ` -file-list-exec-source-files Jason Molenda
2004-06-02 19:22 ` -file-list-exec-source-files Elena Zannoni
0 siblings, 2 replies; 69+ messages in thread
From: Bob Rossi @ 2004-06-01 18:01 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
On Tue, Jun 01, 2004 at 12:00:39PM -0400, Elena Zannoni wrote:
>
> > > > + pst->dirname = xstrdup ( comp_unit_die.dirname );
> > > > +
>
> Forgot this bit.
Is this the bit you are talking about?
The dwarf2 specs say that the name is in the form ":pathname" or
"hostname:pathname". Should we worry about the hostname? Does gcc emit
that? I have looked at a few executables and didn't see the hostname
part.
Would you like me to try to take into account the
hostname:dirname? Is the hostname allowed to have a ':' in it?
> otherwise ok
Great! Thanks Elena.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-01 18:01 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-01 18:56 ` Jason Molenda
2004-06-01 21:22 ` -file-list-exec-source-files Bob Rossi
2004-06-02 19:22 ` -file-list-exec-source-files Elena Zannoni
1 sibling, 1 reply; 69+ messages in thread
From: Jason Molenda @ 2004-06-01 18:56 UTC (permalink / raw)
To: Bob Rossi; +Cc: Elena Zannoni, gdb-patches
On Jun 1, 2004, at 11:01 AM, Bob Rossi wrote:
> On Tue, Jun 01, 2004 at 12:00:39PM -0400, Elena Zannoni wrote:
>>
>>>>> + pst->dirname = xstrdup ( comp_unit_die.dirname );
>>>>> +
>>
>> Forgot this bit.
>
> Is this the bit you are talking about?
I'd wager Elena was talking about the spaces inside the parentheses.
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
After arguing that this was a stupid standard on gdb-patches :-) I made
some snarky comment about it on the dwarf2 mailing list and was
informed that there do exist compilers that emit hostname:pathname.
I'd have to dig up the e-mails to find it, but I think the SGI compiler
was an example of one.
I'm not arguing that your patch needs to handle this; this hasn't been
properly handled in gdb until now so it's not a regression.
Jason
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-01 18:56 ` -file-list-exec-source-files Jason Molenda
@ 2004-06-01 21:22 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-06-01 21:22 UTC (permalink / raw)
To: Jason Molenda; +Cc: Elena Zannoni, gdb-patches
On Tue, Jun 01, 2004 at 11:55:50AM -0700, Jason Molenda wrote:
>
> On Jun 1, 2004, at 11:01 AM, Bob Rossi wrote:
>
> >On Tue, Jun 01, 2004 at 12:00:39PM -0400, Elena Zannoni wrote:
> >>
> >>>>>+ pst->dirname = xstrdup ( comp_unit_die.dirname );
> >>>>>+
> >>
> >>Forgot this bit.
> >
> >Is this the bit you are talking about?
>
> I'd wager Elena was talking about the spaces inside the parentheses.
>
>
> >The dwarf2 specs say that the name is in the form ":pathname" or
> >"hostname:pathname". Should we worry about the hostname? Does gcc emit
> >that? I have looked at a few executables and didn't see the hostname
> >part.
>
> After arguing that this was a stupid standard on gdb-patches :-) I made
> some snarky comment about it on the dwarf2 mailing list and was
> informed that there do exist compilers that emit hostname:pathname.
> I'd have to dig up the e-mails to find it, but I think the SGI compiler
> was an example of one.
>
> I'm not arguing that your patch needs to handle this; this hasn't been
> properly handled in gdb until now so it's not a regression.
Ok, Elena, I am going to commit this with the whitespace changes.
Please let me know if this wasn't your intention.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-01 18:01 ` -file-list-exec-source-files Bob Rossi
2004-06-01 18:56 ` -file-list-exec-source-files Jason Molenda
@ 2004-06-02 19:22 ` Elena Zannoni
2004-06-03 2:35 ` -file-list-exec-source-files Bob Rossi
1 sibling, 1 reply; 69+ messages in thread
From: Elena Zannoni @ 2004-06-02 19:22 UTC (permalink / raw)
To: Bob Rossi; +Cc: Elena Zannoni, gdb-patches
Bob Rossi writes:
>
> The dwarf2 specs say that the name is in the form ":pathname" or
> "hostname:pathname". Should we worry about the hostname? Does gcc emit
> that? I have looked at a few executables and didn't see the hostname
> part.
>
> Would you like me to try to take into account the
> hostname:dirname? Is the hostname allowed to have a ':' in it?
>
Oh, no. Just the formatting.
elena
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-02 19:22 ` -file-list-exec-source-files Elena Zannoni
@ 2004-06-03 2:35 ` Bob Rossi
2004-06-09 18:18 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-03 2:35 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
On Wed, Jun 02, 2004 at 03:13:24PM -0400, Elena Zannoni wrote:
> Bob Rossi writes:
> >
> > The dwarf2 specs say that the name is in the form ":pathname" or
> > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > that? I have looked at a few executables and didn't see the hostname
> > part.
> >
> > Would you like me to try to take into account the
> > hostname:dirname? Is the hostname allowed to have a ':' in it?
> >
>
> Oh, no. Just the formatting.
Ok, I'll commit it as soon as I get the chance.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-03 2:35 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-09 18:18 ` Bob Rossi
2004-06-09 18:42 ` -file-list-exec-source-files Daniel Jacobowitz
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-09 18:18 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Wed, Jun 02, 2004 at 10:35:22PM -0400, Bob Rossi wrote:
> On Wed, Jun 02, 2004 at 03:13:24PM -0400, Elena Zannoni wrote:
> > Bob Rossi writes:
> > >
> > > The dwarf2 specs say that the name is in the form ":pathname" or
> > > "hostname:pathname". Should we worry about the hostname? Does gcc emit
> > > that? I have looked at a few executables and didn't see the hostname
> > > part.
> > >
> > > Would you like me to try to take into account the
> > > hostname:dirname? Is the hostname allowed to have a ':' in it?
> > >
> >
> > Oh, no. Just the formatting.
>
> Ok, I'll commit it as soon as I get the chance.
Ok, I had to make one small change to dwarf2read.c, it was
pst->dirname = xstrdup (comp_unit_die.dirname);
it now is
if (comp_unit_die.dirname)
pst->dirname = xstrdup (comp_unit_die.dirname);
This fixed a crash in the testsuite.
Also, I changed both mi-file.exp and mi2-file.exp from
global srcfile
global srcdir
global subdir
set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
"111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=...
to
"111\\\^done,line=\"23\",file=\".*/${srcfile}\",fullname=...
This had nothing to do with this patch. The testcase was failing with a
clean checkout and run of the testsuite.
Is this OK to commit? If so, I will do it today.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-09 18:18 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-09 18:42 ` Daniel Jacobowitz
2004-06-09 19:17 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Daniel Jacobowitz @ 2004-06-09 18:42 UTC (permalink / raw)
To: gdb-patches
On Wed, Jun 09, 2004 at 02:18:11PM -0400, Bob Rossi wrote:
> Ok, I had to make one small change to dwarf2read.c, it was
> pst->dirname = xstrdup (comp_unit_die.dirname);
> it now is
> if (comp_unit_die.dirname)
> pst->dirname = xstrdup (comp_unit_die.dirname);
>
> This fixed a crash in the testsuite.
This sounds OK.
> Also, I changed both mi-file.exp and mi2-file.exp from
> global srcfile
> global srcdir
> global subdir
> set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
>
> "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=...
>
> to
> "111\\\^done,line=\"23\",file=\".*/${srcfile}\",fullname=...
>
> This had nothing to do with this patch. The testcase was failing with a
> clean checkout and run of the testsuite.
This is not. The reason it's failing for you is probably that you
configured in the source directory or using a relative path, right? Is
it still needed if you configure using an absolute path
(mkdir objdir; cd objdir; /path/to/configure && make && make check) ?
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-09 18:42 ` -file-list-exec-source-files Daniel Jacobowitz
@ 2004-06-09 19:17 ` Bob Rossi
2004-06-09 19:57 ` -file-list-exec-source-files Daniel Jacobowitz
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-09 19:17 UTC (permalink / raw)
To: gdb-patches
On Wed, Jun 09, 2004 at 02:42:12PM -0400, Daniel Jacobowitz wrote:
> On Wed, Jun 09, 2004 at 02:18:11PM -0400, Bob Rossi wrote:
> > Ok, I had to make one small change to dwarf2read.c, it was
> > pst->dirname = xstrdup (comp_unit_die.dirname);
> > it now is
> > if (comp_unit_die.dirname)
> > pst->dirname = xstrdup (comp_unit_die.dirname);
> >
> > This fixed a crash in the testsuite.
>
> This sounds OK.
OK.
> > Also, I changed both mi-file.exp and mi2-file.exp from
> > global srcfile
> > global srcdir
> > global subdir
> > set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
> >
> > "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=...
> >
> > to
> > "111\\\^done,line=\"23\",file=\".*/${srcfile}\",fullname=...
> >
> > This had nothing to do with this patch. The testcase was failing with a
> > clean checkout and run of the testsuite.
>
> This is not. The reason it's failing for you is probably that you
> configured in the source directory or using a relative path, right? Is
> it still needed if you configure using an absolute path
> (mkdir objdir; cd objdir; /path/to/configure && make && make check) ?
You seem to be correct here. I will not make this change.
So otherwise, I'm good to go?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-09 19:17 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-09 19:57 ` Daniel Jacobowitz
2004-06-10 20:04 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Daniel Jacobowitz @ 2004-06-09 19:57 UTC (permalink / raw)
To: gdb-patches
On Wed, Jun 09, 2004 at 03:17:47PM -0400, Bob Rossi wrote:
> On Wed, Jun 09, 2004 at 02:42:12PM -0400, Daniel Jacobowitz wrote:
> > On Wed, Jun 09, 2004 at 02:18:11PM -0400, Bob Rossi wrote:
> > > Ok, I had to make one small change to dwarf2read.c, it was
> > > pst->dirname = xstrdup (comp_unit_die.dirname);
> > > it now is
> > > if (comp_unit_die.dirname)
> > > pst->dirname = xstrdup (comp_unit_die.dirname);
> > >
> > > This fixed a crash in the testsuite.
> >
> > This sounds OK.
>
> OK.
>
> > > Also, I changed both mi-file.exp and mi2-file.exp from
> > > global srcfile
> > > global srcdir
> > > global subdir
> > > set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
> > >
> > > "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=...
> > >
> > > to
> > > "111\\\^done,line=\"23\",file=\".*/${srcfile}\",fullname=...
> > >
> > > This had nothing to do with this patch. The testcase was failing with a
> > > clean checkout and run of the testsuite.
> >
> > This is not. The reason it's failing for you is probably that you
> > configured in the source directory or using a relative path, right? Is
> > it still needed if you configure using an absolute path
> > (mkdir objdir; cd objdir; /path/to/configure && make && make check) ?
>
> You seem to be correct here. I will not make this change.
> So otherwise, I'm good to go?
I think so.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-09 19:57 ` -file-list-exec-source-files Daniel Jacobowitz
@ 2004-06-10 20:04 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-06-10 20:04 UTC (permalink / raw)
To: gdb-patches
On Wed, Jun 09, 2004 at 03:57:39PM -0400, Daniel Jacobowitz wrote:
> On Wed, Jun 09, 2004 at 03:17:47PM -0400, Bob Rossi wrote:
> > On Wed, Jun 09, 2004 at 02:42:12PM -0400, Daniel Jacobowitz wrote:
> > > On Wed, Jun 09, 2004 at 02:18:11PM -0400, Bob Rossi wrote:
> > > > Ok, I had to make one small change to dwarf2read.c, it was
> > > > pst->dirname = xstrdup (comp_unit_die.dirname);
> > > > it now is
> > > > if (comp_unit_die.dirname)
> > > > pst->dirname = xstrdup (comp_unit_die.dirname);
> > > >
> > > > This fixed a crash in the testsuite.
> > >
> > > This sounds OK.
> >
> > OK.
> >
> > > > Also, I changed both mi-file.exp and mi2-file.exp from
> > > > global srcfile
> > > > global srcdir
> > > > global subdir
> > > > set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
> > > >
> > > > "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=...
> > > >
> > > > to
> > > > "111\\\^done,line=\"23\",file=\".*/${srcfile}\",fullname=...
> > > >
> > > > This had nothing to do with this patch. The testcase was failing with a
> > > > clean checkout and run of the testsuite.
> > >
> > > This is not. The reason it's failing for you is probably that you
> > > configured in the source directory or using a relative path, right? Is
> > > it still needed if you configure using an absolute path
> > > (mkdir objdir; cd objdir; /path/to/configure && make && make check) ?
> >
> > You seem to be correct here. I will not make this change.
> > So otherwise, I'm good to go?
>
> I think so.
Committed, thanks.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-04-27 0:05 ` -file-list-exec-source-files Bob Rossi
2004-05-06 22:13 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-27 18:12 ` Andreas Schwab
2004-06-27 19:07 ` -file-list-exec-source-files Bob Rossi
` (2 more replies)
1 sibling, 3 replies; 69+ messages in thread
From: Andreas Schwab @ 2004-06-27 18:12 UTC (permalink / raw)
To: Elena Zannoni; +Cc: Eli Zaretskii, gdb-patches
Bob Rossi <bob@brasko.net> writes:
> +/* Finds the fullname that a 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 symtab represents,
> + NULL will be returned and ps->fullname will be set to NULL. */
This causes gdb to crash in lookup_symtab.
if (full_path != NULL)
{
const char *fp = symtab_to_fullname (s);
if (FILENAME_CMP (full_path, fp) == 0)
{
return s;
}
}
if (real_path != NULL)
{
char *rp = gdb_realpath (symtab_to_fullname (s));
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
return s;
}
}
Neither of these places expect symtab_to_fullname to return NULL.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
@ 2004-06-27 19:07 ` Bob Rossi
2004-06-27 20:33 ` -file-list-exec-source-files Andreas Schwab
2004-06-28 19:48 ` -file-list-exec-source-files Bob Rossi
2004-06-28 20:40 ` -file-list-exec-source-files Bob Rossi
2 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-27 19:07 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Elena Zannoni, Eli Zaretskii, gdb-patches
On Sun, Jun 27, 2004 at 08:06:13PM +0200, Andreas Schwab wrote:
> Bob Rossi <bob@brasko.net> writes:
>
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
>
> This causes gdb to crash in lookup_symtab.
>
> if (full_path != NULL)
> {
> const char *fp = symtab_to_fullname (s);
> if (FILENAME_CMP (full_path, fp) == 0)
> {
> return s;
> }
> }
>
> if (real_path != NULL)
> {
> char *rp = gdb_realpath (symtab_to_fullname (s));
> make_cleanup (xfree, rp);
> if (FILENAME_CMP (real_path, rp) == 0)
> {
> return s;
> }
> }
>
> Neither of these places expect symtab_to_fullname to return NULL.
Is that repeatable with a small example?
I'd be happy to take a look at it.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-27 19:07 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-27 20:33 ` Andreas Schwab
0 siblings, 0 replies; 69+ messages in thread
From: Andreas Schwab @ 2004-06-27 20:33 UTC (permalink / raw)
To: Elena Zannoni; +Cc: Eli Zaretskii, gdb-patches
Bob Rossi <bob@brasko.net> writes:
> Is that repeatable with a small example?
I get loads of testsuite errors on ia64-linux. For example, it crashes
after gdb_run_cmd in gdb.base/dbx.exp:test_assign.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
2004-06-27 19:07 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-28 19:48 ` Bob Rossi
2004-06-28 20:40 ` -file-list-exec-source-files Bob Rossi
2 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-06-28 19:48 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Elena Zannoni, Eli Zaretskii, gdb-patches
On Sun, Jun 27, 2004 at 08:06:13PM +0200, Andreas Schwab wrote:
> Bob Rossi <bob@brasko.net> writes:
>
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
>
> This causes gdb to crash in lookup_symtab.
>
> if (full_path != NULL)
> {
> const char *fp = symtab_to_fullname (s);
> if (FILENAME_CMP (full_path, fp) == 0)
> {
> return s;
> }
> }
>
> if (real_path != NULL)
> {
> char *rp = gdb_realpath (symtab_to_fullname (s));
> make_cleanup (xfree, rp);
> if (FILENAME_CMP (real_path, rp) == 0)
> {
> return s;
> }
> }
>
> Neither of these places expect symtab_to_fullname to return NULL.
I will have a simple patch for this within the next few hours.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
2004-06-27 19:07 ` -file-list-exec-source-files Bob Rossi
2004-06-28 19:48 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-28 20:40 ` Bob Rossi
2004-06-29 4:05 ` -file-list-exec-source-files Eli Zaretskii
2 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-28 20:40 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Elena Zannoni, Eli Zaretskii, gdb-patches
On Sun, Jun 27, 2004 at 08:06:13PM +0200, Andreas Schwab wrote:
> Bob Rossi <bob@brasko.net> writes:
>
> > +/* Finds the fullname that a 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 symtab represents,
> > + NULL will be returned and ps->fullname will be set to NULL. */
>
> This causes gdb to crash in lookup_symtab.
>
> if (full_path != NULL)
> {
> const char *fp = symtab_to_fullname (s);
> if (FILENAME_CMP (full_path, fp) == 0)
> {
> return s;
> }
> }
>
> if (real_path != NULL)
> {
> char *rp = gdb_realpath (symtab_to_fullname (s));
> make_cleanup (xfree, rp);
> if (FILENAME_CMP (real_path, rp) == 0)
> {
> return s;
> }
> }
The patch below checks symtab_to_fullname's return value against NULL.
Even though this is the "trivial" fix, I believe it is the correct
patch. When I added these calls recently, I blindly changed the old call
to symtab_to_fullname, and the old call did not return NULL.
Permission to apply?
2004-06-28 Bob Rossi <bob@brasko.net>
* symtab.c (lookup_symtab): check return value of symtab_to_fullname
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.133
diff -w -u -r1.133 symtab.c
--- symtab.c 18 Jun 2004 21:36:15 -0000 1.133
+++ symtab.c 28 Jun 2004 20:36:18 -0000
@@ -182,7 +182,7 @@
if (full_path != NULL)
{
const char *fp = symtab_to_fullname (s);
- if (FILENAME_CMP (full_path, fp) == 0)
+ if (fp != NULL && FILENAME_CMP (full_path, fp) == 0)
{
return s;
}
@@ -190,7 +190,10 @@
if (real_path != NULL)
{
- char *rp = gdb_realpath (symtab_to_fullname (s));
+ char *fullname = symtab_to_fullname (s);
+ if (fullname != NULL)
+ {
+ char *rp = gdb_realpath (fullname);
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
@@ -198,6 +201,7 @@
}
}
}
+ }
/* Now, search for a matching tail (only if name doesn't have any dirs) */
^ permalink raw reply [flat|nested] 69+ messages in thread* Re: -file-list-exec-source-files
2004-06-28 20:40 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-29 4:05 ` Eli Zaretskii
2004-06-29 18:34 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-06-29 4:05 UTC (permalink / raw)
To: Bob Rossi; +Cc: schwab, ezannoni, gdb-patches
> Date: Mon, 28 Jun 2004 16:40:31 -0400
> From: Bob Rossi <bob@brasko.net>
>
> The patch below checks symtab_to_fullname's return value against NULL.
> Even though this is the "trivial" fix, I believe it is the correct
> patch. When I added these calls recently, I blindly changed the old call
> to symtab_to_fullname, and the old call did not return NULL.
>
> Permission to apply?
This patch is okay with me.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 4:05 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-06-29 18:34 ` Bob Rossi
2004-06-29 18:52 ` -file-list-exec-source-files Eli Zaretskii
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-29 18:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: schwab, ezannoni, gdb-patches
On Tue, Jun 29, 2004 at 07:00:34AM +0200, Eli Zaretskii wrote:
> > Date: Mon, 28 Jun 2004 16:40:31 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > The patch below checks symtab_to_fullname's return value against NULL.
> > Even though this is the "trivial" fix, I believe it is the correct
> > patch. When I added these calls recently, I blindly changed the old call
> > to symtab_to_fullname, and the old call did not return NULL.
> >
> > Permission to apply?
>
> This patch is okay with me.
Am I OK to commit?
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 18:34 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-29 18:52 ` Eli Zaretskii
2004-06-29 20:10 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-06-29 18:52 UTC (permalink / raw)
To: Bob Rossi; +Cc: schwab, ezannoni, gdb-patches
> Date: Tue, 29 Jun 2004 14:34:11 -0400
> From: Bob Rossi <bob@brasko.net>
> > >
> > > Permission to apply?
> >
> > This patch is okay with me.
>
> Am I OK to commit?
That's what I said, didn't I? ;-)
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 18:52 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-06-29 20:10 ` Bob Rossi
2004-06-29 20:27 ` -file-list-exec-source-files Eli Zaretskii
0 siblings, 1 reply; 69+ messages in thread
From: Bob Rossi @ 2004-06-29 20:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: schwab, ezannoni, gdb-patches
On Tue, Jun 29, 2004 at 09:44:44PM +0200, Eli Zaretskii wrote:
> > Date: Tue, 29 Jun 2004 14:34:11 -0400
> > From: Bob Rossi <bob@brasko.net>
> > > >
> > > > Permission to apply?
> > >
> > > This patch is okay with me.
> >
> > Am I OK to commit?
>
> That's what I said, didn't I? ;-)
Well, "this patch is okay with me" and "permission to commit" could mean
two different things, especially since I've been told that only Elena or
Jim have permission to approve this.
Honestly, I have no idea how things work here, as far as patch approval
is concerned, and I never want to commit a patch without the appropriate
permissions.
But I'm assuming you are saying it's OK to commit.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 20:10 ` -file-list-exec-source-files Bob Rossi
@ 2004-06-29 20:27 ` Eli Zaretskii
2004-06-29 20:29 ` -file-list-exec-source-files Bob Rossi
0 siblings, 1 reply; 69+ messages in thread
From: Eli Zaretskii @ 2004-06-29 20:27 UTC (permalink / raw)
To: Bob Rossi; +Cc: schwab, ezannoni, gdb-patches
> Date: Tue, 29 Jun 2004 16:08:51 -0400
> From: Bob Rossi <bob@brasko.net>
>
> Well, "this patch is okay with me" and "permission to commit" could mean
> two different things
Sorry, I thought it was clear what I meant.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: -file-list-exec-source-files
2004-06-29 20:27 ` -file-list-exec-source-files Eli Zaretskii
@ 2004-06-29 20:29 ` Bob Rossi
0 siblings, 0 replies; 69+ messages in thread
From: Bob Rossi @ 2004-06-29 20:29 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: schwab, ezannoni, gdb-patches
On Tue, Jun 29, 2004 at 11:22:16PM +0200, Eli Zaretskii wrote:
> > Date: Tue, 29 Jun 2004 16:08:51 -0400
> > From: Bob Rossi <bob@brasko.net>
> >
> > Well, "this patch is okay with me" and "permission to commit" could mean
> > two different things
>
> Sorry, I thought it was clear what I meant.
Thanks Eli, I will commit this tonight.
Bob Rossi
^ permalink raw reply [flat|nested] 69+ messages in thread
end of thread, other threads:[~2004-07-08 11:19 UTC | newest]
Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27 19:14 -file-list-exec-source-files Michael Elizabeth Chastain
-- strict thread matches above, loose matches on Subject: below --
2004-06-29 22:37 -file-list-exec-source-files Michael Elizabeth Chastain
2004-06-30 3:32 ` -file-list-exec-source-files Eli Zaretskii
2004-07-06 21:02 ` -file-list-exec-source-files Bob Rossi
2004-07-08 11:19 ` -file-list-exec-source-files Bob Rossi
2004-06-29 4:57 -file-list-exec-source-files Michael Elizabeth Chastain
2004-03-25 3:54 -file-list-exec-source-files Bob Rossi
2004-02-26 2:06 -file-list-exec-source-files Bob Rossi
2004-02-26 23:54 ` -file-list-exec-source-files Andrew Cagney
2004-02-27 13:23 ` -file-list-exec-source-files Bob Rossi
2004-02-29 3:20 ` -file-list-exec-source-files Bob Rossi
2004-03-02 0:33 ` -file-list-exec-source-files Bob Rossi
2004-03-02 5:43 ` -file-list-exec-source-files Eli Zaretskii
2004-03-02 15:21 ` -file-list-exec-source-files Andrew Cagney
2004-03-02 15:28 ` -file-list-exec-source-files Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-02 16:32 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Andrew Cagney
2004-03-19 0:09 ` -file-list-exec-source-files Eli Zaretskii
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-02-25 4:01 -file-list-exec-source-files Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Elena Zannoni
2004-03-05 22:36 ` -file-list-exec-source-files Elena Zannoni
2004-03-19 0:09 ` -file-list-exec-source-files Jason Molenda
2004-03-05 23:02 ` -file-list-exec-source-files Jason Molenda
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-06 15:57 ` -file-list-exec-source-files Bob Rossi
2004-03-11 13:25 ` -file-list-exec-source-files Bob Rossi
2004-03-19 0:09 ` -file-list-exec-source-files Bob Rossi
2004-03-29 20:55 ` -file-list-exec-source-files Bob Rossi
2004-04-05 21:40 ` -file-list-exec-source-files Bob Rossi
2004-04-12 15:06 ` -file-list-exec-source-files Bob Rossi
2004-04-21 1:10 ` -file-list-exec-source-files Bob Rossi
2004-04-21 4:52 ` -file-list-exec-source-files Eli Zaretskii
2004-04-21 12:20 ` -file-list-exec-source-files Bob Rossi
2004-04-21 18:41 ` -file-list-exec-source-files Eli Zaretskii
2004-04-22 15:43 ` -file-list-exec-source-files Elena Zannoni
2004-04-27 0:05 ` -file-list-exec-source-files Bob Rossi
2004-05-06 22:13 ` -file-list-exec-source-files Bob Rossi
2004-05-07 15:24 ` -file-list-exec-source-files Eli Zaretskii
[not found] ` <9743-Sat08May2004132930+0300-eliz@gnu.org>
2004-05-17 13:11 ` -file-list-exec-source-files Bob Rossi
2004-05-22 1:53 ` -file-list-exec-source-files Bob Rossi
2004-05-23 10:40 ` -file-list-exec-source-files Eli Zaretskii
2004-05-23 10:51 ` -file-list-exec-source-files Eli Zaretskii
2004-05-24 2:02 ` -file-list-exec-source-files Bob Rossi
2004-05-28 12:52 ` -file-list-exec-source-files Bob Rossi
2004-06-01 16:07 ` -file-list-exec-source-files Elena Zannoni
2004-06-01 18:01 ` -file-list-exec-source-files Bob Rossi
2004-06-01 18:56 ` -file-list-exec-source-files Jason Molenda
2004-06-01 21:22 ` -file-list-exec-source-files Bob Rossi
2004-06-02 19:22 ` -file-list-exec-source-files Elena Zannoni
2004-06-03 2:35 ` -file-list-exec-source-files Bob Rossi
2004-06-09 18:18 ` -file-list-exec-source-files Bob Rossi
2004-06-09 18:42 ` -file-list-exec-source-files Daniel Jacobowitz
2004-06-09 19:17 ` -file-list-exec-source-files Bob Rossi
2004-06-09 19:57 ` -file-list-exec-source-files Daniel Jacobowitz
2004-06-10 20:04 ` -file-list-exec-source-files Bob Rossi
2004-06-27 18:12 ` -file-list-exec-source-files Andreas Schwab
2004-06-27 19:07 ` -file-list-exec-source-files Bob Rossi
2004-06-27 20:33 ` -file-list-exec-source-files Andreas Schwab
2004-06-28 19:48 ` -file-list-exec-source-files Bob Rossi
2004-06-28 20:40 ` -file-list-exec-source-files Bob Rossi
2004-06-29 4:05 ` -file-list-exec-source-files Eli Zaretskii
2004-06-29 18:34 ` -file-list-exec-source-files Bob Rossi
2004-06-29 18:52 ` -file-list-exec-source-files Eli Zaretskii
2004-06-29 20:10 ` -file-list-exec-source-files Bob Rossi
2004-06-29 20:27 ` -file-list-exec-source-files Eli Zaretskii
2004-06-29 20:29 ` -file-list-exec-source-files Bob Rossi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox