diff --git a/etc/config/c++.amazon.win32.properties b/etc/config/c++.amazon.win32.properties index a8727f1e..d2e76bfa 100644 --- a/etc/config/c++.amazon.win32.properties +++ b/etc/config/c++.amazon.win32.properties @@ -6,8 +6,6 @@ compiler.cl19.versionFlag=/? compiler.cl19_32.name=x86 msvc 19 (32 bit) compiler.cl19_32.exe=etc\scripts\cl19_x86.bat compiler.cl19_32.versionFlag=/? -# Kludge; we use this filename in asm.js to detect when we're processing user-input code -compileFilename=GccExplorer.cpp postProcess= binaryHideFuncRe=^(_.*|(de)?register_tm_clones|call_gmon_start|frame_dummy)$ needsMulti=false diff --git a/lib/asm.js b/lib/asm.js index 2b683773..23821652 100644 --- a/lib/asm.js +++ b/lib/asm.js @@ -216,6 +216,30 @@ } }); + function compareWindowsFilename(lhs, rhs) { + function tildeCompare(lhs, rhs) { + var lhsTilde = lhs.indexOf("~"); + var rhsTilde = rhs.indexOf("~"); + if (lhsTilde >= 0) { + lhs = lhs.substr(0, lhsTilde); + rhs = rhs.substr(0, lhsTilde); + } + if (rhsTilde >= 0) { + lhs = lhs.substr(0, rhsTilde); + rhs = rhs.substr(0, rhsTilde); + } + return lhs === rhs; + } + + lhs = lhs.toLowerCase().split('\\'); + rhs = rhs.toLowerCase().split('\\'); + if (lhs.length != rhs.length) return false; + for (var i = 0; i < lhs.length; ++i) { + if (!tildeCompare(lhs[i], rhs[i])) return false; + } + return true; + } + var directive = /^\s*(\.|([_A-Z]+\b))/; var labelDefinition = /^([a-zA-Z0-9$_.]+):/; var commentOnly = /^\s*([#@;]|\/\/).*/; @@ -223,8 +247,10 @@ var fileFind = /^; File\s+(.*)$/; var inMain = false; var sourceTag = /^;\s*([0-9]+)\s*:/; - var ignoreAll = /^include listing\.inc$/; + var ignoreAll = /^\s*include listing\.inc$/; var source = null; + var titleFind = /^\s*TITLE\s*(.*)/; + var title = null; var result = []; function demangle(line) { @@ -304,9 +330,11 @@ } line = demangle(line); + if (title === null && !!(match = line.match(titleFind))) { + title = match[1]; + } if (!!(match = line.match(fileFind))) { - // NB relies on magic name from properties; TODO fix this (or at least share the name instead of repeating it here) - inMain = !!match[1].match(/\\GccExplorer.cpp$/); + inMain = compareWindowsFilename(match[1], title); return; } if (!!(match = line.match(sourceTag))) { diff --git a/test/cases/cl-regex.asm b/test/cases/cl-regex.asm index 1837a05a..e4be424b 100644 --- a/test/cases/cl-regex.asm +++ b/test/cases/cl-regex.asm @@ -1,12 +1,14 @@ ; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23918.0 -include listing.inc + TITLE C:\Users\ADMINI~1\AppData\Local\Temp\2\gcc-explorer-compiler116510-3076-1fwzpub.e7utsm7vi\example.cpp + .686P + .XMM + include listing.inc + .model flat -INCLUDELIB LIBCMT -INCLUDELIB OLDNAMES ; Function compile flags: /Odtp -; File c:\users\administrator\desktop\GccExplorer.cpp +; File c:\users\administrator\appdata\local\temp\2\gcc-explorer-compiler116510-3076-1fwzpub.e7utsm7vi\example.cpp _TEXT SEGMENT self_regex$ = 32 s$ = 72