* Finding absolute path from relative.
@ 2003-09-29 2:25 Bob Rossi
2003-09-29 2:31 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Bob Rossi @ 2003-09-29 2:25 UTC (permalink / raw)
To: gdb
Hi,
I am thinking about the algorithm required to find the absolute path to
a source file given the relative path and the output from 'show dir'.
Is it really as easy as this,
for I in 'show dir' # for each directory in show dir
if $I/relative_path exists
break; # Found absolute path.
Or does it get more complex and obfuscated?
Bob Rossi
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Finding absolute path from relative. 2003-09-29 2:25 Finding absolute path from relative Bob Rossi @ 2003-09-29 2:31 ` Daniel Jacobowitz 2003-09-29 2:33 ` Bob Rossi 0 siblings, 1 reply; 6+ messages in thread From: Daniel Jacobowitz @ 2003-09-29 2:31 UTC (permalink / raw) To: gdb On Sun, Sep 28, 2003 at 10:21:28PM -0400, Bob Rossi wrote: > Hi, > > I am thinking about the algorithm required to find the absolute path to > a source file given the relative path and the output from 'show dir'. > > Is it really as easy as this, > > for I in 'show dir' # for each directory in show dir > if $I/relative_path exists > break; # Found absolute path. > > Or does it get more complex and obfuscated? Well, often the input file has a specified directory. That gets tried first. Anyway, there's a good comment or two about this in the source code... -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding absolute path from relative. 2003-09-29 2:31 ` Daniel Jacobowitz @ 2003-09-29 2:33 ` Bob Rossi 2003-09-29 2:44 ` Daniel Jacobowitz 0 siblings, 1 reply; 6+ messages in thread From: Bob Rossi @ 2003-09-29 2:33 UTC (permalink / raw) To: gdb On Sun, Sep 28, 2003 at 10:25:38PM -0400, Daniel Jacobowitz wrote: > On Sun, Sep 28, 2003 at 10:21:28PM -0400, Bob Rossi wrote: > > Hi, > > > > I am thinking about the algorithm required to find the absolute path to > > a source file given the relative path and the output from 'show dir'. > > > > Is it really as easy as this, > > > > for I in 'show dir' # for each directory in show dir > > if $I/relative_path exists > > break; # Found absolute path. > > > > Or does it get more complex and obfuscated? > > Well, often the input file has a specified directory. That gets tried > first. > > Anyway, there's a good comment or two about this in the source code... Could you get me started in the right direction? ( ex. files of interest ) Either, I could write an MI command that would take a relative source path and convert it into an absolute path, or I could write a function in my front end that does the work. I personally think an MI command could eventually be more helpful to everyone. Bob Rossi ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding absolute path from relative. 2003-09-29 2:33 ` Bob Rossi @ 2003-09-29 2:44 ` Daniel Jacobowitz 2003-09-29 4:58 ` Bob Rossi 0 siblings, 1 reply; 6+ messages in thread From: Daniel Jacobowitz @ 2003-09-29 2:44 UTC (permalink / raw) To: gdb On Sun, Sep 28, 2003 at 10:31:11PM -0400, Bob Rossi wrote: > On Sun, Sep 28, 2003 at 10:25:38PM -0400, Daniel Jacobowitz wrote: > > On Sun, Sep 28, 2003 at 10:21:28PM -0400, Bob Rossi wrote: > > > Hi, > > > > > > I am thinking about the algorithm required to find the absolute path to > > > a source file given the relative path and the output from 'show dir'. > > > > > > Is it really as easy as this, > > > > > > for I in 'show dir' # for each directory in show dir > > > if $I/relative_path exists > > > break; # Found absolute path. > > > > > > Or does it get more complex and obfuscated? > > > > Well, often the input file has a specified directory. That gets tried > > first. > > > > Anyway, there's a good comment or two about this in the source code... > > Could you get me started in the right direction? ( ex. files of interest ) > > Either, I could write an MI command that would take a relative source > path and convert it into an absolute path, or I could write a function > in my front end that does the work. > > I personally think an MI command could eventually be more helpful to > everyone. source.c:openp. Then, open_source_file. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding absolute path from relative. 2003-09-29 2:44 ` Daniel Jacobowitz @ 2003-09-29 4:58 ` Bob Rossi 2003-09-29 5:18 ` Eli Zaretskii 0 siblings, 1 reply; 6+ messages in thread From: Bob Rossi @ 2003-09-29 4:58 UTC (permalink / raw) To: gdb On Sun, Sep 28, 2003 at 10:33:46PM -0400, Daniel Jacobowitz wrote: > On Sun, Sep 28, 2003 at 10:31:11PM -0400, Bob Rossi wrote: > > On Sun, Sep 28, 2003 at 10:25:38PM -0400, Daniel Jacobowitz wrote: > > > On Sun, Sep 28, 2003 at 10:21:28PM -0400, Bob Rossi wrote: > > > > Hi, > > > > > > > > I am thinking about the algorithm required to find the absolute path to > > > > a source file given the relative path and the output from 'show dir'. > > > > > > > > Is it really as easy as this, > > > > > > > > for I in 'show dir' # for each directory in show dir > > > > if $I/relative_path exists > > > > break; # Found absolute path. > > > > > > > > Or does it get more complex and obfuscated? > > > > > > Well, often the input file has a specified directory. That gets tried > > > first. > > > > > > Anyway, there's a good comment or two about this in the source code... > > > > Could you get me started in the right direction? ( ex. files of interest ) > > > > Either, I could write an MI command that would take a relative source > > path and convert it into an absolute path, or I could write a function > > in my front end that does the work. > > > > I personally think an MI command could eventually be more helpful to > > everyone. > > source.c:openp. Then, open_source_file. Thanks! Another quick question. I have been told that some of the debug formats support absolute paths and some do not. Does this just mean that some of the debug formats will give you the absolute path, and with the others, this expensive lookup is necessary? I guess the question is, in both cases, can GDB find the absolute path to a source file, given only the relative path? Bob Rossi ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding absolute path from relative. 2003-09-29 4:58 ` Bob Rossi @ 2003-09-29 5:18 ` Eli Zaretskii 0 siblings, 0 replies; 6+ messages in thread From: Eli Zaretskii @ 2003-09-29 5:18 UTC (permalink / raw) To: Bob Rossi; +Cc: gdb > Date: Sun, 28 Sep 2003 22:44:37 -0400 > From: Bob Rossi <bob@brasko.net> > > Another quick question. I have been told that some of the debug formats > support absolute paths and some do not. True. COFF is one example of debug info format that stores only the file name, without the leading directories. However, even with more advanced debug formats, such as DWARF2, the file name stored in the debug info might exclude the leading directories, depending on how the source file was specified to the compiler during compilation. E.g., try gcc -c foo.c vs gcc -c /full/path/to/foo.c and then use objdump to look at the file name recorded in foo.o's debug info. > Does this just mean that some > of the debug formats will give you the absolute path, and with the > others, this expensive lookup is necessary? > > I guess the question is, in both cases, can GDB find the absolute path > to a source file, given only the relative path? I'm not sure this problem is solvable at all, in all cases. If the leading directories are not recorded in the debug info, the assumption that the file is somewhere along the list of known source directories might not always hold, as GDB has no way of setting the list of those directories automatically. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-09-29 4:58 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-09-29 2:25 Finding absolute path from relative Bob Rossi 2003-09-29 2:31 ` Daniel Jacobowitz 2003-09-29 2:33 ` Bob Rossi 2003-09-29 2:44 ` Daniel Jacobowitz 2003-09-29 4:58 ` Bob Rossi 2003-09-29 5:18 ` Eli Zaretskii
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox