Correct path seperator in DWARF debug info on Windows

Reid Kleckner rnk at google.com
Tue Apr 8 13:18:58 PDT 2014


IMO there's two things we could do:

1. Always normalize paths to the preferred host path separator.  The paths
are only valid on the host, so the host path separator is the one that
makes sense.
2. Always normalize paths to / because it's portable and escapes nicely.

I don't think this one fix of a single / is going to get us nice,
normalized paths.


On Mon, Mar 17, 2014 at 2:21 AM, Yaron Keren <yaron.keren at gmail.com> wrote:

> DWARF info and the patch are relevant only for mingw32 toolchain, not MS
> toolchain, of course.
>
> gcc (MinGW) toolchain is inconsistent handling path seperators.
> Compile m.c=
>
>   int main() { return 0; }
>
> with
>
>   cd c:\test
>   gcc m.c m.c -g -o m.exe
>
> To get
>
> C:\Users\user\AppData\Local\Temp\ccjRtBrL.o: In function `main':
> *c:\test/m.c*:1: multiple definition of `main'
> C:\Users\user\AppData\Local\Temp\cc60AUBa.o:*c:\test/m.c*:1: first
> defined here
> collect2.exe: error: ld returned 1 exit status
>
> so \ in directory name but / between directory and filename, incosistent.
>
> if you generate assembly
>
>   gcc c:\test\m.c -S -g -o m.s
>
> the assembly file
> .file 1 "c:/test/m.c"
> .ascii "c:\\test\\m.c\0"
>
> gdb is also quirky, unrelated to debug info:
>
>   gcc m.c -o m.exe
>   gdb m.exe
>   Reading symbols from *c:\test\m.exe*...done.
>   (gdb) r
>   Starting program: *c:\test/m.exe*
>
> Back to clang, directories could be normalized to / but not the case now.
> If we make an error:
>
>   int main() { return e; }
>
> and run clang -c -g c:/test/m.c -o m.o -target i686-pc-mingw32 we get
> *c:/test/m.c*:1:21: error: use of undeclared identifier 'e'
> but if we run clang -c -g c:\test\m.c -o m.o -target i686-pc-mingw32 we get
> *c:\test\m.c*:1:21: error: use of undeclared identifier 'e'
>
> so it follows the input.
>
> In DWARF info the path sep. in directories follows input in some fields
> and normalized to host \\ in others but is never normalized to / so
> hardcoding / in MCDWARF does not match this behaviour.
>
> Yaron
>
>
>
>
>
>
>
>
>
> 2014-03-17 9:32 GMT+02:00 NAKAMURA Takumi <geek4civic at gmail.com>:
>
>> Does dwarf affect "Your Windows"? I suppose MS toolchain would be
>> innocent of dwarf.
>> Would mingw emit '\\' as pathsep in dwarf? I'll investigate later.
>> (IIRC, it wouldn't)
>> I assume "preferred_separator" depends on host system. Would you
>> really like to emit '\\' on Windows targeting elf?
>>
>> IMO, pathsep should be always normalized to '/' unless it would be
>> illegal.
>>
>> 2014-03-17 16:18 GMT+09:00 Yaron Keren <yaron.keren at gmail.com>:
>> > The path seperator is hardcoded in MCDwarf.cpp:649 as '/'. This is
>> worng on
>> > Windows.
>> >
>> > A patch to use the correct path seperator is attached. I had to expose
>> the
>> > path seperator from llvm::sys::path.
>> >
>> > Yaron
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140408/f9d02ac2/attachment.html>


More information about the cfe-commits mailing list