Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Craig Jeffree <craig.jeffree@preston.net>
To: Bob Rossi <bob@brasko.net>
Cc: Daniel Jacobowitz <drow@false.org>, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Relative source file search
Date: Thu, 06 Oct 2005 02:49:00 -0000	[thread overview]
Message-ID: <1128566917.18954.39.camel@norman> (raw)
In-Reply-To: <20051006021548.GA5232@white>

On Wed, 2005-10-05 at 22:15 -0400, Bob Rossi wrote:
> I've been thinking about this a little. Here's the documentation for
> explaining how the 'dir' command works.
> 
>   Plain file names, relative file names with leading directories, file names 
>   containing dots, etc. are all treated as described above; for instance, 
>   if the source path is `/mnt/cross', and the source file is recorded as 
>      `../lib/foo.c', GDB would first try `../lib/foo.c', then 
>      `/mnt/cross/../lib/foo.c', and after that---`/mnt/cross/foo.c'. 
> 

I think my change works in support of this, but there is some
complication that I don't understand.  In one example that I've got
dirname is relative and filename is just the filename.  However in
another example dirname is empty and filename is a relative path like
the ../lib/foo.c example from the docs.  This later case works fine all
the time (haven't looked at the final test of /mnt/cross/foo.c though),
however the first case fails.  My change converts this first case into
the second case.  What I don't understand is why does the symtab
sometimes have the path and filename separate and other times have them
already concatenated?

> This documentation describes the steps taken in order to find a file. It
> doesn't describe using the symtabs dirname field. As I look at the code
> in source.c:find_and_open_source I find that if dirname is not NULL,
> then source_path get's set to "dirname:$cwd", and if the user used the
> 'dir' command to add directory's you end up with
> "/home/dir1:/home/dir2:dirname:$cwd".
> 
> So, if your dirname is relative, like "../include", and your filename is
> "foo.h", then moving your executable should not be a problem. I think
> the problem is where you start GDB from. I find that if I start GDB
> from where the executable original was, then it finds the file no
> problem. If you start GDB from somewhere else, then the relative path
> makes no sense to GDB.
> 
> Can you try starting GDB from the correct location and see if this fixes
> your problem?

Yes this does work, but its quite restrictive.  We're now letting GDB
dictate what your current working directory is allowed to be.  Our
application's behaviour depends on the cwd and so I can't always run it
from where GDB would feel more comfortable.  I believe the dir command
exists for this very reason, so I can explain to GDB where it will find
the source.

Cheers,
Craig.



  reply	other threads:[~2005-10-06  2:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-27  7:42 Craig Jeffree
2005-10-04  1:24 ` [PATCH] " Craig Jeffree
2005-10-04  1:35   ` Daniel Jacobowitz
2005-10-06  0:57     ` Craig Jeffree
2005-10-06  2:16       ` Bob Rossi
2005-10-06  2:49         ` Craig Jeffree [this message]
2005-10-06 13:00           ` Bob Rossi
2005-10-06 23:33             ` Craig Jeffree
2005-10-07  0:25               ` Bob Rossi
2005-10-10  4:57                 ` Craig Jeffree
2005-10-10 10:46                   ` Bob Rossi
2005-10-10 16:46                   ` Bob Rossi
2005-10-10 16:47                   ` Daniel Jacobowitz
2005-10-10 23:15                     ` Craig Jeffree

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1128566917.18954.39.camel@norman \
    --to=craig.jeffree@preston.net \
    --cc=bob@brasko.net \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox