<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 20, 2015, at 11:14 AM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class=""><blockquote type="cite" class="">On 2015-Feb-20, at 09:44, Frédéric Riss <<a href="mailto:friss@apple.com" class="">friss@apple.com</a>> wrote:<br class=""><br class="">Speaking of deduplication of filenames. I think we discussed that in the early stages of your work, but I just wanted to make sure I remember correctly: the new debug hierarchy will allow to implement specific uniquing behavior, right? So we will be able to tweak MDFile to unique:<br class=""><br class="">!MDFile(filename: "path/to/file", directory: "/path/to/dir")<br class="">!MDFile(filename: "to/file", directory: "/path/to/dir/path")<br class=""><br class="">into the same object? I did some work in this area and in the current form it’s not really possible to do cleanly (don’t remember the details here, but I know punted it till we get smart uniquing capability).<br class=""></blockquote><br class="">IIRC, there was some talk about how the DWARF spec requires that<br class="">references to a `directory` need to be the CWD of the compiler.<br class=""></div></blockquote><div><br class=""></div><div>If you refer to a conversation we had, I’m pretty sure I was referring to this text in the standard about the directories listed in the line table:</div><div>
                
        
        
                <div class="page" title="Page 128">
                        <div class="layoutArea">
                                <div class="column"><p class=""><span style="font-size: 12.000000pt; font-family: 'TimesNewRomanPSMT'" class="">"Entries in this sequence describe each path that was searched for included source files in this
compilation. (The paths include those directories specified explicitly by the user for the
compiler to search and those the compiler searches without explicit direction.) Each path
entry is either a full path name or is relative to the current directory of the compilation."</span></p>
                                </div>
                        </div>
                </div></div><div>I think that at the time I had interpreted that has “if the user passes -I../include to the compiler, le line table should list ../include as a directory in the line table”. I think my interpretation was too strict though and that we could canonicalize the file/dir names as we’d like.</div><div><br class=""></div><div>The compilation dir will always be there as a special entry. It’s the implicit entry 0 in the directory list, but it’s value is not stored in the line table, it is a normal string that is referenced by the TAG_compile_unit DIE. If it is extracted from an MDFile, we need to make sure this one doesn’t get mangled, but I think this is the only one we really need to preserve.</div><br class=""><blockquote type="cite" class=""><div class="">It's not clear to me *which* references need that, but I guess<br class="">we need to sort out exactly what the requirements are so we know<br class="">which way to canonicalize things.  I wonder if this only matters<br class="">for DW_TAG_compile_unit?  If so, we could canonicalize freely<br class="">everywhere else.  (For example, we could store a `path:` node<br class="">everywhere (dropping the filename/directory distinction, or<br class="">canonicalizing it to basename/dirname, etc.), and add a `cwd:`<br class="">to the compile unit.)<br class=""></div></blockquote><div><br class=""></div><div>As stated above, I think we are free to canonicalize as we wish.</div><br class=""><blockquote type="cite" class=""><div class="">David also pointed out (in a previous thread about this) that<br class="">the frontend (or `DIBuilder`) might be the right location for<br class="">canonicalization.  Certainly, we couldn't canonicalize `..`<br class="">references without access to the filesystem (at least not on<br class="">POSIX platforms), but maybe we don't care about that anyway?</div></blockquote><br class=""></div><div>What I attempted to do in the past was exactly that, canonicalize ‘..’ in the paths (The lldb folks would have loved to be able to consider file identifiers as unique in the line table). </div><div><br class=""></div><div>Fred</div><div><br class=""></div><br class=""></body></html>