Adrian Prantl via llvm-dev
2018-Nov-29 17:02 UTC
[llvm-dev] DIFile filenames containing directories
I noticed that clang produces DIFiles that look like DIFile(filename: "src/test.c", directory: "/path/to/pwd") at first I thought this must be a bug, but this could also be a space-saving optimization to unique the redundant $PWD prefix of all paths. Is this a bug or a feature? -- adrian
> -----Original Message----- > From: aprantl at apple.com [mailto:aprantl at apple.com] > Sent: Thursday, November 29, 2018 12:02 PM > To: llvm-dev > Cc: David Blaikie; Robinson, Paul; Davide Italiano > Subject: DIFile filenames containing directories > > I noticed that clang produces DIFiles that look like > > DIFile(filename: "src/test.c", directory: "/path/to/pwd") > > at first I thought this must be a bug, but this could also be a space- > saving optimization to unique the redundant $PWD prefix of all paths. > > Is this a bug or a feature?Based on extremely quick experiments, I think it's simple-minded and not purposely factoring out common prefixes; directories are just PWD and -Ifoo, and filenames are the rest of the path, whether it comes from the command line or an #include directive. Interestingly, I get different .debug_line sections depending on compiling straight to object versus compiling to assembler and then assembling. When we compile to object, all the directories get moved to the directory table. Assembler doesn't seem to do that. But even in my Mr. Pedantic mode, it's hard to say it's wrong to put directories into the file table. There's no semantic distinction in DWARF, the consumer is expected to paste the strings together. So, I don't think I'd call it a bug. --paulr> > -- adrian
David Blaikie via llvm-dev
2018-Nov-29 19:34 UTC
[llvm-dev] DIFile filenames containing directories
Yeah, I Think this is intentional to provide paths relative to some root - at least Chromium builds use -fdebug-compilation-dir to avoid baking in the random directory on various distributed build machines, but the "filename" is still qualified relative to that directory so that the debugger can lookup the relative paths itself. On Thu, Nov 29, 2018 at 10:02 AM <paul.robinson at sony.com> wrote:> > > > -----Original Message----- > > From: aprantl at apple.com [mailto:aprantl at apple.com] > > Sent: Thursday, November 29, 2018 12:02 PM > > To: llvm-dev > > Cc: David Blaikie; Robinson, Paul; Davide Italiano > > Subject: DIFile filenames containing directories > > > > I noticed that clang produces DIFiles that look like > > > > DIFile(filename: "src/test.c", directory: "/path/to/pwd") > > > > at first I thought this must be a bug, but this could also be a space- > > saving optimization to unique the redundant $PWD prefix of all paths. > > > > Is this a bug or a feature? > > Based on extremely quick experiments, I think it's simple-minded and > not purposely factoring out common prefixes; directories are just PWD > and -Ifoo, and filenames are the rest of the path, whether it comes > from the command line or an #include directive. > > Interestingly, I get different .debug_line sections depending on > compiling straight to object versus compiling to assembler and then > assembling. When we compile to object, all the directories get moved > to the directory table. Assembler doesn't seem to do that. > > But even in my Mr. Pedantic mode, it's hard to say it's wrong to put > directories into the file table. There's no semantic distinction in > DWARF, the consumer is expected to paste the strings together. > > So, I don't think I'd call it a bug. > --paulr > > > > > -- adrian >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181129/ba0a4449/attachment.html>