[lldb-dev] filenames in a cross-platform environment

Duane Ellis via lldb-dev lldb-dev at lists.llvm.org
Thu Aug 27 21:48:10 PDT 2015


> On Aug 27, 2015, at 4:17 PM, via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hi all,
> 
> The question of how to tackle filename/path issues in a cross-platform
> environment arose as a result of http://reviews.llvm.org/D12115, and we would
> like to continue that discussion here.  I'll start with excerpts from comments
> in that review to give you some background:
> 
[snip]
> 
> Thoughts/ideas?

I solved this quite a few years ago inside of “GDB-TK/Insight” - my situation was:

	Some libraries are built on: Linux + SunOS + Cygwin + MSDOS + MAC (prior to Unix-fication, colons in the path)
	Libraries and Apps could be built on any of those. Hence we had many different combiations.

Today - you are talking about LLDB - which potentially has python under the hood.
In my case GDB-TK/Insight - it was Tcl/Tk built in.

My solution worked like this:

When GDB failed to find the filename by “the normal means” - I made GDBTK call a TCL/TK function

If that function did not exist - the code just gave up - too bad you do not get to find the file.
This was the default action if you (the user) did not provide a lookup function.

If that function existed - in my case, we wrote one or two functions for each project
And, when you launched GDB we just did a “source project_paths.tcl” in the .gdbinit script

The beauty is this: 
	You will never get all of these features and corner cases resolved.
	The solution is very adaptable, and the user can do what is required.
	The user can - if they desire - write a fix-up function

The default implementation would be this simple - it does nothing.

def  my_find_my_file( filename ):
	# Default implementation .. just return the filename
	return filename

You could, get really fancy - 
	You could go lookup the file name via a GIT-WEB service and pull it locally.
	Thus you do not need 100% of the source code present it comes in on demand.
	But that is a *USER* solution - all you are doing is calling a function they can write.

Example:

def my_find_my_file(filename):
	if filename.startswith( ‘/proj/libfoo/rev1.0’  ):
		return git_web_lookup( foo_server,  filename );
	else:
		return filename

NOTE: Please … I beg you: 
	Do not pass the base-name, pass the entire path from the debug record.
	Why? Because often you find duplicate filenames the full path is better!

Even better:
	Pass the symbol name, the address, and line number the function.
	And - the DW_LNF_MD5 (md5 sum of the source file?)
	And … the list goes on and on

In the LLDB case, that function could be written by the user in Python
or perhaps example python template can be provided with some simple instructions.

-Duane.






More information about the lldb-dev mailing list