Commit graph

41 commits

Author SHA1 Message Date
Ricardo Luís Vaz Silva
807043b995 dynlight optimize attempt 2025-08-07 21:04:26 -03:00
Nikita
45ac7c1d9e
ZScript DAP Debug server (#3009)
* Add STL-standard type traits and functions to TMap to enable for loop iteration

* add third-party range-map library

I have e-mailed the author for clarifcation on the license, will update this when they respond

* vcpkg: Add cppdap and eventpp libraries, update baseline

* DAP implementation

* Add `FileSystem::FileHash()` to get the CRC32 hash

* add `starting_offset` param to `VMDisasm()` for debugger disassembly view

Defaults to `0`, should not change output if it's not set

* Add `VMFrameStack::HasFrames()` to prevent assertions when inspecting in the debugger

* Add `PC` field to VMFrame, ensure that it is updated whenever vm increments/decrements the pc

Does not change alignment, the offsets used in VMFrame still work
We need this for the debugger because we otherwise have no way to get the pc; it was a local in `ExecScriptFunc()`

* `ZCCCompiler::CreateClassTypes()`: ensure SourceLumpName is set for classes derived from non-native classes

* start debug server in d_main, add `vm_debug` cvars and `-debug` CLI arg

* Add documentation for `vm_debug` cvars

* vm_exec: Add debugger hooks for instruction execution events

* c_console: Add debugger hooks for logging events in `PrintString`

* add `.cache/` to gitignore

* vendor cppdap on main @ 6464cd7

Patches:
removed .gitmodules (submodules were thirdparty/json, thirdparty/googletest)
removed thirdparty/googletest, not needed
removed thirdparty/json/docs, thirdparty/json/test, thirdparty/json/benchmarks to prevent massive bloat

* vendor eventpp on master @ 1224dd6

* build: use internal cppdap and eventpp by default

* dap: fix Binary::GetFunctionLineRange()

* fix bug in range_map::find_ranges

* make Binary dap::Source dynamic

* cache source code upon retrieval

* refactor Binary into a class, cleanup PexCache

* fix ending session gracefully

* d_main: Stop debug server in D_Cleanup()

* Fix connecting to debugger when session already started

* cleanup unused stuff in ZScriptDebugger

* always send TerminateEvents on disconnect if initialized

* tweak color display

* Don't cache disassembly lines when scanning scripts

* Cache nodes when getting runtime state

* WIP display locals

* Fix display of static arrays

* Ensure names display in proper order

* dap: Fix struct locals display, add args display

* Support `start` parameter

* Support `filter` parameter

* remove struct unbound native data display

Practically useless for debugging zscript and didn't work properly anyway

* d_main: fix vm_jit and vm_jit not being disabled soon enough

* support breaking on abort exceptions

* dap: refactor game event emitter functions into seperate header

* dap: show native functions on stack

* dap: Remove "Native" from exception handling, simplify exception event emit

* dap: add instruction breakpoints

* dap: fix display of locals not in scope yet

* dap: Make disassembly view display invalid instructions for non-code addresses

* dap: remove dot initializers

* dap: fix local structs in scope

* dap: don't parse the non-used options in the launch/attach requests

* dap: fix local struct view

* dap: Fix displaying objects that aren't their actual types

* dap: Fix action and state handling

* dap: stack display view

* dap: fix object display view

* d_dehacked: set qualified name in addition to the printable name

* dap: fix displaying breakpoint errors when script isn't loaded

* dap: remove debug print

* dap: Display parameter names

* dap: Turn down verbosity of logging

* dap: fix disassembly view

* dap: fix performance problems with arrays

* c_console: emit event only if not PRINT_NODAPEVENT

* dap: improve logging

* dap: update upstream cppdap library to fix deadlocks on no bind

* dap: Fix ending session on client socket closed

* dap: prevent DebugServer.h from pulling in `dap` and `ZScriptDebugger.h`

* dap: fix pause event not being emitted on pause

* dap: remove eventpp emitters, way too slow

* Remove eventpp dependency

* dap: Display correct register names

* dap: Show special inits in registers

* dap: Add stack offset to VMLocalVariable

* dap: fix display of static arrays and local variables on stack vs. registers

* dap: fix displaying function pointers

* dap: tweak color display

* dap: fix scalar display < 4

* dap: add Globals display to debugger

* dap: unify methods to get vmvalue

* dap: rename free method to freeValue to avoid running afoul of macro defs

* fix windows builds

* fix compile on linux

* cleanup

* Fix display of function breakpoints

* dap: Don't send back binary files

* dap: include sbarinfo in script types (no debug support for anything but zscript yet, this is just for returning source info)

* dap: don't show ending session message unless initialized

* fix erroneous commit

* dap: handle evaluate requests

* Fix getting bitfield values

* Add CVars Scope and evaluation

* add running console commands from repl

* dap: disable commands via repl for now

* fix loading functions DECORATE scripts

* Add source information to Dehacked VM functions, add debugging support

* dap: cleanup

* fix resolving archive paths

* don't send source back on native stack frames

* handle `modules` request

* cleanup

* allow evaluating cvars on hover

* fix oob bpinfos

* fix restarting the game blowing out the debug server

* dap: process input events while paused to prevent deadlocks

* fix getting local state

* dap: fix LocalState alignment

* dap: fix DumpStateHelper

* update cppdap protocol version to 1.68.0

* remove cppdap from vcpkg deps

We can't use the upstream version anyway because the maintainers are not merging our patches

* dap: make named variable nodes derive from the same class

* dap: make cvar scope available in native stack frames

* handle local variables with conflicting names

* add I_GetWindowEvent() to win32 to only process window events when debugging is paused

* dap: fix evaluate

* dap: fix display of `out` variables
2025-07-18 00:01:18 -03:00
Boondorl
269689703d Clear references to map data on level change
These shouldn't be left as they'll now point towards potentially invalid memory and also cause errors with serializing. Arrays and maps holding them are cleared. Also unlinks and relinks inventory items correctly from the hashmap on traveling.
2025-07-10 14:12:31 -03:00
Ricardo Luís Vaz Silva
29b2253bdb TArray list constructor 2025-07-10 14:12:31 -03:00
Ricardo Luís Vaz Silva
88a55be561 add TryEmplace to TMap 2025-04-16 23:45:16 -03:00
Jan Engelhardt
8e4080f8d1 Resolve compiler warning about destructor syntax
gcc-14 warns:

tarray.h:927:9: warning: template-id not allowed for destructor in C++20 [-Wtemplate-id-cdtor]
  927 |         ~TDeletingArray<T, TT> ()
2024-10-12 12:00:32 -03:00
Ricardo Luís Vaz Silva
87463ef36b Fix memory leak on TDeletingArray move assignment 2024-06-03 10:52:07 -03:00
Ricardo Luís Vaz Silva
458d81cede Make TArray take functions by forward-reference and call them by invoke
(1. avoids copying for lambdas, and 2. allows passing methods)
2024-03-17 18:07:50 -03:00
Ricardo Luís Vaz Silva
cc88dfbe50 Unrevert two changes
* Sorted Delete for TArray
* Typed constructor for TObjPtr
2024-03-15 17:21:59 -03:00
Christoph Oelckers
520b960ca5 Reverted the path node system
Code reviews were unfavorable so better nix it before it finds wider use.
2024-03-15 20:24:39 +01:00
Ricardo Luís Vaz Silva
3348822390 ... 2024-03-05 13:44:38 -05:00
Ricardo Luís Vaz Silva
cc51b486e0 TArray Binary Search 2024-03-05 13:44:38 -05:00
Christoph Oelckers
b37ea19f86 remove unnecessary #defines 2024-02-03 16:07:12 +01:00
Christoph Oelckers
963209e8af removed external stuff from tarray.h 2024-01-09 16:47:24 +01:00
Ricardo Luís Vaz Silva
8ae93fb87f use map instead of linear search to find texture indices for animation 2024-01-09 06:38:08 -05:00
Christoph Oelckers
83aa9388ca backend update from Raze
* moving large allocations off the stack
* use proper printf formatters for size_t and ptrdiff_t.
* adding some missing 'noexcept'.
2024-01-06 15:24:10 +01:00
Professor Hastig
c446af41ae fixed TArray::push_back 2024-01-05 16:42:40 +01:00
Christoph Oelckers
41573df58f added STL compatible access functions to TArray.
This allows using them in templates made for STL containers.
2023-12-10 09:07:48 +01:00
Christoph Oelckers
d65d1a3b82 minor backend update from Raze. 2023-10-17 20:54:27 +02:00
Christoph Oelckers
89535b803a Backend update from Raze. 2023-10-07 18:42:24 +02:00
Ricardo Luís Vaz Silva
fa8df5a4e5 make Array::Append faster for simple structs
This makes appending arrays of simple types faster
2023-10-07 17:27:35 +02:00
Ricardo Luís Vaz Silva
65ea4f91b6 fix TMap move insertion, was using the copy constructor due to a missing std::move 2023-10-07 17:27:35 +02:00
Ricardo Luís Vaz Silva
5b85557ddb add TArray::AppendFill for appending a single value multiple times 2023-06-26 00:36:36 -04:00
Christoph Oelckers
acfe82b9a8 - Backend update from Raze. 2023-05-27 09:31:17 +02:00
Christoph Oelckers
47b76180d6 - fixed several warnings emitted by Clang. 2023-03-26 08:48:54 +02:00
Ricardo Luís Vaz Silva
9e19134016 Fix possible memory corruption in TArray::Delete(index, count) 2023-03-22 18:59:59 +01:00
RaveYard
9514d1b120 Fix TArray allocating 0 bytes in constructor 2023-03-19 16:11:07 +01:00
Christoph Oelckers
941c0850ba - Backend update from Raze.
Mainly optimizations for the sound system and texture manager.
2022-12-18 16:19:18 +01:00
Ricardo Luís Vaz Silva
8b6a714d41 Map<K,V> and MapIterator<K,V> for ZScript 2022-12-04 15:11:00 +01:00
Christoph Oelckers
473221bb33 - fixed SoundEngine::isValidSoundId.
This never accounted for linked and random sounds. It never got noticed because it never was used to validate anything essential before.
2022-11-25 10:28:18 +01:00
Christoph Oelckers
c55dfbcddd - Backend update from Raze. 2022-11-06 08:49:25 +01:00
Christoph Oelckers
65a37856ec -fix TArray::Append with rvalue parameter
This must clear the source array to obey move rules.
2022-04-29 02:10:43 +02:00
Christoph Oelckers
673f06c05f - make m_alloc optional for tarray and memarena 2022-01-24 19:05:46 +01:00
Christoph Oelckers
e60e6967c0 - whitespace cleanup, updated from Raze. 2022-01-02 12:23:42 +01:00
Christoph Oelckers
1c517d19fa - Backend update from Raze.
This is mainly code cleanup from setting the compiler to a stricter warning level.
2022-01-02 11:39:17 +01:00
Christoph Oelckers
c598d9bab7 - Backend update from Raze.
* TArray extensions
* MSVC setup so that [[deprecated]] emits warnings.
2021-11-12 09:36:46 +01:00
Christoph Oelckers
b5294e9e90 - backend update from Raze. 2021-08-31 07:59:37 +02:00
Christoph Oelckers
52554dc32c - Backend update fron Raze, mainly new script exports and extensions. 2021-05-03 14:13:03 +02:00
alexey.lysiuk
013078a02f - fixed compilation with MSVC 14.28.29333 from VS2019 16.8.0
include\algorithm(7419,17): error C3892: '_First': you cannot assign to a variable that is const (compiling source file src\rendering\hwrenderer\scene\hw_drawlist.cpp)
2020-11-12 12:06:03 +02:00
Christoph Oelckers
db895b43b2 - copied constexpr declarations plus a few fixed in utility code and fixed a few places where this triggered a compile error now. 2020-09-27 08:36:30 +02:00
Christoph Oelckers
fb1a7679ec - moved most basic utility code without any dependencies on the rest of the engine to 'common' directory.
Again the objective is easier sharing with Raze.
2020-04-11 14:00:13 +02:00
Renamed from src/utility/tarray.h (Browse further)