diff --git a/CHANGES b/CHANGES index e3b87613..7e9060cb 100644 --- a/CHANGES +++ b/CHANGES @@ -1475,10 +1475,10 @@ Version history - fix some crashes in the frontend * exclude \\.\C: from dependencies generated by LDC v1.40+ -2026-04-xx version 1.5.0-rc1 +2026-04-27 version 1.5.0-rc1 * full installer now bundled with DMD 2.112.0 and LDC 1.41.0 * dmdserver: - - updated to dmd 2.112 (current master) + - updated to dmd 2.112 (master @ 2026/01/09) - dmdserver executable selected by installed dmd version (2.110, 2.111, 2.112) * mago-mi executable added * mago native debug engine now also works in VS2022 (mago concord extension for @@ -1488,4 +1488,15 @@ Version history * dbuild: added support for VS 2026 18.1, 18.3 and 18.6 * dbuild: fixed building if source files are compiled with different settings * improved msbuild integration with the "Fast Up To Date Check" of VS - * installer: can now also add mago as an extension for cppvsdbg in VSCode \ No newline at end of file + * installer: can now also add mago as an extension for cppvsdbg in VSCode + +2026-07-26 version 1.5.0-rc2 + * full installer now bundled with LDC 1.42.0 + * dmdserver: + - updated to dmd 2.113 (stable @ 2026/04/28) + - now works slighly more incremental + - fixed a couple of false pointer memory leaks + * mago: + - add "Step Over Foreach" command + * dbuild: generic support for VS 2026 18.1-18.15 + * added command "Step Over Foreach" diff --git a/Makefile b/Makefile index 41bdf59f..b1b814ff 100644 --- a/Makefile +++ b/Makefile @@ -56,29 +56,29 @@ all: install_vs # compile visuald components prerequisites: - devenv /Project "build" /Build "$(CONFIG)|Win32" visuald_vs10.sln + devenv visuald_vs10.sln /Project "build" /Build "$(CONFIG)|Win32" visuald_vs: - devenv /Project "VisualD" /Build "$(CONFIG)|Win32" visuald_vs10.sln + devenv visuald_vs10.sln /Project "VisualD" /Build "$(CONFIG)|Win32" visuald_vs_x64: - devenv /Project "VisualD" /Build "$(CONFIG_X64)|x64" visuald_vs10.sln + devenv visuald_vs10.sln /Project "VisualD" /Build "$(CONFIG_X64)|x64" visuald_vs_arm64: - devenv /Project "VisualD" /Build "$(CONFIG_ARM64)|x64" visuald_vs10.sln + devenv visuald_vs10.sln /Project "VisualD" /Build "$(CONFIG_ARM64)|x64" visuald_test: - devenv /Project "VisualD" /Build "TestDebug|Win32" visuald_vs10.sln + devenv visuald_vs10.sln /Project "VisualD" /Build "TestDebug|Win32" bin\TestDebug\VisualD\VisualD.exe vdserver: - devenv /Project "vdserver" /Build "$(CONFIG)|Win32" visuald_vs10.sln + devenv visuald_vs10.sln /Project "vdserver" /Build "$(CONFIG)|Win32" dmdserver: - devenv /Project "dmdserver" /Build "$(CONFIG_DMDSERVER)|x64" visuald_vs10.sln + devenv visuald_vs10.sln /Project "dmdserver" /Build "$(CONFIG_DMDSERVER)|x64" dmdserver_test: - devenv /Project "dmdserver" /Build "TestDebug|x64" visuald_vs10.sln + devenv visuald_vs10.sln /Project "dmdserver" /Build "TestDebug|x64" bin\TestDebug\x64\dmdserver.exe dparser: @@ -195,21 +195,46 @@ dbuild17_all: dbuild17_0 dbuild17_1 dbuild17_2 dbuild17_3 dbuild17_4 dbuild17_5 dbuild18_0: cd msbuild\dbuild && $(MSBUILD) dbuild.csproj /p:Configuration=Release-v18_0;Platform=AnyCPU $(MSBUILD_REBUILD) -dbuild18_1: - cd msbuild\dbuild && $(MSBUILD) dbuild.csproj /p:Configuration=Release-v18_1;Platform=AnyCPU $(MSBUILD_REBUILD) +ASSEMBLYPATCHER = bin\AssemblyPatcher\Release\net10.0\AssemblyPatcher.exe +DBUILD18_BIN = bin\dbuild\Release-v18_0\obj -dbuild18_3: - cd msbuild\dbuild && $(MSBUILD) dbuild.csproj /p:Configuration=Release-v18_3;Platform=AnyCPU $(MSBUILD_REBUILD) +$(ASSEMBLYPATCHER): + cd msbuild\dbuild\AssemblyPatcher && dotnet build -c Release -dbuild18_6: - cd msbuild\dbuild && $(MSBUILD) dbuild.csproj /p:Configuration=Release-v18_6;Platform=AnyCPU $(MSBUILD_REBUILD) +dbuild18_all: dbuild18_0 $(ASSEMBLYPATCHER) + for %f in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) do \ + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.%f.0.0 $(DBUILD18_BIN)\dbuild.18.%f.dll -dbuild18_all: dbuild18_0 dbuild18_1 dbuild18_3 dbuild18_6 +dbuild18_2: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.2.0.0 $(DBUILD18_BIN)\dbuild.18.2.dll + +dbuild18_3: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.3.0.0 $(DBUILD18_BIN)\dbuild.18.3.dll + +dbuild18_4: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.4.0.0 $(DBUILD18_BIN)\dbuild.18.4.dll + +dbuild18_5: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.5.0.0 $(DBUILD18_BIN)\dbuild.18.5.dll + +dbuild18_6: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.6.0.0 $(DBUILD18_BIN)\dbuild.18.6.dll + +dbuild18_7: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.7.0.0 $(DBUILD18_BIN)\dbuild.18.7.dll + +dbuild18_8: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.8.0.0 $(DBUILD18_BIN)\dbuild.18.8.dll + +dbuild18_9: dbuild18_0 $(ASSEMBLYPATCHER) + $(ASSEMBLYPATCHER) $(DBUILD18_BIN)\dbuild.18.0.dll Microsoft.Build.CPPTasks.Common 18.9.0.0 $(DBUILD18_BIN)\dbuild.18.9.dll + +dbuild18_allx: dbuild18_0 dbuild18_1 dbuild18_2 dbuild18_3 dbuild18_4 dbuild18_5 dbuild18_6 dbuild18_7 dbuild18_8 dbuild18_9 mago: - cd ..\..\mago && devenv /Build "Release|Win32" /Project "MagoNatDE" magodbg_2010.sln - cd ..\..\mago && devenv /Build "Release|x64" /Project "MagoRemote" magodbg_2010.sln - cd ..\..\mago && devenv /Build "Release StaticDE|Win32" /Project "MagoNatCC" magodbg_2010.sln + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|Win32" /Project "MagoNatDE" + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|x64" /Project "MagoRemote" + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release StaticDE|Win32" /Project "MagoNatCC" mago_vs15: cd ..\..\mago && msbuild /p:Configuration=Release;Platform=Win32;PlatformToolset=v141 /target:DebugEngine\MagoNatDE /verbosity:quiet MagoDbg_2010.sln @@ -237,17 +262,17 @@ mago_mi: cd ..\..\mago && msbuild "/p:Configuration=Release StaticDE;Platform=x64;PlatformToolset=v143" /target:MagoMI\mago-mi /verbosity:quiet MagoDbg_2010.sln magogc: - cd ..\..\mago && devenv /Build "Release|Win32" /Project "MagoGC" magodbg_2010.sln - cd ..\..\mago && devenv /Build "Release|x64" /Project "MagoGC" magodbg_2010.sln + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|Win32" /Project "MagoGC" + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|x64" /Project "MagoGC" magogc_ldc: - cd ..\..\mago && devenv /Build "Release|Win32"/Project "MagoGC" /projectconfig "Release LDC|Win32" magodbg_2010.sln - cd ..\..\mago && devenv /Build "Release|x64" /Project "MagoGC" /projectconfig "Release LDC|x64" magodbg_2010.sln + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|Win32"/Project "MagoGC" /projectconfig "Release LDC|Win32" + cd ..\..\mago && devenv magodbg_2010.sln /Build "Release|x64" /Project "MagoGC" /projectconfig "Release LDC|x64" cv2pdb: - cd ..\..\cv2pdb\trunk && devenv /Project "cv2pdb" /Build "Release|Win32" src\cv2pdb_vs12.sln - cd ..\..\cv2pdb\trunk && devenv /Project "dviewhelper" /Build "Release|Win32" src\cv2pdb_vs12.sln - cd ..\..\cv2pdb\trunk && devenv /Project "dumplines" /Build "Release|Win32" src\cv2pdb_vs12.sln + cd ..\..\cv2pdb\trunk && devenv src\cv2pdb_vs12.sln /Project "cv2pdb" /Build "Release|Win32" + cd ..\..\cv2pdb\trunk && devenv src\cv2pdb_vs12.sln /Project "dviewhelper" /Build "Release|Win32" + cd ..\..\cv2pdb\trunk && devenv src\cv2pdb_vs12.sln /Project "dumplines" /Build "Release|Win32" cv2pdb_vs15: cd ..\..\cv2pdb\trunk && msbuild /p:Configuration=Release;Platform=Win32;PlatformToolset=v141 /verbosity:quiet src\cv2pdb.vcxproj diff --git a/VERSION b/VERSION index 80317bf7..c5680d67 100644 --- a/VERSION +++ b/VERSION @@ -2,4 +2,4 @@ #define VERSION_MINOR 5 #define VERSION_REVISION 0 #define VERSION_BETA -rc -#define VERSION_BUILD 1 +#define VERSION_BUILD 2 diff --git a/c2d/idl2d.d b/c2d/idl2d.d index d6fa6f8d..693e32b4 100644 --- a/c2d/idl2d.d +++ b/c2d/idl2d.d @@ -18,6 +18,8 @@ import c2d.tokenizer; import c2d.tokutil; import c2d.dgutil; +import stdext.file; + import std.string; import std.file; import std.path; @@ -2754,7 +2756,7 @@ version(remove_pp) {} else { Source src = new Source; src.filename = file; - src.text = fromMBSz (cast(immutable(char)*)(cast(char[]) read(file) ~ "\0").ptr); + src.text = fromMBSz (cast(immutable(char)*)(cast(char[]) readUtf8(file) ~ "\0").ptr); try { // bad qquoting in VS2019 SDK diff --git a/msbuild/dbuild/AssemblyPatcher/AssemblyPatcher.csproj b/msbuild/dbuild/AssemblyPatcher/AssemblyPatcher.csproj new file mode 100644 index 00000000..48d16e5c --- /dev/null +++ b/msbuild/dbuild/AssemblyPatcher/AssemblyPatcher.csproj @@ -0,0 +1,16 @@ + + + + Exe + net10.0 + enable + enable + ..\..\..\bin\AssemblyPatcher + + + + + + + + diff --git a/msbuild/dbuild/AssemblyPatcher/Program.cs b/msbuild/dbuild/AssemblyPatcher/Program.cs new file mode 100644 index 00000000..77363844 --- /dev/null +++ b/msbuild/dbuild/AssemblyPatcher/Program.cs @@ -0,0 +1,27 @@ +using dnlib.DotNet; +using System; + +if (args.Length != 4) +{ + Console.WriteLine("Usage: AssemblyPatcher "); + return; +} + +var inputPath = args[0]; +var refname = args[1]; +var version = args[2]; +var outputPath = args[3]; + +var module = ModuleDefMD.Load(inputPath); + +foreach (var asmRef in module.GetAssemblyRefs()) +{ + if (asmRef.Name == refname) + { + Console.WriteLine("Patching reference to " + refname + " to " + version + "..."); + asmRef.Version = Version.Parse(version); + } +} + +module.Write(outputPath); + diff --git a/msbuild/dbuild/dbuild.csproj b/msbuild/dbuild/dbuild.csproj index 4b12d931..704cc295 100644 --- a/msbuild/dbuild/dbuild.csproj +++ b/msbuild/dbuild/dbuild.csproj @@ -522,6 +522,28 @@ MinimumRecommendedRules.ruleset 18.6 + + bin\Debug-v18_5\ + TRACE;DEBUG;TOOLS_V17 + true + false + pdbonly + AnyCPU + prompt + MinimumRecommendedRules.ruleset + 18.5 + + + bin\Release-v18_5\ + TRACE;TOOLS_V17 + true + true + pdbonly + AnyCPU + prompt + MinimumRecommendedRules.ruleset + 18.5 + bin\Debug-v18_6\ TRACE;DEBUG;TOOLS_V17 @@ -586,7 +608,8 @@ or '$(TargetVer)' == '17.7' or '$(TargetVer)' == '17.8' or '$(TargetVer)' == '17.9' or '$(TargetVer)' == '17.10' or '$(TargetVer)' == '17.11' or '$(TargetVer)' == '17.12' or '$(TargetVer)' == '17.13' or '$(TargetVer)' == '17.14' or '$(TargetVer)' == '18.0' - or '$(TargetVer)' == '18.1' or '$(TargetVer)' == '18.3' or '$(TargetVer)' == '18.6'">v4.7.2 + or '$(TargetVer)' == '18.1' or '$(TargetVer)' == '18.3' or '$(TargetVer)' == '18.5' + or '$(TargetVer)' == '18.6'">v4.7.2 false false false @@ -989,7 +1012,7 @@ - + assemblies\v18\Microsoft.Build.dll False @@ -1037,6 +1060,12 @@ False + + + assemblies\v18_5\Microsoft.Build.CPPTasks.Common.dll + False + + assemblies\v18_6\Microsoft.Build.CPPTasks.Common.dll diff --git a/nsis/visuald.nsi b/nsis/visuald.nsi index bf9af42b..908b16f1 100644 --- a/nsis/visuald.nsi +++ b/nsis/visuald.nsi @@ -34,7 +34,7 @@ ; define LDC to include ldc installation ; !define LDC -!define LDC_VERSION "1.41.0" +!define LDC_VERSION "1.42.0" !define LDC_SRC c:\d\ldc2-${LDC_VERSION}-windows-multilib ; define VS2019 to include VS2019 support @@ -314,6 +314,7 @@ Section "Visual Studio package" SecPackage ${SetOutPath} "$INSTDIR\dmdserver" ${File} "..\..\binaries\" dmdserver-2.110.exe ${File} "..\..\binaries\" dmdserver-2.111.exe + ${File} "..\..\binaries\" dmdserver-2.112.exe !endif !ifdef DPARSER @@ -388,9 +389,21 @@ Section "Visual Studio package" SecPackage !endif !ifdef VS2026 ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.0.dll - ${File} ..\bin\dbuild\release-v18_1\obj\ dbuild.18.1.dll - ${File} ..\bin\dbuild\release-v18_3\obj\ dbuild.18.3.dll - ${File} ..\bin\dbuild\release-v18_6\obj\ dbuild.18.6.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.1.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.2.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.3.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.4.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.5.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.6.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.7.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.8.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.9.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.10.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.11.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.12.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.13.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.14.dll + ${File} ..\bin\dbuild\release-v18_0\obj\ dbuild.18.15.dll !endif WriteRegStr HKLM "Software\${APPNAME}" "msbuild" $INSTDIR\msbuild !endif diff --git a/sdk/vsi.visualdproj b/sdk/vsi.visualdproj index 503ad581..6d16476b 100644 --- a/sdk/vsi.visualdproj +++ b/sdk/vsi.visualdproj @@ -2758,6 +2758,7 @@ + @@ -2784,7 +2785,6 @@ - @@ -2847,6 +2847,7 @@ + diff --git a/tools/tracegc.d b/tools/tracegc.d index cd744dd3..a622db4e 100644 --- a/tools/tracegc.d +++ b/tools/tracegc.d @@ -296,7 +296,7 @@ class GCTraceProxy : GC gc.collect(); } - static if(__VERSION__ < 2_111) + static if(__VERSION__ < 2_109) void collectNoStack() nothrow { gc.collectNoStack(); @@ -325,28 +325,28 @@ class GCTraceProxy : GC void* malloc(size_t size, uint bits, const TypeInfo ti) nothrow { void* p = gc.malloc(size, bits, ti); - traceAlloc(p); + traceAlloc(p, size, bits); return p; } BlkInfo qalloc(size_t size, uint bits, scope const TypeInfo ti) nothrow { BlkInfo bi = gc.qalloc(size, bits, ti); - traceAlloc(bi.base); + traceAlloc(bi.base, size, bits); return bi; } void* calloc(size_t size, uint bits, const TypeInfo ti) nothrow { void* p = gc.calloc(size, bits, ti); - traceAlloc(p); + traceAlloc(p, size, bits); return p; } void* realloc(void* p, size_t size, uint bits, const TypeInfo ti) nothrow { void* q = gc.realloc(p, size, bits, ti); - traceAlloc(q); + traceAlloc(q, size, bits); return q; } @@ -709,9 +709,13 @@ void removeGCTracer() } +/ -void traceAlloc(void* addr) nothrow +void traceAlloc(void* addr, size_t size, uint bits) nothrow { size_t[15] buf; + static if(__VERSION__ >= 2_111) + if (bits & BlkAttr.APPENDABLE) + if (size > 2046) + addr -= 0x10; auto backtraceLength = RtlCaptureStackBackTrace(2, cast(ULONG)buf.length, cast(void**)buf.ptr, null); @@ -810,7 +814,11 @@ __gshared void** ifacedeclvtbl; __gshared void** enumdeclvtbl; __gshared void** enummembervtbl; __gshared void** tmpldeclvtbl; -__gshared void** tmplinstvtbl; // package +__gshared void** tmplinstvtbl; +__gshared void** rootobjectvtbl; + +import dmd.rootobject; +import dmd.asttypename; shared static this() { @@ -834,6 +842,7 @@ shared static this() enummembervtbl = getVtbl!EnumMember; tmpldeclvtbl = getVtbl!TemplateDeclaration; tmplinstvtbl = getVtbl!TemplateInstance; + rootobjectvtbl = getVtbl!RootObject; } char[] dumpExtra(void* p) @@ -896,7 +905,21 @@ char[] dumpExtra(void* p) return buf[0..len]; } } + else if (isInImage(vtbl)) + { + try + { + if (*vtbl is *rootobjectvtbl) + { + auto ro = cast(RootObject)p; + return cast(char[])astTypeName(ro); + } + } + catch (Throwable) + { + } + } } return null; } @@ -1552,6 +1575,7 @@ void dumpGC(GC _gc) cgc.gcLock.unlock(); findRoot(null); + printBlockInfo(null); } shared static this() @@ -1590,16 +1614,20 @@ const(char)[] dmdident(ConservativeGC cgc, void* p) bool isInImage(void* p) { import core.internal.traits : externDFunc; - static if(__VERSION__ < 2_111) - { - alias findImageSection = externDFunc!("rt.sections_win64.findImageSection", void[] function(string) nothrow @nogc); - void[] dataSection = findImageSection(".data"); - } - else + __gshared void[] dataSection; + if (!dataSection.length) { - alias findImageSection = externDFunc!("rt.sections_win64.findImageSection", void[] function(void*, string) nothrow @nogc); - void* handle = GetModuleHandle(null); // only executables - void[] dataSection = findImageSection(handle, ".data"); + static if(__VERSION__ < 2_111) + { + alias findImageSection = externDFunc!("rt.sections_win64.findImageSection", void[] function(string) nothrow @nogc); + dataSection = findImageSection(".data"); + } + else + { + alias findImageSection = externDFunc!("rt.sections_win64.findImageSection", void[] function(void*, string) nothrow @nogc); + void* handle = GetModuleHandle(null); // only executables + dataSection = findImageSection(handle, ".data"); + } } if (p - dataSection.ptr < dataSection.length) @@ -1629,6 +1657,32 @@ const(char)[] dmdtype(ConservativeGC cgc, void* p) return buf[0..len]; } +void printBlockInfo(void* addr) +{ + if (!addr) + return; + auto cgc = cast(ConservativeGC) tracer.gc; + auto bi = cgc.query(addr); + void* base; + size_t size; + uint attr; + + xtrace_printf("%p: blkinfo .base=%p .size=%zu .attr=%x\n", addr, bi.base, bi.size, bi.attr); + + int age = 0; + foreach_reverse (ref rng; tracer.traceBuffer._p[0..tracer.traceBuffer._length]) + foreach_reverse (ref te; rng._entries[0..rng._length]) + if (te.addr == addr) + { + if (StackAddrInfo* ai = te.resolve()) + { + const(char)* filename = stringBuffer.ptr + ai.filenameOff; + xtrace_printf("%s(%d): %d\n", filename, ai.line, age); + } + age++; + } +} + void** sobj_in_nongc_mem; void findRoot(void* sobj) diff --git a/vdc/dmdserver/dmd b/vdc/dmdserver/dmd index a10efa76..3023f50f 160000 --- a/vdc/dmdserver/dmd +++ b/vdc/dmdserver/dmd @@ -1 +1 @@ -Subproject commit a10efa76fc529997f894b2ad3517682bc4712c3b +Subproject commit 3023f50fcf790357dcd9c631dad59490f5d9eca7 diff --git a/vdc/dmdserver/dmdinit.d b/vdc/dmdserver/dmdinit.d index 6602e736..84921551 100644 --- a/vdc/dmdserver/dmdinit.d +++ b/vdc/dmdserver/dmdinit.d @@ -52,6 +52,17 @@ alias countersType = uint[uint]; // actually uint[Key] alias EscapeInfer = RootObject[int]; enum uint_1 : uint { initValue = 1 } +enum build_for_version = "2.113"; + +string select_by_version(string[] sel...) +{ + string sym; + for (size_t i = 0; i < sel.length; i += 2) + if (sel[i] <= build_for_version) + sym = sel[i + 1]; + return sym; +} +alias sbv = select_by_version; enum string[2][] dmdStatics = [ @@ -70,13 +81,11 @@ enum string[2][] dmdStatics = ["_D3dmd10dsymbolsem14loadCoreAtomicFZ11core_atomicCQBw7dmodule6Module", "Module"], // up to 2.110 -// ["_D3dmd4func15FuncDeclaration8genCfuncRPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifiermZ2stCQFb7dsymbol12DsymbolTable", "DsymbolTable"], - // 2.111 -// ["_D3dmd4func15FuncDeclaration8genCfuncRPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifierEQEw8astenums3STCZ2stCQFr7dsymbol12DsymbolTable", "DsymbolTable"], - // 2.111.1 -// ["_D3dmd4func15FuncDeclaration8genCfuncFPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifierEQEw8astenums3STCZ2stCQFr7dsymbol12DsymbolTable", "DsymbolTable"], - // 2.112.0 - ["_D3dmd7funcsem8genCfuncFPSQy4root5array__T5ArrayTCQBw5mtype9ParameterZQBcCQCuQy4TypeCQDf10identifier10IdentifierEQEh8astenums3STCZ2stCQFc7dsymbol12DsymbolTable", "DsymbolTable"], + [sbv("", "_D3dmd4func15FuncDeclaration8genCfuncRPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifiermZ2stCQFb7dsymbol12DsymbolTable", + "2.111", "_D3dmd4func15FuncDeclaration8genCfuncRPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifierEQEw8astenums3STCZ2stCQFr7dsymbol12DsymbolTable", + "2.111.1", "_D3dmd4func15FuncDeclaration8genCfuncFPSQBm4root5array__T5ArrayTCQCl5mtype9ParameterZQBcCQDjQy4TypeCQDu10identifier10IdentifierEQEw8astenums3STCZ2stCQFr7dsymbol12DsymbolTable", + "2.113", "_D3dmd7funcsem8genCfuncFPSQy4root5array__T5ArrayTCQBw5mtype9ParameterZQBcCQCuQy4TypeCQDf10identifier10IdentifierEQEh8astenums3STCZ2stCQFc7dsymbol12DsymbolTable"), + "DsymbolTable"], // 2.091 // ["_D3dmd7typesem12typeSemanticRCQBc5mtype4TypeSQBr7globals3LocPSQCi6dscope5ScopeZ11visitAArrayMFCQDpQCn10TypeAArrayZ3feqCQEn4func15FuncDeclaration", "FuncDeclaration"], @@ -133,6 +142,8 @@ enum string[2][] dmdStatics = ["_D3dmd10identifier10Identifier9newSuffixFNbZ1ik", "size_t"], // 2.111 // ["_D3dmd10identifier10Identifier17generateIdWithLocFNbAyaSQCc8location3LocQuZ8countersHSQDgQDfQCwQCnFNbQBxQBxQCdZ3Keyk", "countersType"], + // 2.112 + ["_D3dmd10identifier10Identifier17generateIdWithLocFNbAyaSQCc8location3LocxPvZ8countersHSQDhQDgQCxQCoFNbQByQByxQBkZ3Keyk", "countersType"], // 2.106 ["_D3dmd7arrayop7arrayOpFCQw10expression6BinExpPSQBt6dscope5ScopeZQByCQCo9dtemplate19TemplateDeclaration", "TemplateDeclaration"], @@ -143,10 +154,11 @@ enum string[2][] dmdStatics = ["_D3dmd10dsymbolsem18loadCoreStdcConfigFZ16core_stdc_configCQCf7dmodule6Module", "Module"], // EscapeState.reset not accessible in package dmd - // to 2.111 - // ["_D3dmd6escape11EscapeState17scopeInferFailureHiCQBu10rootobject10RootObject", "EscapeInfer" ], - // 2.112 - ["_D3dmd6escape11EscapeState16scopeInferReasonHiCQBt10rootobject10RootObject", "EscapeInfer" ], + [sbv("", "_D3dmd6escape11EscapeState17scopeInferFailureHiCQBu10rootobject10RootObject", + "2.113", "_D3dmd6escape11EscapeState16scopeInferReasonHiCQBt10rootobject10RootObject"), + "EscapeInfer" ], + // 2.113 +// ["_D3dmd6escape11EscapeState16scopeInferReasonHiCQBt10rootobject10RootObject", "EscapeInfer" ], // 2.10x ["_D3dmd7typesem21getComplexLibraryTypeFSQBl8location3LocPSQCd6dscope5ScopeEQCu8astenums2TYZ13complex_floatCQEa5mtype4Type", "Type" ], diff --git a/vdc/dmdserver/dmdrmem.d b/vdc/dmdserver/dmdrmem.d index 76e3054b..ecce0b16 100644 --- a/vdc/dmdserver/dmdrmem.d +++ b/vdc/dmdserver/dmdrmem.d @@ -98,7 +98,7 @@ extern (D) char[] xarraydup(const(char)[] s) nothrow pure if (!s) return null; - auto p = cast(char*)mem.xmalloc(s.length + 1); + auto p = cast(char*)mem.xmalloc_noscan(s.length + 1); char[] a = p[0 .. s.length]; a[] = s[0 .. s.length]; p[s.length] = 0; // preserve 0 terminator semantics diff --git a/vdc/dmdserver/dmdserver.d b/vdc/dmdserver/dmdserver.d index fcb8cae6..7a4b8ef7 100644 --- a/vdc/dmdserver/dmdserver.d +++ b/vdc/dmdserver/dmdserver.d @@ -174,9 +174,6 @@ enum ModuleState struct ModuleData { string filename; - Module parsedModule; - Module analyzedModule; - ModuleState state; string parseErrors; string analyzeErrors; @@ -390,8 +387,6 @@ class DMDServer : ComObject, IVDServer synchronized(gDMDSync) { reinitSemanticModules(); - foreach (i, m; mModules) - m.analyzedModule = null; version(traceGC) { @@ -627,23 +622,26 @@ class DMDServer : ComObject, IVDServer string sexpr = to_string(expr); void _calcExpansions() { - string[] symbols; - try - { - if (auto m = ensureAnalyzed(md)) - symbols = findExpansions(m, line, idx + 1 - cast(int) stok.length, stok); - } - catch(OutOfMemoryError e) - { - version(DebugServer) if(dbgfh) dbglog(" GetSemanticExpansions: out of memory"); - throw e; // terminate - } - catch(Throwable t) + synchronized(gDMDSync) { - version(DebugServer) if(dbgfh) dbglog(" GetSemanticExpansions: exception " ~ t.toString()); + string[] symbols; + try + { + if (auto m = ensureAnalyzed(md)) + symbols = findExpansions(m, line, idx + 1 - cast(int) stok.length, stok); + } + catch(OutOfMemoryError e) + { + version(DebugServer) if(dbgfh) dbglog(" GetSemanticExpansions: out of memory"); + throw e; // terminate + } + catch(Throwable t) + { + version(DebugServer) if(dbgfh) dbglog(" GetSemanticExpansions: exception " ~ t.toString()); + } + mSemanticExpansionsRunning = false; + mLastSymbols = symbols; } - mSemanticExpansionsRunning = false; - mLastSymbols = symbols; } version(DebugServer) if(dbgfh) dbglog(dbghdr("GetSemanticExpansions", fname, line, idx) ~ stok); mLastSymbols = null; @@ -697,11 +695,11 @@ class DMDServer : ComObject, IVDServer synchronized(gErrorSync) { - ModuleData* md = findModule(fname, false); - if (!md || !md.parsedModule) + Module parsedModule = findParsedModule(fname); + if (!parsedModule) return S_FALSE; - string[] outlines = getModuleOutline(md.parsedModule, 4); + string[] outlines = getModuleOutline(parsedModule, 4); string joined = outlines.join("\n"); *outline = allocBSTR(joined); } @@ -713,15 +711,15 @@ class DMDServer : ComObject, IVDServer // array of pairs of DWORD string fname = makeFilenameCanonical(to_string(filename), null); - ModuleData* md; + Module parsedModule; synchronized(gErrorSync) { - md = findModule(fname, false); - if (!md || !md.parsedModule) + parsedModule = findParsedModule(fname); + if (!parsedModule) return S_FALSE; } - Loc[] locData = findBinaryIsInLocations(md.parsedModule); + Loc[] locData = findBinaryIsInLocations(parsedModule); SAFEARRAY *sa = SafeArrayCreateVector(VT_INT, 0, 2 * cast(ULONG) locData.length); if(!sa) @@ -874,7 +872,7 @@ class DMDServer : ComObject, IVDServer { try { - if (auto m = md.analyzedModule) + if (auto m = findAnalyzedModule(md.filename)) { auto res = findIdentifierTypes(m); identiferTypes = findIdentifierTypesResultToString(res); @@ -922,18 +920,18 @@ class DMDServer : ComObject, IVDServer // array of pairs of DWORD string fname = makeFilenameCanonical(to_string(filename), null); - ModuleData* md; + Module analyzedModule; synchronized(gErrorSync) { - md = findModule(fname, false); - if (!md || !md.analyzedModule) + analyzedModule = findAnalyzedModule(fname); + if (!analyzedModule) { version(DebugServer) if(dbgfh) dbglog(dbghdr("GetParameterStorageLocs", fname) ~ " not found"); return S_FALSE; } } - auto stcLoc = findParameterStorageClass(md.analyzedModule); + auto stcLoc = findParameterStorageClass(analyzedModule); SAFEARRAY *sa = SafeArrayCreateVector(VT_INT, 0, 3 * cast(ULONG) stcLoc.length); if(!sa) @@ -991,7 +989,7 @@ class DMDServer : ComObject, IVDServer } // call under gDMDSync lock, do not parse if fname is null - void analyzeModules(ModuleData* modData, string fname, string text) + Module analyzeModules(ModuleData* modData, string fname, string text) { string combinedErrorMessages() { @@ -1010,42 +1008,51 @@ class DMDServer : ComObject, IVDServer return msgs; } + Module parsedModule; if (fname) { tryExec(" parseModule", () { initErrorMessages(fname); - modData.parsedModule = createModuleFromText(fname, text); + parsedModule = createModuleFromText(fname, text); }); modData.parseErrors = combinedErrorMessages(); } + else + parsedModule = findParsedModule(modData.filename); modData.state = ModuleState.Analyzing; + Module analyzedModule; tryExec(" analyzeModule", () { - if (modData.parsedModule) + if (parsedModule) { - initErrorMessages(modData.parsedModule.srcfile.toString().idup); + initErrorMessages(parsedModule.srcfile.toString().idup); // clear all other semantic modules? - modData.analyzedModule = analyzeModule(modData.parsedModule, mOptions); + analyzedModule = analyzeModule(parsedModule, mOptions); } }); modData.analyzeErrors = combinedErrorMessages(); modData.state = ModuleState.Done; + return analyzedModule; } // call under gDMDSync lock Module ensureAnalyzed(ModuleData* modData) { - if (modData.analyzedModule) - return modData.analyzedModule; - if (!modData.parsedModule) + if (auto m = findAnalyzedModule(modData.filename)) + { + import dmd.dsymbol; + if (m.semanticRun < PASS.semantic3done) + runModuleSemantic(m); + return m; + } + if (!findParsedModule(modData.filename)) return null; if (modData.state == ModuleState.Analyzing) return null; - analyzeModules(modData, null, null); - return modData.analyzedModule; + return analyzeModules(modData, null, null); } private: diff --git a/vdc/dmdserver/dmdserver.visualdproj b/vdc/dmdserver/dmdserver.visualdproj index c9ff93da..cf15c8c7 100644 --- a/vdc/dmdserver/dmdserver.visualdproj +++ b/vdc/dmdserver/dmdserver.visualdproj @@ -1227,7 +1227,7 @@ 0 MARS NoBackend GC LanguageServer 0 - 0 + 1 0 0 @@ -2347,7 +2347,7 @@ - + diff --git a/vdc/dmdserver/semanalysis.d b/vdc/dmdserver/semanalysis.d index 09f930fc..12b61687 100644 --- a/vdc/dmdserver/semanalysis.d +++ b/vdc/dmdserver/semanalysis.d @@ -50,7 +50,7 @@ struct ModuleInfo if (semanticModule) return semanticModule; Module m = cloneModule(parsedModule); - m.importedFrom = m; + m.importedFrom = m; // make module a root module semanticModule = m; if (resolve) { @@ -87,7 +87,7 @@ class AnalysisContext { // only called if module not found in Module.amodules L_nextMod: - foreach (mi; modules) + foreach (ref mi; modules) { if (mi.parsedModule.ident != ident) continue L_nextMod; @@ -137,7 +137,15 @@ void reinitSemanticModules() import core.memory; auto stats = GC.stats(); if (stats.usedSize > stats.freeSize) + { GC.collect(); + version(traceGC) + { + bool dump = false; // to be modified in the debugger + if (dump) + dumpGC(); + } + } } alias Mod = void*; @@ -301,6 +309,18 @@ bool invalidateDependents(AnalysisContext ctxt, Module mod) return true; } +void runModuleSemantic(Module m) +{ + Module.rootModule = m; + m.importAll(null); + m.dsymbolSemantic(null); + runDeferredSemantic(); + m.semantic2(null); + runDeferredSemantic2(); + m.semantic3(null); + runDeferredSemantic3(); +} + // Module analyzeModule(Module parsedModule, const ref Options opts) { @@ -400,16 +420,6 @@ Module analyzeModule(Module parsedModule, const ref Options opts) Module.loadModuleHandler = &ctxt.loadModuleHandler; - void semantic(Module m) - { - m.dsymbolSemantic(null); - runDeferredSemantic(); - m.semantic2(null); - runDeferredSemantic2(); - m.semantic3(null); - runDeferredSemantic3(); - } - if (needsReinit) { reinitSemanticModules(); @@ -442,9 +452,7 @@ Module analyzeModule(Module parsedModule, const ref Options opts) } auto mi = ctxt.modules[rootModuleIndex]; - Module.rootModule = mi.semanticModule; - mi.semanticModule.importAll(null); - semantic(mi.semanticModule); + runModuleSemantic(mi.semanticModule); version(none) { @@ -521,6 +529,30 @@ debug } } +ModuleInfo* findModuleInfo(const(char)[] filename) +{ + if (!lastContext) + return null; + int idx = lastContext.findModuleInfo(filename); + if (idx < 0) + return null; + return &lastContext.modules[idx]; +} + +Module findParsedModule(const(char)[] filename) +{ + if (auto mi = findModuleInfo(filename)) + return mi.parsedModule; + return null; +} + +Module findAnalyzedModule(const(char)[] filename) +{ + if (auto mi = findModuleInfo(filename)) + return mi.semanticModule; + return null; +} + //////////////////////////////////////////////////////////////// version (traceGC) import tracegc; @@ -735,6 +767,12 @@ void do_unittests() string source; Module m; + source = q{ + __VERSION__ + }; + string ver = select_by_version("", "2112L", "2.113", "2113L"); + m = checkErrors(source, "2,2,2,3:Error: declaration expected, not `" ~ver ~ "`\n"); + source = q{ int main() { @@ -2025,10 +2063,11 @@ void do_unittests() source.dep(); } }; + string decl_here = select_by_version("", "\n", "2.112", "\asource.d(2): `dep` is declared here\n"); m = checkErrors(source, - "5,3,5,4:Deprecation: function `source.dep` is deprecated\n" ~ - "6,10,6,11:Deprecation: function `source.dep` is deprecated\n" ~ - "6,10,6,11:Deprecation: function `source.dep` is deprecated\n"); + "5,3,5,4:Deprecation: function `source.dep` is deprecated" ~ decl_here ~ + "6,10,6,11:Deprecation: function `source.dep` is deprecated" ~ decl_here ~ + "6,10,6,11:Deprecation: function `source.dep` is deprecated" ~ decl_here); //dumpAST(m); // type references diff --git a/vdc/dmdserver/semvisitor.d b/vdc/dmdserver/semvisitor.d index f7ae5206..31664d49 100644 --- a/vdc/dmdserver/semvisitor.d +++ b/vdc/dmdserver/semvisitor.d @@ -317,10 +317,16 @@ extern(C++) class ASTVisitor : StoppableVisitor if (!stop) d.accept(this); } - else if (auto inc = decl.include(null)) - foreach(d; *inc) - if (!stop) - d.accept(this); + else + { + auto oldErrors = decl.errors; + scope(exit) decl.errors = oldErrors; + decl.errors = false; // ignore errors on members + if (auto inc = decl.include(null)) + foreach(d; *inc) + if (!stop) + d.accept(this); + } } } @@ -2937,6 +2943,19 @@ Module cloneModule(Module mo) cond.condition = new VersionCondition(ver.loc, m, ver.ident); super.visit(cond); } + + override void visit(ScopeDsymbol scopesym) + { + if (scopesym.symtab) + scopesym.symtab = null; + super.visit(scopesym); + } + override void visit(FuncDeclaration fd) + { + if (fd.localsymtab) + fd.localsymtab = null; + super.visit(fd); + } } import dmd.visitor.permissive; diff --git a/visuald/Resources/pkgcmd.vsct b/visuald/Resources/pkgcmd.vsct index d070fc68..7f645073 100644 --- a/visuald/Resources/pkgcmd.vsct +++ b/visuald/Resources/pkgcmd.vsct @@ -46,6 +46,9 @@ + + + @@ -214,16 +217,6 @@ DeleteCoverageFiles - +