From 30faf1e756f23491264df96070cf1aed4f4c31a4 Mon Sep 17 00:00:00 2001 From: arakov Date: Tue, 9 Jul 2024 10:47:06 +0200 Subject: [PATCH] [ADDED] #658 : new project LDBG - ELENA Debugger Adapter --- doc/api/system-runtime.html | 18 +++ doc/todo.txt | 30 ++--- elenasrc3/elenasrc3.sln | 10 ++ elenasrc3/ldbg/dpaconst.h | 1 + elenasrc3/ldbg/vs/Resource.rc | 60 +++++++++ elenasrc3/ldbg/vs/ldbg.vcxproj | 183 ++++++++++++++++++++++++++++ elenasrc3/ldbg/vs/resource.h | 29 +++++ elenasrc3/ldbg/windows/ldbg.cpp | 3 + src60/core/system.core_routines.esm | 10 ++ src60/forms/win32_controls.l | 18 ++- src60/forms/win_forms.l | 4 +- src60/system/runtime/vectortable.l | 104 ++++++++++++++-- src60/system/system.prj | 2 +- src60/system/winforms/win_windows.l | 3 +- 14 files changed, 443 insertions(+), 32 deletions(-) create mode 100644 elenasrc3/ldbg/dpaconst.h create mode 100644 elenasrc3/ldbg/vs/Resource.rc create mode 100644 elenasrc3/ldbg/vs/ldbg.vcxproj create mode 100644 elenasrc3/ldbg/vs/resource.h create mode 100644 elenasrc3/ldbg/windows/ldbg.cpp diff --git a/doc/api/system-runtime.html b/doc/api/system-runtime.html index bc5f935d3..a017fda75 100644 --- a/doc/api/system-runtime.html +++ b/doc/api/system-runtime.html @@ -366,12 +366,30 @@

Method Summary

