[llvm-dev] DIFile filenames containing directories

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev
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
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> 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
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev
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 <[hidden email]> wrote:


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> 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

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev
Thanks for the feedback! Closely-related follow-up question: Is *this* a bug?

llvm/tools/clang/test/CodeGen/debug-prefix-map.c:33:27:
// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty")

-- adrian
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev
Can't say I know much about -fdebug-prefix-map, but...

On Thu, Nov 29, 2018 at 1:07 PM Adrian Prantl <[hidden email]> wrote:
Thanks for the feedback! Closely-related follow-up question: Is *this* a bug?

llvm/tools/clang/test/CodeGen/debug-prefix-map.c:33:27:
// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty")

Yeah, that doesn't look quite right to me. The duplication of the directory in both the filename and directory... 

Well, I guess it could be read as "resolve the filename relative to this directory" - but since the filename is absolute, the directory is ignored?
 

-- adrian

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev


On Nov 29, 2018, at 1:19 PM, David Blaikie <[hidden email]> wrote:

Can't say I know much about -fdebug-prefix-map, but...

On Thu, Nov 29, 2018 at 1:07 PM Adrian Prantl <[hidden email]> wrote:
Thanks for the feedback! Closely-related follow-up question: Is *this* a bug?

llvm/tools/clang/test/CodeGen/debug-prefix-map.c:33:27:
// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty")

Yeah, that doesn't look quite right to me. The duplication of the directory in both the filename and directory... 

Well, I guess it could be read as "resolve the filename relative to this directory" - but since the filename is absolute, the directory is ignored?
 

Apparently LLVM is smart enough to not emit this as "/var/empty/var/empty/...", but I don't understand why we wouldn't strip the directory prefix in CGDebugInfo::getOrCreateFile() to save space, or at least not emit a redundant directory.

I'll send out a patch to strip a common prefix. It should save a little bit of memory and go better with my sense of aesthetics :-)

Let me know if someone has an idea why this would be useful to keep.

-- adrian

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev

Try compiling –S before you say LLVM is that smart… like I said, the .debug-line header comes out differently.

In which case this would be a real bug and not just aesthetic.

--paulr

 

From: [hidden email] [mailto:[hidden email]]
Sent: Thursday, November 29, 2018 4:21 PM
To: David Blaikie
Cc: Robinson, Paul; llvm-dev; Davide Italiano
Subject: Re: DIFile filenames containing directories

 

 



On Nov 29, 2018, at 1:19 PM, David Blaikie <[hidden email]> wrote:

 

Can't say I know much about -fdebug-prefix-map, but...

On Thu, Nov 29, 2018 at 1:07 PM Adrian Prantl <[hidden email]> wrote:

Thanks for the feedback! Closely-related follow-up question: Is *this* a bug?

llvm/tools/clang/test/CodeGen/debug-prefix-map.c:33:27:
// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty")

 

Yeah, that doesn't look quite right to me. The duplication of the directory in both the filename and directory... 

Well, I guess it could be read as "resolve the filename relative to this directory" - but since the filename is absolute, the directory is ignored?

 

 

Apparently LLVM is smart enough to not emit this as "/var/empty/var/empty/...", but I don't understand why we wouldn't strip the directory prefix in CGDebugInfo::getOrCreateFile() to save space, or at least not emit a redundant directory.

 

I'll send out a patch to strip a common prefix. It should save a little bit of memory and go better with my sense of aesthetics :-)

 

Let me know if someone has an idea why this would be useful to keep.

 

-- adrian


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] DIFile filenames containing directories

Alberto Barbaro via llvm-dev

> On Nov 29, 2018, at 1:24 PM, [hidden email] wrote:
>
> Try compiling –S before you say LLVM is that smart… like I said, the .debug-line header comes out differently.
> In which case this would be a real bug and not just aesthetic.

  .file 1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

Looks like we're kicking the can down the road to the assembler here.

I'm planning to fix it anyway.

-- adrian
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev