Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Debug source lookup question

Thanks Volodya. Dropping "getSourcePaths" is a long story - it's part of
CDI. There are non-GDB implementations based on CDI. Who knows, maybe
one of them is using this interface for their own purposes.

Mikhail
-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Vladimir Prus
Sent: Wednesday, November 19, 2008 6:09 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] Debug source lookup question

On Wednesday 19 November 2008 17:52:46 Mikhail Khodjaiants wrote:

Hi Mikhail,

> As far as I remember this functionality was added in attempt to 
> "synchronize" the external (CDT) source lookup with GDB. I haven't 
> been aware it has such an effect. What's the purpose of this command
then?

The answer is somewhat long. Most often, binaries compiled with gcc and
typical build systems have two bits of information for every source
file:

	- the name of the file (without directory)
	- the compilation directory

The GDB search path is a list of directories, and may include special
'$cdir' element. When GDB wants to find the fullname of a file, it
checks for it each directory in the search path. If $cdir is found, it
checks in the compilation directory from the debug info.

The default search path includes $cdir already, so if you don't do any
explicit 'dir' commands only compilation directory and current directory
are searched.

The problem is that paths passed via 'dir' or '-environment-directory'
are added in front of the search path. So, it overrides the compilation
directory. And if you have file name a.c in two different directories,
and you add both those directories via -environment-directory, you're
out of luck. Note that adding $cdir in the front will not work, in
general, for example if the binary is run on a different system from
where it was compiled.  I think this is the fundamental limitation of a
system where N source directories are specified and searched in order.
The best approach is
	- Not used 'dir' at all when application is built and debugged
	on the same system
	- Use GDB path substitution mechanisms otherwise, documented at
	http://sourceware.org/gdb/current/onlinedocs/gdb_9.html#SEC63
	This is only available in recent versions of GDB.

I'm also not quite sure how this all meshes with the CDT model.
Probably, search path should not include any directories by default.
Then users would add it if all the standard mechanisms in GDB fail.

> Regarding getSourcePaths: it was added to get the source lookup 
> information from GDB and populate the CDT source lookup. But the idea 
> has never materialized. I am not aware of any future plans for it.

Should this maybe be dropped from source code? The only possible use
case for this is detecting when user typed 'dir' in GDB console, which
does not seem like a very important use case.

Thanks,
Volodya
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.




Back to the top