+BoolValue + +rearrange() + + + + + + UnsafePointer allocate(Object obj) + + + + + +release(Object obj) + + + diff --git a/doc/todo.txt b/doc/todo.txt index ce9385824..8dc003a86 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -5,38 +5,34 @@ In development: [development] ### EPIC: elena 6.3 ### - === Iteration 27 (10.06.2024) === + === Iteration 27 (10.07.2024) === + -------------------------------------- + - #658 : create debug adapter + + -------------------------------------- + + === Iteration 28 === -------------------------------------- dev: - upndown - web server - weather forecast - a field must be assigned, warn if not + - threads : clean the perm table after the thread is stopped / freed gen: + - elt : nested executing managed code : keep frames (the frames must be included / excluded correctly) - elt : fails after executing several times, exception handler works only once - nested call must not stop / start vm, - - maint: - - #667 - elena : nested classes should not be loadable at runtime + - #667 - constructor - single dispatcher + - #658 port: - - #658 : create debug adapter - x86-64 : vm terminal, ide vm console - - + - + - prom: posting weekly -------------------------------------- - - elt : nested executing managed code : keep frames (the frames must be included / excluded correctly) - -------------------------------------- - - system'winforms : free PermVectorTable item after the window is closed, to save the resources - - === Iteration 28 === - -------------------------------------- - dev: - gen: - maint: - port: - prom: - -------------------------------------- -------------------------------------- === Iteration 29 === diff --git a/elenasrc3/elenasrc3.sln b/elenasrc3/elenasrc3.sln index 3832e939c..8914e77f0 100644 --- a/elenasrc3/elenasrc3.sln +++ b/elenasrc3/elenasrc3.sln @@ -34,6 +34,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "elt", "tools\elt\vs\elt.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "elena-tests", "elena-tests\elena-tests.vcxproj", "{89A68A7E-1CB6-45CB-9B02-8183FF59284A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldbg", "ldbg\vs\ldbg.vcxproj", "{60FE12CF-0DA9-4266-9C0F-F544DB115020}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -138,6 +140,14 @@ Global {89A68A7E-1CB6-45CB-9B02-8183FF59284A}.Release|x64.Build.0 = Release|x64 {89A68A7E-1CB6-45CB-9B02-8183FF59284A}.Release|x86.ActiveCfg = Release|Win32 {89A68A7E-1CB6-45CB-9B02-8183FF59284A}.Release|x86.Build.0 = Release|Win32 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Debug|x64.ActiveCfg = Debug|x64 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Debug|x64.Build.0 = Debug|x64 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Debug|x86.ActiveCfg = Debug|Win32 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Debug|x86.Build.0 = Debug|Win32 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Release|x64.ActiveCfg = Release|x64 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Release|x64.Build.0 = Release|x64 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Release|x86.ActiveCfg = Release|Win32 + {60FE12CF-0DA9-4266-9C0F-F544DB115020}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/elenasrc3/ldbg/dpaconst.h b/elenasrc3/ldbg/dpaconst.h new file mode 100644 index 000000000..eb7fd79e5 --- /dev/null +++ b/elenasrc3/ldbg/dpaconst.h @@ -0,0 +1 @@ +#define LDBG_REVISION_NUMBER 0x0001 diff --git a/elenasrc3/ldbg/vs/Resource.rc b/elenasrc3/ldbg/vs/Resource.rc new file mode 100644 index 000000000..fcf4fce29 --- /dev/null +++ b/elenasrc3/ldbg/vs/Resource.rc @@ -0,0 +1,60 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) +LANGUAGE 7, 1 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION ENGINE_MAJOR_VERSION,ENGINE_MINOR_VERSION,LDBG_REVISION_NUMBER,0 + PRODUCTVERSION ENGINE_MAJOR_VERSION,ENGINE_MINOR_VERSION,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040004b0" + BEGIN + VALUE "CompanyName", "ELENA Programming Language by Alex Rakov" + VALUE "FileDescription", "ELENA debugger adapter" + VALUE "FileVersion", VER_FILE_VERSION_STR "\0" + VALUE "InternalName", "TODO: " + VALUE "LegalCopyright", "Copyright (C) 2024" + VALUE "OriginalFilename", "elc" + VALUE "ProductName", "ELENA Programming Language" + VALUE "ProductVersion", VER_PRODUCT_VERSION_STR "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x400, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// diff --git a/elenasrc3/ldbg/vs/ldbg.vcxproj b/elenasrc3/ldbg/vs/ldbg.vcxproj new file mode 100644 index 000000000..45e4b5e62 --- /dev/null +++ b/elenasrc3/ldbg/vs/ldbg.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {60FE12CF-0DA9-4266-9C0F-F544DB115020} + ConsoleApplication1 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\ + ..\..\temp\ldbg\ + elena-dpa + + + false + ..\..\..\bin\ + ..\..\temp\ldbg\ + elena-dpa + + + true + ..\..\..\bin\ + ..\..\temp\ldbg64\ + elena64-dpa + + + false + ..\..\..\bin\ + ..\..\temp\ldbg64\ + elena64-dpa + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + ..\..\common;..\..\engine;..\windows;..;%(AdditionalIncludeDirectories) + + + Console + true + + + ..;..\..\engine + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + ..\..\common;..\..\engine;..\windows;..;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + ..;..\..\engine + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + ..\..\common;..\..\engine;..\windows;..;%(AdditionalIncludeDirectories) + + + Console + true + + + ..;..\..\engine + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + ..\..\common;..\..\engine;..\windows;..;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + ..;..\..\engine + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/elenasrc3/ldbg/vs/resource.h b/elenasrc3/ldbg/vs/resource.h new file mode 100644 index 000000000..ee3c6bed3 --- /dev/null +++ b/elenasrc3/ldbg/vs/resource.h @@ -0,0 +1,29 @@ +#include "elenaconst.h" +#include "dpaconst.h" + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Resource.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + +#define STRINGIZE2(s) #s +#define STRINGIZE(s) STRINGIZE2(s) + +#define VER_FILE_VERSION_STR STRINGIZE(ENGINE_MAJOR_VERSION) \ + "." STRINGIZE(ENGINE_MINOR_VERSION) \ + "." STRINGIZE(LDBG_REVISION_NUMBER) \ + ".0" + +#define VER_PRODUCT_VERSION_STR STRINGIZE(ENGINE_MAJOR_VERSION) \ + "." STRINGIZE(ENGINE_MINOR_VERSION) \ + ".0.0" diff --git a/elenasrc3/ldbg/windows/ldbg.cpp b/elenasrc3/ldbg/windows/ldbg.cpp new file mode 100644 index 000000000..0eefc1c8c --- /dev/null +++ b/elenasrc3/ldbg/windows/ldbg.cpp @@ -0,0 +1,3 @@ +int main() +{ +} \ No newline at end of file diff --git a/src60/core/system.core_routines.esm b/src60/core/system.core_routines.esm index 8a895b0e1..2e822b48a 100644 --- a/src60/core/system.core_routines.esm +++ b/src60/core/system.core_routines.esm @@ -1644,6 +1644,16 @@ procedure __perm_array_set end +procedure __perm_array_clear + + peek sp:1 + load + set nil + swap sp:0 + xassign + +end + procedure __perm_array_refer (self,index,retVal) xflush sp:0 diff --git a/src60/forms/win32_controls.l b/src60/forms/win32_controls.l index 0ef5915f9..62ba37781 100644 --- a/src60/forms/win32_controls.l +++ b/src60/forms/win32_controls.l @@ -501,7 +501,9 @@ class PaintboxListener : WindowCallback { _owner.destroy(); - super.onWMDestoy(hwnd) + super.onWMDestoy(hwnd); + + PermVectorTable.release(self); } } @@ -765,6 +767,13 @@ class PanelListener : WindowCallback { _owner.resize(control, width, height); } + + onWMDestoy(Handle hwnd) + { + super.onWMDestoy(hwnd); + + PermVectorTable.release(self); + } } public sealed class Panel : BasePanel, interface @@ -819,6 +828,13 @@ class RadioButtonGroupListener : WindowCallback _owner := owner } + onWMDestoy(Handle hwnd) + { + super.onWMDestoy(hwnd); + + PermVectorTable.release(self); + } + onClick(Handle control) { _owner.onClick(control); diff --git a/src60/forms/win_forms.l b/src60/forms/win_forms.l index b02b62e12..32c39766a 100644 --- a/src60/forms/win_forms.l +++ b/src60/forms/win_forms.l @@ -43,7 +43,7 @@ class SDIWindowListener : SDIWindowCallback { super.onWMDestoy(hwnd); - //TODO : free PermVectorTable entry to reuse it + PermVectorTable.release(self); } onSize(Handle control, int width, int height) @@ -142,7 +142,7 @@ class ChildWindowListener : ChildWindowCallback { super.onWMDestoy(hwnd); - //TODO : free PermVectorTable entry to reuse it + PermVectorTable.release(self); } onSize(Handle control, int width, int height) diff --git a/src60/system/runtime/vectortable.l b/src60/system/runtime/vectortable.l index b76a92426..1f2631e43 100644 --- a/src60/system/runtime/vectortable.l +++ b/src60/system/runtime/vectortable.l @@ -16,6 +16,9 @@ class PermVectorArray setAt(int index, object obj) : external(system'core_routines'__perm_array_set); + removeAt(int index) + : external(system'core_routines'__perm_array_clear); + int Length { get() @@ -32,7 +35,8 @@ class PermVectorArray class PermVectorChain { - Reference Used : rprop; + Reference Free : rprop; + Reference Current : rprop; PermVectorArray Array : rprop; @@ -42,30 +46,66 @@ class PermVectorChain get bool isAvailable() { - int length := Array.Length; - int used := *Used; + int free := *Free; - ^ length > used; + ^ free > 0; } pointer allocate(object) { - int index := *Used; + int index := *Current; + while (Array[index] != nil) + index++; Array[index] := object; - Used.append(1); + Current.Value := index + 1; + + Free.reduce(1); Array.refer(index, out pointer ptr); ^ ptr; } + int indexOf(object) + { + int len := Array.Length; + for (int i := 0; i < len; i++) { + if (Array[i] != nil && object == Array[i]) { + ^ i + } + }; + + ^ -1 + } + + remove(int index) + { + Array.removeAt(index); + } + + bool rearrange() + { + int len := Array.Length; + int free := 0; + for (int i := 0; i < len; i++) { + if (Array[i] == nil) + free++; + }; + + Current.Value := 0; + Free.Value := free; + + ^ self.isAvailable; + } + constructor(PermVectorChain next) { - Array := self.createArray(); - Used := 0; - Next := next; + Array := self.createArray(); + Current := 0; + Free := Array.Length; + Next := next; } } @@ -73,6 +113,7 @@ class PermVectorChain public singleton PermVectorTable { + static PermVectorChain _firstChainItem; static PermVectorChain _chainItem; get private bool isAvailable() @@ -87,14 +128,57 @@ public singleton PermVectorTable ^ false; } + bool rearrange() + { + PermVectorChain previous := nil; + PermVectorChain current := _firstChainItem; + while (current != nil) { + if (current.rearrange()) { + _chainItem := current; + + ^ true + }; + + previous := current; + current := current.Next; + }; + + if (previous == nil) { + _firstChainItem := new PermVectorChain(previous); + _chainItem := _firstChainItem; + + ^ true + }; + _chainItem := previous; + + ^ false; + } + pointer allocate(object obj) { if (!self.isAvailable) { - _chainItem := new PermVectorChain(_chainItem); + ifnot (rearrange()) { + _chainItem := new PermVectorChain(_chainItem); + } }; pointer ptr := _chainItem.allocate(obj); ^ ptr; } + + release(object obj) + { + PermVectorChain current := _firstChainItem; + while (current != nil) { + int index := current.indexOf(obj); + if (index >= 0) { + current.remove(index); + + $break; + }; + + current := current.Next; + }; + } } \ No newline at end of file diff --git a/src60/system/system.prj b/src60/system/system.prj index f67eb866e..bc09433ee 100644 --- a/src60/system/system.prj +++ b/src60/system/system.prj @@ -16,7 +16,7 @@ ELENA Standard Library - 6.1.2 + 6.2.0 Aleksey Rakov diff --git a/src60/system/winforms/win_windows.l b/src60/system/winforms/win_windows.l index 7ffa86021..0c4884ae1 100644 --- a/src60/system/winforms/win_windows.l +++ b/src60/system/winforms/win_windows.l @@ -71,8 +71,9 @@ public closed class WindowCallback onWMDestoy(Handle hwnd) { extern { + extern USER32.SetWindowLongW(hwnd, GWL_USERDATA, 0); extern USER32.DefWindowProcW(hwnd, WM_DESTROY, 0, 0); - } + }; } onWMPaint(Handle hwnd)