Author SHA1 Message Date
Nikita Smith b99e10224f simplified chunk size tracking 2024-11-15 16:14:00 -08:00
Nikita Smith 435f6c4ef6 append .lib to defaultlibs 2024-11-15 16:14:00 -08:00
Nikita Smith b631d431fa create section layout without copying chunk data and perform chunk data
copy in parallel given layout
2024-11-15 16:14:00 -08:00
Nikita Smith 2562d04fbf changed build.bat to handle extra natvis for radlink and removed
'Unset' part since we use setlocal that prevents local variable
from leaking to the environment.
2024-11-15 16:14:00 -08:00
Nikita Smith b52a008748 remove debug trap 2024-11-15 16:14:00 -08:00
Nikita Smith b16d930d13 natvis for linker types 2024-11-15 16:14:00 -08:00
Ryan Fleury 26be351354 eliminate per-build version numbers, just use base layer to define defaults; bump to 14 2024-11-15 15:36:12 -08:00
Ryan Fleury 77b2172a85 restrict cursor line info committing by selected module 2024-11-15 15:00:15 -08:00
Ryan Fleury f1c5c97a1b fix stale detection in background fuzzy search results 2024-11-15 14:53:03 -08:00
Ryan Fleury 6be2792659 search cache eviction 2024-11-15 14:40:05 -08:00
Ryan Fleury c42e7837ac fix 64-bit bitfield type value evaluation mask/shift 2024-11-15 11:44:51 -08:00
Ryan Fleury fe657987d6 restrict module for line info visualization; it is not generally useful to do all modules, and in large projects it is too slow to do serially: 2024-11-15 11:19:46 -08:00
Ryan Fleury 48c7bb788e fix incorrect completion parameters hash storage in dbgi matching work, pt. 2 2024-11-15 11:15:25 -08:00
Ryan Fleury 080a001183 fix incorrect completion parameters hash storage in dbgi matching work 2024-11-15 11:12:58 -08:00
Ryan Fleury 81c7c7a7c4 per-target option of automatically debugging subprocesses, or not 2024-11-14 14:18:35 -08:00
Ryan Fleury 95fe497056 fix incorrect advance logic on invalid page reads in cached process memory reading path 2024-11-14 13:08:17 -08:00
Ryan Fleury 8994cb04bc adjust default font size settings by dpi relative to standard 2024-11-14 12:07:19 -08:00
Ryan Fleury ce90b63079 oops........ 2024-11-14 10:58:52 -08:00
Ryan Fleury 6cf9b82857 strip out completion counter from dbgi parsing layer 2024-11-14 10:47:45 -08:00
Ryan Fleury cefbd40e2c fix rw lock r/w mismatch 2024-11-14 10:26:51 -08:00
Ryan Fleury 420f089fda eliminate incorrect cases of async_push_work, where pushes which could occur on worker threads may try to write to a cache that is currently being held, when the push occurs (when all threads are saturated) - async_push_work must never be called from within a cache locking mechanism 2024-11-14 09:55:03 -08:00
Ryan Fleury ff45952f07 re-introduce timeout-based re-requests for dbgi & fs layers; further adjust pre-emptive conversion heuristic 2024-11-14 09:29:01 -08:00
Ryan Fleury fa4f9621b0 adjust pre-emptive conversion heuristics; fix deadlock scenario in match work 2024-11-14 09:10:07 -08:00
Ryan Fleury 4c0ebc851c async priorities, strip out incorrect ring position calculations 2024-11-13 18:23:18 -08:00
Ryan Fleury 5a79518dcb fix debug directory tree cache clearing rule 2024-11-13 16:05:22 -08:00
Ryan Fleury 713cc2c693 entering the 7th circle of DLL hell 2024-11-13 15:48:38 -08:00
Ryan Fleury dcec3c07d9 pass over pre-emptive debug info conversion heuristic, to be friendlier to ue-style root project directories, with what feels like 1000s and 1000s of sub-directories with DLLs hidden in various folders 2024-11-13 14:40:08 -08:00
Ryan Fleury b03c1766c6 just make commit granularity 64 bit; it matches the expected usage pattern in a few spots 2024-11-13 12:18:48 -08:00
Ryan Fleury 4278f7db1e extend pre-emptive conversion rule to do limited children directory checking as well 2024-11-13 11:47:17 -08:00
Ryan Fleury ff90a90744 fix lru eviction in async name match store 2024-11-12 14:36:40 -08:00
Ryan Fleury 626665911d fix incorrect order of work queueing in file stream task kickoff 2024-11-12 14:15:28 -08:00
Ryan Fleury f09f059af2 eliminate thread expression strings in scheduler process expansion 2024-11-12 13:47:04 -08:00
Ryan Fleury e95afcd5aa fix ring buffer stomping in async match 2024-11-12 13:20:42 -08:00
Nikita Smith a8b1805749 updated prof markup usage sites 2024-11-12 13:18:17 -08:00
Nikita Smith a8b2266fc0 added macro for sending notes to telemetry 2024-11-12 13:18:17 -08:00
Nikita Smith bc446d8520 dynamic profile zone with raddbg sprintf 2024-11-12 13:18:17 -08:00
Ryan Fleury 9808157f45 switch match tasks to atomically update match nodes, rather than push results into a queue 2024-11-12 13:00:23 -08:00
Ryan Fleury 0ec6b8e8a8 more work on match store experiment; consume ring buffer results on begin - this experiment is not exactly the right approach, though. because the ui thread definitionally learns about these identifiers faster than the matches can (always) be completed, there is a permanent writer-going-faster-than-reader problem. the correct approach will need to account for this. 2024-11-12 13:00:23 -08:00
Ryan Fleury 3e0c150ccb more work on background name matching & plugging it into syntax highlighting path 2024-11-12 13:00:23 -08:00
Nikita Smith fd1906b034 safe cast commit size 2024-11-12 10:36:45 -08:00
Nikita Smith 2bbf3ff987 switch to data size formatter 2024-11-12 10:36:45 -08:00
Nikita Smith 880d7a4139 data size formatter for stb_sprintf 2024-11-12 10:36:45 -08:00
Nikita Smith c6caec657d moved cstring and find needle string ops to the main layer 2024-11-12 10:36:45 -08:00
Nikita Smith 3d7fc6fce5 moved memory and count string formatters to the main layer and
replaced str8_from_memory_size with more accurate data size units
2024-11-12 10:36:44 -08:00
Nikita Smith 0d0951bf08 squash some image-related steps into finalize image 2024-11-12 10:36:44 -08:00
Nikita Smith 3a190ae2c3 show an early warning for /DEBUG:FASTLINK 2024-11-12 10:36:44 -08:00
Ryan Fleury 420c2ec208 fix dbgi key array copy 2024-11-11 16:15:15 -08:00
Ryan Fleury f9abd3efb9 first half of first pass at asynchronous name matching; simplify current name matching path used in syntax highlighting & deduplicate between code slice & code labels 2024-11-11 16:06:01 -08:00
Ryan Fleury 5893ab94cb cancellation mechanism for debug info fuzzy searching 2024-11-11 10:38:52 -08:00
Ryan Fleury ff2e9df705 fix incorrect match range list copying in new searcher threads 2024-11-11 10:02:06 -08:00
Ryan Fleury 5aeee47f98 oops - fix busted render handle compare 2024-11-11 09:48:11 -08:00
Ryan Fleury 31f25d0fe7 eliminate attempts at clever read-only synchronization in file stream & ctrl layer, just fall back to simple locking mechanism 2024-11-10 11:25:55 -08:00
Nikita Smith bd4f82c8e8 cursed early return 2024-11-08 16:46:11 -08:00
Nikita Smith 680ea2ffdc added /RAD_IDLE_WORKERS 2024-11-08 16:09:56 -08:00
Nikita Smith f7d7f6633f expose file API to enable IO detouring 2024-11-08 16:09:56 -08:00
Ryan Fleury 04c1488cd4 xxhash for ev & ui hashes 2024-11-08 15:02:52 -08:00
Ryan Fleury 5232ba298d cache cons type byte size, and more generally, do not require full type calculation in order to calculate byte sizes 2024-11-08 15:02:52 -08:00
Ryan Fleury 65ada18d1d fix render layer guid linking w/out font provider layer; eliminate generation number on render handles; sketch out tester scratch program for text drawing performance 2024-11-08 15:02:52 -08:00
Nikita Smith 8e6a0ae4db errors and warnings fixes 2024-11-08 11:43:05 -08:00
Nikita Smith e297460697 add necessary Linux impls for linker
NOTE: Current OS API for semaphores doesn't work well with Linux/pthreads
way, for example, on Linux it's up to user program to allocate shared memory
and store there sem_t and detect when to release it. (Windows does this under
the hood when process that created shared semaphore exits)
2024-11-08 11:43:05 -08:00
Nikita Smith cf8c0e7442 clang and gcc bit ops 2024-11-08 11:43:05 -08:00
Nikita Smith 776c8daa27 updated build.sh to define git hash 2024-11-08 11:43:05 -08:00
Nikita Smith 69b43c76d4 default to llvm-mt on non-windows platforms 2024-11-08 11:43:05 -08:00
Nikita Smith d114a0e961 tidy up guid on linux 2024-11-08 11:43:05 -08:00
Nikita Smith d177e39a54 build.sh add radlink target 2024-11-08 11:43:05 -08:00
Ryan Fleury 158dd742ad eliminate entry point 'mode'/type; just gather argc/argv as part of command line parse 2024-11-08 10:33:28 -08:00
Ryan Fleury 0773b6d282 switch to xxhash for font cache hashes 2024-11-08 09:04:16 -08:00
Nikita Smith 15d43d7c99 removed dependency on os_ext 2024-11-07 14:12:41 -08:00
Nikita Smith 7650a83d1e further simplify linker/os_ext/os_core.c 2024-11-07 14:08:21 -08:00
Nikita Smith daeb08e79f moved os_folder_exists to the main layer and deleted win32 layer from linker folder 2024-11-07 13:55:15 -08:00
Nikita Smith ef5287d2a9 switch to os_full_path_from_path 2024-11-07 13:41:47 -08:00
Nikita Smith db04792073 moved getter for process start time w32 2024-11-07 13:33:37 -08:00
Nikita Smith 4091373517 moved operating system -> string to base 2024-11-07 11:54:25 -08:00
Nikita Smith 214be8c433 moved Guid struct and related helpers to base 2024-11-07 11:54:25 -08:00
Nikita Smith f807dc4785 override entry point 2024-11-07 11:54:25 -08:00
Nikita Smith 0dd05169ee add ability to override entry point type 2024-11-07 11:54:25 -08:00
Nikita Smith ce9d43a92e pass over coff header 2024-11-07 11:54:25 -08:00
Nikita Smith 0886963d93 promote section definition number to 32-bit when linking big obj 2024-11-07 11:54:25 -08:00
Nikita Smith 27cd7a21a3 coff section definition for big obj 2024-11-07 11:54:24 -08:00
Nikita Smith 7bb88f480e mask compute typo 2024-11-07 11:54:24 -08:00
Nikita Smith fad817fb9e apply communal variable rule for largest comdat only 2024-11-07 11:54:24 -08:00
Nikita Smith 1d42f1bd66 speed up export table build with hash table 2024-11-07 11:54:24 -08:00
Ryan Fleury a5dd35b874 eliminate dbgi search layer usage 2024-11-07 10:14:17 -08:00
Ryan Fleury a89af7f6fd scratch that - *now* fix the arrayification 2024-11-07 10:07:36 -08:00
Ryan Fleury 5a19ab9c31 fix new search path arrayification 2024-11-07 10:06:49 -08:00
Ryan Fleury e204fe28c1 eliminate deadlocking mechanism in dbgi search cache lookup/mutation; replace with simpler but possibly worse mechanism for now 2024-11-07 09:57:25 -08:00
Ryan Fleury d036eb9fc5 eliminate old dbgi_search layer 2024-11-05 15:08:58 -08:00
Ryan Fleury 1621e504ce first half pass at new dbgi fuzzy searching functionality; distributes search amongst sub-tasks 2024-11-05 15:07:06 -08:00
Ryan Fleury 44b8c9e87c eliminate r/w lock promotion concept 2024-11-04 13:30:10 -08:00
Ryan Fleury 4a0e21d447 collapse user clock indices into base-layer-provided clock counter; fuzzy_search -> dbgi_search 2024-11-04 13:12:52 -08:00
Ryan Fleury 3cd32fa235 correctly prepare paths for windows launches in demon 2024-11-03 14:45:21 -08:00
Ryan Fleury c3a672cd02 fix incorrect async work ordering in dbgi layer 2024-11-03 12:48:34 -08:00
Ryan Fleury 9ce0bc5dbf [geo] move to async layer 2024-11-03 12:17:18 -08:00
Ryan Fleury ffb21277e9 [tex] move to async layer 2024-11-03 12:13:20 -08:00
Ryan Fleury a40edbba51 dasm, ctrl memstream, & more moving to async layer, rather than per-layer thread pools 2024-11-03 12:11:24 -08:00
Ryan Fleury c2855a9a46 eliminate txt layer parsing threads; use async layer 2024-11-03 11:12:24 -08:00
Ryan Fleury 61e7aaadeb implement 'work stealing' mechanism for falling back to synchronous task execution, if all work threads are taken 2024-11-01 16:41:43 -07:00
Ryan Fleury 5a0efe1261 move dbgi layer to async task layer 2024-11-01 15:30:17 -07:00
Ryan Fleury 6d55d21643 fix clang builds 2024-11-01 15:22:26 -07:00
Ryan Fleury 4164b30aac move breakpad converter to async layer; eliminate task system 2024-11-01 15:18:40 -07:00
Ryan Fleury aded54c97f fix pointer stability of async task output slot; finish moving converter to async system 2024-11-01 15:02:45 -07:00
Ryan Fleury 79bcbe4b39 switch rdi_from_pdb to new async layer, off of old task system 2024-11-01 14:44:56 -07:00
Ryan Fleury 86d9b792d8 shift file streaming layer to using async layer for background work, remove file stream layer thread pool 2024-10-31 11:44:54 -07:00
Nikita Smith f3a36ece13 rebase fixes 2024-10-30 15:56:55 -07:00
Nikita Smith c5d198e3e9 build linker with branch name and full commit hash 2024-10-30 15:56:10 -07:00
Nikita Smith eba7500f73 /rad_pdb_hash_type_names:lenient
Less aggressive optimization for type names. When lenient enabled, linker
replaces only mangled names and compiler generated lambda types.
2024-10-30 15:56:10 -07:00
Nikita Smith 339f43919c remove bogus leaf align 2024-10-30 15:56:09 -07:00
Nikita Smith f3fbf10754 replace type names with hashes 2024-10-30 15:56:09 -07:00
Nikita Smith 4a2e1dd8d0 switch to thread safe hash trie map
Initial implementation of the symbol table allowed us to push symbols
from one thread at a time and required a wonky lock-step and spread out
logic for replacing symbols. And because it was a externally chained
hash table we had to guesstimate optimal capacity for small and big targets.
We erred on the side of larger capacity to prevent degradation and
rehashing, however this meant small targets had to spent unreasonable
amount of time memory allocing slots. With hash trie we can dynamically
scale up to 4 ^ 32 items and atomically replace symbols when needed. Neat!
2024-10-30 15:43:53 -07:00
Nikita Smith ee65ea3692 fast-path for string matching 2024-10-30 15:42:39 -07:00
Nikita Smith baead67a99 minor fixes 2024-10-30 15:42:39 -07:00
Nikita Smith e085dae636 pass over atomic operations
- use cast to volatile trick for atomic loads on x64 windows
- removed unnecessary includes on windows
- upgraded clang and gcc code paths to use modern atomics

Removed WIN32_LEAN_AND_MEAN because we were already compiling without it
and there is code path in os_gfx_win32.c that relies on including full
windows.h
2024-10-30 15:42:39 -07:00
Nikita Smith eba6765541 set LF endings for shell scripts so they are executable after checkout 2024-10-30 15:42:39 -07:00
Nikita Smith 002e479a2d index on dev: 62880e6 set explicitly heap and stack reserve and size 2024-10-30 15:42:39 -07:00
Nikita Smith 8848080729 set explicitly heap and stack reserve and size 2024-10-30 15:42:39 -07:00
Nikita Smith e1166abc63 typo in str8 compar name 2024-10-30 15:42:39 -07:00
Nikita Smith 6ffc065712 set dynamic base on /fixed:no 2024-10-30 15:42:39 -07:00
Nikita Smith 15b1ebcd21 coff section align from byte size helper 2024-10-30 15:42:39 -07:00
Ryan Fleury 37b27a9cff correctly bounds-check cursor before doing snapping operations 2024-10-30 06:20:11 -07:00
Ryan Fleury 327fec3155 fix rdi_from_pdb build 2024-10-29 16:50:37 -07:00
Ryan Fleury d0b97a3010 first pass at more comprehensive async layer, for replacing task system & providing single mechanism for async work, which is currently done ad-hoc in various layers 2024-10-29 16:27:21 -07:00
Ryan Fleury 1b5321ad8e fix incorrect tooltip 2024-10-28 21:38:09 -07:00
Ryan Fleury 4769d0a8d4 narrow scope of name resolution for debugger collections; default launching to not attach to child processes, set up msgs to parameterize this 2024-10-28 15:37:28 -07:00
Ryan Fleury 41cddf96b8 preemptive adjacent pdb conversion on initial module load; tighten up c/c++ lexer for smaller string lexes 2024-10-28 13:52:36 -07:00
Ryan Fleury 100d3523d3 clamp floating root positions by window lower bound as well 2024-10-24 11:48:45 -07:00
Ryan Fleury f0b1b46840 clamp thread tooltip callstack symbol names 2024-10-24 11:45:45 -07:00
Ryan Fleury e9666e2edd adjust disasm lexer to account for compiler-autogenerated symbol names 2024-10-24 11:41:59 -07:00
Ryan Fleury 8f932bdbf7 oops 2024-10-24 11:29:13 -07:00
Ryan Fleury c3c9539f9b prioritize string/symbol content in single-line pointer visualization; only use address-first when descending. also fix signed/unsigned visualization of character numeric values 2024-10-24 11:25:27 -07:00
Ryan Fleury 13341a458a fix incorrect kill-single-process ui path 2024-10-23 13:23:22 -07:00
Ryan Fleury 62659c5161 introduce dedicated kill-all path; fix exit conditions for single-stepping stuck threads to be robust toward unexpected kills; fix exit conditions for kill-single-process path, to be more robust to halts; correctly report stop cause 2024-10-23 13:19:37 -07:00
Ryan Fleury 1ecabff7b6 prefer usage of pdbs in dbgi layer, if rdi path is not baked in, but pdb path *is* - otherwise the dbgi layer can simply choose a stale rdi file with no way to generate a new one. 2024-10-23 11:49:47 -07:00
Ryan Fleury 45f5a2d18f accept / command line arguments on windows 2024-10-23 11:19:07 -07:00
Ryan Fleury bcd16a4f29 only plug in jumping immediates to jump_dest_vaddr paths in stepping; ctrl flow info analysis path stops when it has to read memory or registers 2024-10-23 11:07:51 -07:00
Ryan Fleury 6d7858d445 parameterize tester with test data root folder; wrap tester run in top-levels cript 2024-10-22 17:51:21 -07:00
Ryan Fleury c67f1a8b4a fix empty file edge case in hash store / text cache 2024-10-22 16:19:11 -07:00
Nikita Smith 340396f9f7 fix arena usage 2024-10-22 15:07:49 -07:00
Nikita Smith eb6aabe2d1 set block base pos 2024-10-22 15:06:39 -07:00
Nikita Smith 9ec7fb61ed implemented /noimplib /noexp 2024-10-22 11:02:59 -07:00
Nikita Smith dcffefd0c6 typo in string table lookup 2024-10-22 10:58:41 -07:00
Nikita Smith 5be2b5dfd9 alias for amd64 machine 2024-10-22 10:19:37 -07:00
Nikita Smith 7260baea85 implemented /PDBALTPATH and /RAD_DEBUGALTPATH 2024-10-21 18:03:28 -07:00
Nikita Smith a802f2186b actually push new block to list 2024-10-21 14:35:55 -07:00
Nikita Smith a43678e311 voff -> line search fix
when line table contains duplicate virtual offsets we have to return
index of last virtual offset so following property is true:
'line_length = virtual_offsets[index + 1] - virtual_offsets[index]'
2024-10-21 13:32:04 -07:00
Ryan Fleury edee84dd03 fix maximum munch rule application in text cache lexers 2024-10-21 10:37:04 -07:00
Ryan Fleury 4a211de2b3 do not bake path normalization into eval string <-> file path; this incorrectly assumes the normalization base directory, which is not correct when serializing/deserializing/etc. instead, just normalize on find-code-location. 2024-10-21 09:56:32 -07:00
Ryan Fleury d0915ec9a7 eval expressions: unary +, correctly lex exponentiated numerics 2024-10-21 09:23:31 -07:00
Ryan Fleury 52245a8e5a maintain explicit casts in cstring -> string paths 2024-10-21 08:51:19 -07:00
Nikita Smith dbcecd99af fix sizeof array types 2024-10-19 20:39:40 -07:00
Nikita Smith 68c0906570 print register name 2024-10-19 20:39:40 -07:00
Nikita Smith 26611c5454 moved IO related code to stand-alone file, piped all read/and writes
through new API, /rad_log now can enable read and/or write logs with
"io", "io_reads", "io_writes" parameters.
2024-10-19 16:36:32 -07:00
Nikita Smith 05d4faeb49 remove unsued func 2024-10-19 15:13:10 -07:00
Nikita Smith d5c2e50e9a rename import table regular -> static 2024-10-19 15:11:51 -07:00
Nikita Smith 800a2349e5 pass over COFF resource reader and writer 2024-10-19 13:44:36 -07:00
Nikita Smith 46390ba0b8 reworked manifest handling
- manifest files wont be created unless symbols are resolved
- delay mt.exe presence check until we launch it
- create explicit case that writes manifests to disk
- moved manifest dependency collection step to happen after obj input
- removed /rad_delete_manifest
2024-10-18 23:37:30 -07:00
Nikita Smith f1a0e7233d cstring helper for wide chars 2024-10-18 22:56:55 -07:00
Nikita Smith 9d60dcc099 updated radlink benches in readme 2024-10-18 17:12:31 -07:00
Nikita Smith f792da5d31 manifest... 2024-10-18 16:53:30 -07:00
Ryan Fleury 1344270b5a adjust versions 2024-10-18 16:40:25 -07:00
Ryan Fleury c03844fb1a fix build, make icon unique to raddbg 2024-10-18 16:32:49 -07:00
Nikita Smith d04e86c007 rename merged manifest 2024-10-18 16:23:51 -07:00
Ryan Fleury 669574df5a fix incorrect ordering of inline sites & concrete frames in call stack view 2024-10-18 16:07:25 -07:00
Nikita Smith 3aa4b2ea03 fix udt resolution & emit correct null type 2024-10-18 16:01:17 -07:00
Nikita Smith 2f5e55d52f switch check typo 2024-10-18 16:01:17 -07:00
Nikita Smith 14ad67d59a assign correct file path node to source file
* disabled debug check for sortness too while I'm here
2024-10-18 16:01:17 -07:00
Nikita Smith b2bdb893a0 print file path node idx 2024-10-18 16:01:17 -07:00
Ryan Fleury 98dfedfff5 limit the amount of line info visualization voff gathering; otherwise we can just spend tons of time gathering inline site voffs forever... 2024-10-18 15:16:34 -07:00
Ryan Fleury 1f633a029c skip redundant expansion tasks in eval viz block tree build 2024-10-18 13:58:24 -07:00
Ryan Fleury b3d6b2913e fix enum value committing 2024-10-18 13:47:51 -07:00
Ryan Fleury 53c624a27c respect view rule radix in enum evaluations 2024-10-18 13:37:14 -07:00
Ryan Fleury 1865c33704 specify collection qualifier for collection tabs; do not resolve to anything else 2024-10-18 13:32:29 -07:00
Ryan Fleury e17a089564 fix incorrect 0 member (should be nil) 2024-10-18 12:14:40 -07:00
Ryan Fleury eb9212b6f7 fix string cmd query params 2024-10-18 12:00:13 -07:00
Nikita Smith 0ac090cab2 delete unused files 2024-10-18 11:07:00 -07:00
Nikita Smith 7827e1b1c7 fix bounds check condition in assert 2024-10-18 11:07:00 -07:00
Nikita Smith 36f3924160 don't allocate .reloc section when there are no pages 2024-10-18 11:05:51 -07:00
Nikita Smith 00dd4ad6ec check if subsystem was specified 2024-10-18 11:05:01 -07:00
Nikita Smith 7f7f7f2873 reserve space for null string 2024-10-18 11:03:46 -07:00
Nikita Smith c8a5fc4806 Changed debug directory parser to handle multiple entries. Added
parser for RDI debug info entry. Changed debug info lookup order so
debugger tries to load path specified in exe first and if debug info
is missing then debugger will do heuristic searches.
2024-10-17 18:51:35 -07:00
Nikita Smith 652dcafbbf demon helper for reading cstrings 2024-10-17 18:46:59 -07:00
Ryan Fleury 72f987533c Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-10-17 16:50:50 -07:00
Ryan Fleury 5fd835c4d4 note 2024-10-17 16:50:25 -07:00
Nikita Smith c50d9276ba build inline lines accels 2024-10-17 16:25:54 -07:00
Nikita Smith 1214cb0968 dumper for CodeView inline sites 2024-10-17 16:25:54 -07:00
Nikita Smith 3099759c0b stringizers for inline site range kind 2024-10-17 16:25:54 -07:00
Nikita Smith 95d31f5608 fix off-by-one in inline site decode 2024-10-17 16:25:54 -07:00
Ryan Fleury 687323fc2e fix soft-halt with thread freezes; fix disabling/tooltips of top-bar controls 2024-10-17 16:12:31 -07:00
Ryan Fleury 51dce36ede notes 2024-10-17 14:51:41 -07:00
Ryan Fleury b61f4d550f Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-10-17 14:51:28 -07:00
Ryan Fleury d8d8762869 adjust entity rows in watch views to use single-click for select, double-click for their primary operation, and add in operation for breakpoints/watch-pins 2024-10-17 14:51:07 -07:00
Nikita Smith d2db4542cb check type server signature against signature in obj 2024-10-17 14:05:34 -07:00
Ryan Fleury 7adf08cc7b parameterize string eval commit path by whether or not the surrounding ui expects the string to be manually escaped or not by the user (it is not in the case of things like the meta-entity views) 2024-10-17 12:57:53 -07:00
Ryan Fleury a202999655 fix over-ambitious thread selection in frontend 2024-10-17 12:43:32 -07:00
Ryan Fleury ae3a43c694 fix file-path-parameterized commands w/ ipc 2024-10-17 12:32:20 -07:00
Ryan Fleury 2f7434cd92 always use pending-file when doing a file switch 2024-10-17 12:29:06 -07:00
Ryan Fleury b02c67bfa6 close stdout/stderr/stdin handles 2024-10-17 12:20:03 -07:00
Ryan Fleury 992be37801 fix unclamped-by-line token ranges in code slice widget mouse -> token path 2024-10-17 12:13:32 -07:00
Ryan Fleury 4727a01b9f fix kill/halt button & text 2024-10-17 12:01:02 -07:00
Ryan Fleury e376ad8113 stdout/stderr/stdin file path overrides for targets 2024-10-17 11:25:47 -07:00
Ryan Fleury 23ad094a68 allow escaped-identifier lookup for type names 2024-10-17 10:46:14 -07:00
Nikita Smith 2b407b5861 changed write file to accept 1MiB blocks to improve file write speed on windows 2024-10-16 22:27:46 -07:00
Nikita Smith 79390f4a95 align msf pages on page size 2024-10-16 22:27:46 -07:00
Nikita Smith aedfb556be fix aligned arena push 2024-10-16 22:27:46 -07:00
Ryan Fleury 78039c86a0 include no_addr in view rule system for docs/inheritance rules 2024-10-16 15:41:21 -07:00
Ryan Fleury 186e8cbabe shift disasm view to rounding/sizing equally 2024-10-16 14:58:13 -07:00
Ryan Fleury 5ec0a0e406 fix incorrect inline site baking 2024-10-16 14:29:08 -07:00
Martins Mozeiko 9c016004c2 Setup symbol path in win32 exception handler to the .exe folder
Otherwise it was trying lookup .pdb files only in the current folder,
as that is how .exe's are built (/pdbaltpath). This change now makes
exception handler to load .pdb from the same folder as where .exe is.
2024-10-16 14:13:26 -07:00
Ryan Fleury 9c1f8ef37b file name disambiguation for tab titles 2024-10-16 14:12:21 -07:00
Ryan Fleury 938af75efb normalize paths when doing file-path <-> eval string 2024-10-16 13:33:47 -07:00
Ryan Fleury 38173a7154 adjust pointer visualization; don't follow 0 pointers, go back to showing address first; adjust find-code-location snapping rule to only require a disasm snap / focus if no file location is specified 2024-10-16 13:23:10 -07:00
Ryan Fleury 74ee3b9850 option to rdi_from_pdb for deterministic generation; omits non-intrinsic, build-dependent information 2024-10-16 12:47:10 -07:00
Ryan Fleury 2edb65b5bd fix remaining non-determinism in pdb -> rdi generation! 2024-10-16 12:07:02 -07:00
Nikita Smith 9e6aa8506f README.md tweaks 2024-10-16 10:48:51 -07:00
Nikita Smith 648fa7cdab update hash in config 2024-10-16 10:23:53 -07:00
Nikita Smith 6612f4a32d hash image only when we have debug info building 2024-10-16 10:15:16 -07:00
Ryan Fleury e65bc121ed more work on pdb -> rdi determinism; almost done hitting all of the issues... 2024-10-16 08:52:27 -07:00
Ryan Fleury e1575f815c Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-10-15 18:05:14 -07:00
Ryan Fleury 0b50d8718e oops - reenable 2024-10-15 18:05:05 -07:00
Ryan Fleury 4671458e8e further debugging / logging / work on tester, trynig to get to the bottom of nondeterministic rdi generation 2024-10-15 17:41:18 -07:00
Nikita Smith bb86072dfa updated git actions 2024-10-15 17:32:21 -07:00
Nikita Smith d5988d0066 updated README 2024-10-15 17:26:50 -07:00
Nikita Smith 932df7bf68 linker 2024-10-15 17:25:22 -07:00
Nikita Smith 0cf553e39a minor fixes 2024-10-15 17:24:29 -07:00
Nikita Smith 1bcd66329f factored parser code out of pdb 2024-10-15 16:28:51 -07:00
Nikita Smith c3e2e2e91b factored parser code out of msf 2024-10-15 16:28:47 -07:00
Nikita Smith c34d7e2062 added missing LF_ENDPRECOMP type, fixed case for S_OBJNAME symbol,
merged leaf id kinds into main leaf enum, renamed public flags enum,
removed type dependency on PDB string table and PDB coff section array
2024-10-15 16:24:29 -07:00
Nikita Smith b1d6ebf77b added masm language enum and type kind count 2024-10-15 16:20:18 -07:00
Nikita Smith 9535652cfb define null path style 2024-10-15 16:19:27 -07:00
Nikita Smith 3ae1d8e401 bunch of tiny tweaks and changes from internal repo 2024-10-15 16:18:43 -07:00
Nikita Smith 7e98df22d7 temp arena change that lets us bypass memory decommits 2024-10-15 14:43:36 -07:00
Ryan Fleury 65b5176468 allocate extra slot for nil in global vmap baking; was causing overwrites of keys/markers before! 2024-10-15 12:42:43 -07:00
Ryan Fleury e61dfd793a stdout redirection support in os command line launch helper; do rdi dumps in determinism test 2024-10-15 12:20:25 -07:00
Ryan Fleury 97abec11a2 begin setting up tester for automated tests 2024-10-15 11:46:07 -07:00
Ryan Fleury b223a61cad tweaks & language fix 2024-10-15 10:17:37 -07:00
Ryan Fleury 94fb5056c2 resolve ptr-addition integer to value 2024-10-15 10:07:10 -07:00
Ryan Fleury 88dced7d2a notes 2024-10-15 09:00:54 -07:00
Ryan Fleury e92543d3f8 round to 4K rather than 16K boundaries for starting disasm address 2024-10-14 21:46:03 -07:00
Ryan Fleury 078cbf6afd fix incorrect auto disasm starting address 2024-10-14 20:56:25 -07:00
Martins Mozeiko 3d34a26205 avx512 register support in codeview -> rdi conversion 2024-10-14 20:54:26 -07:00
Ryan Fleury cc2848feb9 visualize temporary targets, provide path to move to project; final notes & readme adjustments 2024-10-14 16:25:31 -07:00
Ryan Fleury 5c861d5a10 temporary hack to fix serialization/deserialization of symbol breakpoints 2024-10-14 15:54:11 -07:00
Ryan Fleury 78e99d4094 temporary hack to fix over-ambitious project filtering 2024-10-14 15:45:15 -07:00
Ryan Fleury 18f72dd5ea fix cases where empty/busted config was not being properly reset; a few other small fixes & notes; disabling linked list helper tooltip until it's back in 2024-10-14 15:33:35 -07:00
Ryan Fleury eadd49072a restart path, breakpoint vaddr editing path 2024-10-14 15:10:44 -07:00
Ryan Fleury 1bf01c790b ctrl entity lister; fix up entity parameter commands / lister interaction 2024-10-14 15:01:35 -07:00
Ryan Fleury 6fcdce4e0f default expansion in eval visualization; apply to scheduler tree 2024-10-14 14:21:12 -07:00
Ryan Fleury 6a297113c5 more work on new scheduler 2024-10-14 13:36:17 -07:00
Ryan Fleury 9169c14e24 dead code elimination 2024-10-14 11:04:28 -07:00
Ryan Fleury e2722e45c8 new go-to-file-path implementation, in go-to-name command 2024-10-14 11:03:51 -07:00
Ryan Fleury 59abb3750d switch-to-partner file implementation 2024-10-14 10:43:48 -07:00
Ryan Fleury 4f33162d8c new switch implementation with per-project recent files 2024-10-14 10:35:00 -07:00
Ryan Fleury d87704c91f decay arrays to pointers when doing pointer-array comparisons; begin gathering recent file history into project state; prefer larger src/disasm panels when finding a new location; do not over-ambitiously hold top-level frame scopes for dbgi/fzy - stop before per-frame sleep 2024-10-14 10:20:27 -07:00
Ryan Fleury 89f47df0e2 wrap view rule, for wrapping an expression with a containing expression 2024-10-14 09:17:29 -07:00
Ryan Fleury 68fa006e53 basic entity right click menu for name/condition editing 2024-10-14 08:44:18 -07:00
Ryan Fleury a365d23acf do not apply invalid auto view rules: 2024-10-14 08:21:21 -07:00
Ryan Fleury 1c269286df auto view rules 2024-10-14 08:19:42 -07:00
Ryan Fleury 8a1dd578a7 sketch out ptr graph building data structures 2024-10-13 20:14:59 -07:00
Ryan Fleury adb8d5237c stub out linked list view rule in new eval viz system; sketch out pointer graph cache layer, for pointer chasing & building graphs asynchronously, for use in the linked list viewer & other future visualizers 2024-10-13 20:07:39 -07:00
Ryan Fleury 000970758a dead code elimination; bp hit count reset on initial-step-into fix; notes 2024-10-13 19:32:09 -07:00
Ryan Fleury ba0e4ea0c5 fix cross-module global evaluation with new multi-module-capable eval system 2024-10-13 19:25:42 -07:00
Ryan Fleury b45462c740 cache control entity meta evals, do not reconstruct on every single meta ctrl eval space read 2024-10-13 18:11:20 -07:00
Ryan Fleury ff589d2e55 digits view rule 2024-10-13 16:39:16 -07:00
Ryan Fleury 2a44f1df60 tweaks 2024-10-13 15:16:54 -07:00
Ryan Fleury 165170ba2b Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-10-11 17:26:56 -07:00
Ryan Fleury 9aefc68177 more work on full scheduler view 2024-10-11 17:23:41 -07:00
Nikita Smith 3f88b83fdb pe: added helpers for image checksum debug directory, and entry point names 2024-10-11 16:15:55 -07:00
Ryan Fleury 7724c7f7d3 begin setting up view rules for scheduler tree 2024-10-11 16:01:40 -07:00
Ryan Fleury e86190a3d3 Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-10-11 15:14:50 -07:00
Ryan Fleury fc1c00c8f5 fix array value string generation to account for type modifiers 2024-10-11 15:14:46 -07:00
Ryan Fleury 193d6726c6 adjust control thread single-step path to be a bit more robust to malformed requests 2024-10-11 15:09:08 -07:00
Nikita Smith ab9804860c base: bug fix large pages commit code path 2024-10-11 13:50:08 -07:00
Ryan Fleury 4091f5e0c0 rich unwind -> callstack, defined by ctrl layer, so we can begin floating meta evaluation cache to ctrl layer 2024-10-11 11:46:25 -07:00
Ryan Fleury 4757c4dafd switch reg cmd name parameterization from using general string slot, to its own dedicated slot, so that the string can be used 2024-10-11 10:38:28 -07:00
Ryan Fleury f44c94c3ca bring-to-front command 2024-10-11 10:23:18 -07:00
Ryan Fleury b9f931a749 guard against name collisions in call stack root expression; need to explicitly resolve against debugger-defined names 2024-10-10 15:34:31 -07:00
Ryan Fleury 79b2bcf37a fix incorrect alignment assumption in arena 2024-10-10 15:11:22 -07:00
Ryan Fleury 01eb655d19 fix memory view 2024-10-10 14:37:46 -07:00
Ryan Fleury 51b8dbaab0 fix incorrect registers view with new eval viz expansion system 2024-10-10 14:06:52 -07:00
Ryan Fleury 578d8d64a0 correctly apply path maps in engine; correctly set disasm mode in source/disasm views 2024-10-10 13:43:45 -07:00
Ryan Fleury 546c817d34 proper file path map application in source code line info visualization & thread/bp mapping; fix incorrect base vaddr in disasm view post-visualization pass 2024-10-10 13:33:50 -07:00
Ryan Fleury 2bf5c9c9a4 docs & fix for -q 2024-10-10 13:04:16 -07:00
Ryan Fleury f6502f476b quit-after-success flag 2024-10-10 12:57:26 -07:00
Ryan Fleury 0d50157239 fixes with path map application; further completeness of file drop completion menu; fix of set-next-statement 2024-10-10 12:03:11 -07:00
Ryan Fleury ba5f2021f6 file path map application in go-to-code-location path 2024-10-10 11:45:38 -07:00
Ryan Fleury 8336aa71ad fix incorrect deletion flags set for file path map entities 2024-10-10 11:23:29 -07:00
Ryan Fleury 903995f85e file path map building & ui 2024-10-10 11:13:11 -07:00
Ryan Fleury 0c6912ed78 sketch out meta-evaluation for file path maps; have an extra drop-completion ui step when drag/dropping exes, so you can easily drag/drop exes from explorer and add them as targets (the likely common case), but also allowing viewing them with the memory viewer 2024-10-10 09:03:38 -07:00
Ryan Fleury 5933708bdb fix cacheline boundary visualization & other various fixes in eval / eval viz 2024-10-10 08:13:58 -07:00
Ryan Fleury 9c5d9caa32 pass over help menu; typeof in eval 2024-10-10 07:44:26 -07:00
Ryan Fleury 848b26bbd9 fixes / jank pass 2024-10-10 07:13:47 -07:00
Ryan Fleury 0359998a8b do not send statically-disqualified conditional breakpoints to control thread - if they are only controlled by static values or by evaluations on ui-thread-controlled-or-defined state, we can eliminate them from the control thread's concerns 2024-10-09 16:38:34 -07:00
Ryan Fleury 883f1ee1cb eliminate path for frontend to communicate meta evaluation info to ctrl thread - that can't be how it works, since control thread entities change during a demon_run, and thus the control thread needs to recompute meta evaluations for its entities on-the-fly 2024-10-09 16:26:04 -07:00
Ryan Fleury 07c781a4f6 jank reduction & completeness pass 2024-10-09 16:24:29 -07:00
Ryan Fleury ac19591df6 source view reset bugfix; bp hit count reset bugfix (should happen on launch-of-new-session, not after process has started, since we can now evaluate breakpoints on the control thread) 2024-10-09 16:07:00 -07:00
Ryan Fleury 564b8ea753 don't use checkbox icon for what is really a radio button 2024-10-09 15:26:12 -07:00
Ryan Fleury 73555a2486 shift+click to toggle bps 2024-10-09 15:17:39 -07:00
Ryan Fleury 1758292074 pipe breakpoint-condition-touched meta-evaluations to control thread; allow evaluation of meta-evaluations in conditional breakpoints 2024-10-09 15:07:54 -07:00
Ryan Fleury d0e0e35fb5 fix first-time startup not being parameterized by startup window 2024-10-09 14:25:28 -07:00
Ryan Fleury 8e5ebc2d75 memory view fixups for new visualization systems; breakpoint editing work 2024-10-09 13:58:41 -07:00
Ryan Fleury bd87c109b5 extend autocompletion lister to support path autocompletion; use in cases where a watch window view is editing a path-tagged type 2024-10-09 11:18:46 -07:00
Ryan Fleury b960935315 only apply file paths to registers in text visualizers if they are explicitly evaluated - otherwise line info will be correlated to non-source-files 2024-10-08 21:37:45 -07:00
Ryan Fleury dc32a9eb01 leave stubs for go-to-disasm & go-to-source commands 2024-10-08 17:12:45 -07:00
Ryan Fleury 8d0267395a fix go-to-source 2024-10-08 17:08:02 -07:00
Ryan Fleury 05045c8db0 increase hash store history limit; fix incorrectly skipping important go-to-code-location commands 2024-10-08 17:02:49 -07:00
Ryan Fleury aea1999af0 further fixes to implicit disasm parameterization 2024-10-08 16:28:36 -07:00
Ryan Fleury 6bcc316b42 adjust non-parameterized disassembly rules to fit expected behavior better; if user runs 'go to address', or 'go to disassembly', a non-parameterized disassembly view will adjust to a 'temporary look' address, but will reset back to the thread's address upon a new run. this fits generally expected behavior - for stable looks at arbitrary addresses, that is when you would just want to use the watch window & use the disassembly view rule on a specific parameter expression. 2024-10-08 16:19:11 -07:00
Ryan Fleury 8cdf264f4d fix only/omit rules to apply to pointers-to-structs in the same way they apply to regular structs 2024-10-08 15:46:17 -07:00
Ryan Fleury 91aedd5888 be a bit less careful with disabled animation delay 2024-10-08 15:33:52 -07:00
Ryan Fleury 870df1191b jank reduction & flow fix pass, after all of the last month's changes 2024-10-08 15:32:34 -07:00
Ryan Fleury 8708b27bff bps view work 2024-10-08 11:52:43 -07:00
Ryan Fleury c6b44f6afa bp hit counts reset; cell-granularity deletions path for watch windows 2024-10-08 11:25:16 -07:00
Ryan Fleury 6be9c71ea9 first pass at meta entity eval commits; breakpoint editing, target editing, watch pin editing 2024-10-07 21:22:22 -07:00
Ryan Fleury 3720634a62 scroll output to bottom by default (not yet configurable) 2024-10-07 17:45:57 -07:00
Ryan Fleury 534a727b7c unminimize on exception hit 2024-10-07 17:33:10 -07:00
Ryan Fleury 32ce2e110b auto-resolution of derived class ptrs 2024-10-07 17:06:40 -07:00
Ryan Fleury 58114b72f4 move member lookup paths to using eval type member cache 2024-10-07 16:26:43 -07:00
Ryan Fleury 54bb225704 lock expand operations in the watch view via the expandability detection - do not just try expanding 2024-10-07 16:13:36 -07:00
Ryan Fleury 3f19c45dd3 fix enums not working for simple integer operations in eval 2024-10-07 16:04:03 -07:00
Ryan Fleury cf46ce7712 codebase readme pass 2024-10-07 15:59:39 -07:00
Ryan Fleury 23ed5c8f5f allow 'only' view rule to determine sort-order of members in constructed type info 2024-10-07 14:50:41 -07:00
Ryan Fleury c7ce08fd71 fix clang builds 2024-10-07 14:43:31 -07:00
Ryan Fleury 7114a20e66 apply expr view rule fast paths properly 2024-10-07 14:22:31 -07:00
Ryan Fleury 95dd544871 top-level text editing mode state, so that textual keys can be used for hotkeys, but just become disabled when text editing is actually happening 2024-10-07 13:54:30 -07:00
Ryan Fleury 084ef67583 fix implicit source code location parameterization w.r.t. disassembly & code file cursors; also fix output view state 2024-10-07 13:40:08 -07:00
Ryan Fleury 71cdc0eab8 watch pins 2024-10-07 13:10:54 -07:00
Ryan Fleury fa46a52600 stop double-escaping font config paths 2024-10-07 12:50:38 -07:00
Ryan Fleury a2f1be3aa9 fix view rule state retention across reloads 2024-10-07 12:47:17 -07:00
Ryan Fleury 9ed5134843 fix watch reordering, to be more flexible to how entities are arranged w.r.t. rows (add-new-rows at top) 2024-10-07 11:52:53 -07:00
Ryan Fleury 232f955786 breakpoints, watch pins 2024-10-06 13:35:41 -07:00
Ryan Fleury 6a1c36b212 use more basic default epsilon assumption 2024-10-04 11:51:12 -07:00
Ryan Fleury 71ff183dc4 move over to new rich hover system for all entity tooltips 2024-10-03 09:34:47 -07:00
Ryan Fleury 8b8acf64d6 more work on universal rich hover / ctx menu systems 2024-10-02 12:02:49 -07:00
Ryan Fleury 487c7c9938 show rich hover tooltips when dragging/dropping as well 2024-10-01 15:44:37 -07:00
Ryan Fleury d978f56250 thread rich hover 2024-10-01 13:48:11 -07:00
Ryan Fleury 5f32b0710e more work on modules view; show debug info loading status 2024-10-01 12:36:41 -07:00
Ryan Fleury 911f9ef97b make meta & eval type system a bit richer to express plain text vs. code text vs. path text 2024-10-01 12:04:40 -07:00
Ryan Fleury 685cb4a3b8 further work on expanding main watch path to support various string styling/visualizing mechanisms, used ad-hoc before; more work on scheduler 2024-10-01 11:43:57 -07:00
Ryan Fleury dae0d602f9 modules view pass 2024-10-01 10:42:31 -07:00
Ryan Fleury ac5c65ebdd fix busted next/prev tab operations on panels with single tab 2024-10-01 10:02:37 -07:00
Ryan Fleury 04815b4265 continue work on ctrl entity visualization in watch views & further progress on new scheduler 2024-10-01 09:36:29 -07:00
Ryan Fleury 152cc709ce work on ctrl entity buttons in watch views 2024-09-30 17:07:50 -07:00
Ryan Fleury 57d01355a1 create pre-filtered types for meta evals; all of the same underlying data transforms are on a single meta-eval data bundle, but now each type of meta eval entity is exposed via a tighter type to the ui & eval system 2024-09-30 16:03:55 -07:00
Ryan Fleury fcedcab57c begin work on scheduler view requirements 2024-09-30 15:08:05 -07:00
Ryan Fleury 3fb8b83324 mostly done with all of the special machinery for entity views via watch windows 2024-09-30 14:12:55 -07:00
Ryan Fleury 5d76b58acd targets view: ensure ctrl+click for selection, ensure proper target parameterization of engine commands 2024-09-30 09:40:39 -07:00
Ryan Fleury 2e13b221ac do not attempt to form implicit member lookup expressions if initial map failed 2024-09-27 17:03:18 -07:00
Ryan Fleury 64e5d60f38 eliminate adjusted frame base check, which was causing incorrect unwinds in some cases 2024-09-27 16:57:23 -07:00
Ryan Fleury ce72af8b59 fix inclusion of symbolized addresses in editable eval visualization strings 2024-09-27 16:30:01 -07:00
Ryan Fleury 086ca98181 callstack unwind selection in watch window-ified callstack view 2024-09-27 16:27:55 -07:00
Ryan Fleury fe59fab3da progress on callstack view replacement 2024-09-27 15:48:36 -07:00
Ryan Fleury 52b2cbc17a selection in targets view 2024-09-27 14:46:22 -07:00
Ryan Fleury 7362f8ef60 always focus window on stop events; further watch view progress 2024-09-27 14:25:32 -07:00
Ryan Fleury cab01431be more watch view work 2024-09-27 13:41:17 -07:00
Ryan Fleury 771883c56c another checkpoint in fixing up the watch window for replacing targets/scheduler/etc 2024-09-27 13:15:10 -07:00
Ryan Fleury b6b188b67b begin work on full targets view replacement in new watch / eval viz systems 2024-09-27 11:02:37 -07:00
Ryan Fleury ecaa2c55c0 eliminate all old eval visualization block/row code 2024-09-27 10:29:55 -07:00
Ryan Fleury 45226e8a81 begin eliminating old block/row code in eval visualization 2024-09-27 10:26:30 -07:00
Ryan Fleury 0073b2b045 fix correct application of top-level view rules in block tree build 2024-09-27 10:12:44 -07:00
Ryan Fleury 3d781f847e fix expansion rule picking 2024-09-27 10:08:49 -07:00
Ryan Fleury 4b7e6d7113 fixes for variable size rows in new eval visualization structures / integration 2024-09-27 10:04:56 -07:00
Ryan Fleury 3fa98eb0e7 begin moving all visualizer view rules to new eval visualization block system 2024-09-26 17:00:32 -07:00
Ryan Fleury 60f65d30e2 populate entity deletions more urgently in watch viiew 2024-09-26 16:24:47 -07:00
Ryan Fleury 007efe29eb fix incorrect multi-select deletion behavior 2024-09-26 16:21:45 -07:00
Ryan Fleury bbac451de4 fix a few small issues with insertion/deletion of new watch rows 2024-09-26 16:15:03 -07:00
Ryan Fleury 73c37b4d8b correct collection editing/deletion/reordering/etc. with new watch visualization system 2024-09-26 16:08:35 -07:00
Ryan Fleury 2fdfeec467 always keep collections in filtered watch views; add add-new-row capability to watch collection expansion & hook up with expansion ids 2024-09-26 15:36:22 -07:00
Ryan Fleury d314a12698 eliminate possibility for recursive watch window builds; correctly sort child expansion keys before iteration, if needed, for non-identity-based id schemes (debug info tables, frontend entities, etc.); further fixes & integration 2024-09-26 15:26:28 -07:00
Ryan Fleury 07f978ac41 further integration work & expanded support; generalized paths for entity reordering in watch views 2024-09-26 14:37:13 -07:00
Ryan Fleury 338fabd9d0 more block tree / eval visualization integration work with watch views 2024-09-26 13:13:30 -07:00
Ryan Fleury 715bd36965 fix table cursor snapping 2024-09-26 12:24:13 -07:00
Ryan Fleury 198246eb52 more integration work, of new block tree eval visualization structure w/ watch views 2024-09-26 12:05:01 -07:00
Ryan Fleury e705907ec0 checkpoint in moving existing watch views to new block-tree visualization structure 2024-09-26 08:09:22 -07:00
Ryan Fleury 2fb0eb0eb1 sketch out basic coordinate space conversions for new block tree / block range list structures; num -> key; key -> row; num -> containing block range; etc. 2024-09-25 16:53:54 -07:00
Ryan Fleury 48b10411bc eliminate old weld-together path for block tree walk & windowed row list build 2024-09-25 16:37:11 -07:00
Ryan Fleury d6f6ec83da unweld windowed row list generation from block tree walk; write new path which relies on caller-prepped block range list 2024-09-25 16:36:43 -07:00
Ryan Fleury df2bc62563 extend eval visualization view rule hooks to support view-rule-defined (id <-> number) mapping; used for id-based state keys, but an immediate-mode ordering (e.g. sorted/filtered debug info tables); can be used in the future for sorted types/arrays/etc., while preserving expansion/view rule state. also, pull out the block tree -> list(block*range) walk, since it is going to be useful in multiple places 2024-09-25 16:32:48 -07:00
Ryan Fleury f2ecb3d898 expand info & expansion range query hook implementation, for all currently supported view rules 2024-09-25 15:59:42 -07:00
Ryan Fleury a1ceb5fa3b on second thought... merging both view rule expansion *header* info generation, and windowed range queries into an expanded block, into the same hook, is really limiting & wrong - so split back to two hooks, one stage is just informing the expansion space, the next provides per-row information within an expanded block with range-based queries 2024-09-25 15:17:39 -07:00
Ryan Fleury a87c032305 fix a few details in new eval visualization block tree generation algorithm; fix row generation; start fitting new system into hover eval as a first test 2024-09-25 13:17:17 -07:00
Ryan Fleury 9c3d2cd5ab eval visualization: first pass of new tree-ified block building, which preserves the hierarchy of the eval visualization path, as well as relies on only a single view rule hook; first pass of windowed row list production, given that block tree build; also still just uses the single hook 2024-09-25 12:23:50 -07:00
Ryan Fleury c976154284 eval: add cache for type data member gathering & member lookup; eval_visualization: sketch out new hook organization which has single hook for both view rule expansion info, + expansion expr production, in a single combined path (the two often require the same information so it is maybe a good idea to combine them - if not, it will be easy to separate into two stages (expand + expr-child production), but basically just trying to get view rules out of 'block production', and more into just providing the information that actually varies per view rule 2024-09-25 09:34:23 -07:00
Ryan Fleury fcfd446c5e watch ui tweaks 2024-09-24 16:58:10 -07:00
Ryan Fleury d2c9fdcf0b notes 2024-09-24 13:27:59 -07:00
Ryan Fleury 2f9121171c eliminate dead code, after this pass 2024-09-24 13:24:23 -07:00
Ryan Fleury fbfaf1c747 strip out root buttons idea; fix up pretty member names 2024-09-24 11:06:31 -07:00
Ryan Fleury 64f763162f adjust font provider rasterization bounds to prevent off-by-one cutoffs 2024-09-24 07:23:44 -07:00
Ryan Fleury 629ddec458 begin sketching out watch-window-driven scheduler replacement 2024-09-23 17:41:26 -07:00
Ryan Fleury 5690a9e19b further enriching of codebase type info & eval type info to encode code-contents of pointers, pretty names for members; further progress on improving watch views to support all needed features for replacing all table uis 2024-09-23 16:45:18 -07:00
Ryan Fleury 508d11c8d8 further progress on targets view replacement; split collection views into several types 2024-09-23 16:06:01 -07:00
Ryan Fleury bfe6f655be more work on watch view to replace all old uis 2024-09-23 14:26:27 -07:00
Ryan Fleury f728614e0b eliminate watch view fill kind; extend rtti & eval type system with 'external' pointers, for e.g. meta-space vaddr u64s pointing into an address space; begin sketching out paths for mutational rows in watch collections, use to add 'add target' fastpath in targets collection evaluations 2024-09-23 10:57:43 -07:00
Ryan Fleury ebaad35813 fix filter passthrough & fix double-application of view rules in some cases 2024-09-20 17:19:13 -07:00
Ryan Fleury 8babd89f47 modules view, watch window style 2024-09-20 17:04:53 -07:00
Ryan Fleury 066f5f6cf2 add correct inheritance rules for oct, hex, dec, bin, only, omit view rules 2024-09-20 16:24:09 -07:00
Ryan Fleury c98db01b63 replace watch view fill kind with top-level expression & view rule; collection macro for watches; reintroduce only/omit, with new expr-macro-based eval visualization system; remove root-expression-generation from expansion block generation, since it makes things a bit more complicated 2024-09-20 16:15:29 -07:00
Ryan Fleury a1debd9219 targets, breakpoints, watch pins, etc. collections; fix . access on enum types; add more information to meta evaluations 2024-09-20 13:49:27 -07:00
Ryan Fleury 432e70caf6 begin sketching out 'collections', which are the formal mechanism in the eval/eval-viz systems for visualizing synthetic structures/arrays/trees produced by the debugger, rather than ad-hocing / hardwiring the correct ev-block production for each kind of view - the views can still stay, but this is an important feature for other cases 2024-09-20 12:04:13 -07:00
Ryan Fleury bbd86449d8 fix ghost auto-view-rule text visualization to calculate auto view rule from raw type expression rather than post-view-rule-applied one 2024-09-19 16:07:14 -07:00
Ryan Fleury 454764b9f6 set up auto view rule table in frontend thread; visualize auto-view-rules as ghosted text in watch views 2024-09-19 15:29:08 -07:00
Ryan Fleury 05ec402a8e make eval visualization system robust to absence of auto view rule table 2024-09-19 15:23:55 -07:00
Ryan Fleury df4d18aa5c sketch out type-based auto-view-rule in eval visualization system 2024-09-19 15:22:47 -07:00
Ryan Fleury cc61df0c7b lazily-evaluate meta evaluations on an as-needed basis - with callstacks in particular it is just too expensive to do all threads every frame up-front 2024-09-19 14:38:24 -07:00
Ryan Fleury 7bec50db75 type-info-table-driven pointer rebasing for meta evals; add callstack info to entity meta evals 2024-09-19 14:04:40 -07:00
Ryan Fleury 0e993c5e7a eliminate old ctx menu paths 2024-09-19 11:36:34 -07:00
Ryan Fleury 16ba8a98cf shift source ctx menu to universal ctx menu path 2024-09-19 11:33:23 -07:00
Ryan Fleury 1e8413797a shift tab ctx menu into universal ctx menu 2024-09-19 11:27:55 -07:00
Ryan Fleury ca8fdd1d6e progress on universal ctx menu 2024-09-19 11:22:08 -07:00
Ryan Fleury 714c736530 eliminate old manual serialization code for meta evals in ctrl msgs 2024-09-18 17:01:59 -07:00
Ryan Fleury 7c41fc11e0 fix up issues with user <-> ctrl thread communication 2024-09-18 16:21:22 -07:00
Ryan Fleury 546e6e695f eliminate ad-hoc meta eval info type tables; switch to base layer meta type info; do first pass of shifting serialization of meta evals to meta type info driven system 2024-09-18 15:57:01 -07:00
Ryan Fleury 7e5759ed03 finish first pass sketching out basic base-layer-defined codebase type info & serialization/deserialization path with basic pointer cases 2024-09-18 14:52:39 -07:00
Ryan Fleury 9ae3b2eb92 base layer defined type info tables experiment - can ideally be used as a more whole solution for the ctrl meta eval info stuff 2024-09-17 17:52:23 -07:00
Ryan Fleury 85a07be1ac generate meta tables for meta evaluations; use to table-drive ctrl msg serialization, deserialization, meta eval type info generation, and info <-> serialized eval path 2024-09-17 15:43:39 -07:00
Ryan Fleury 3de6331a8e notes for 0.9.12 2024-09-17 14:17:04 -07:00
Ryan Fleury 487637aaaa fix while-loading command processing in text views 2024-09-17 14:05:40 -07:00
Ryan Fleury e825c0f5b5 keep 64mb reserve size default if possible with large pages enabling 2024-09-17 13:46:11 -07:00
Ryan Fleury 5dd89f350d --large_pages option; allow dynamic override of arena defaults 2024-09-17 13:41:56 -07:00
Ryan Fleury 4d41c32586 plug in fuzzy searching system to autocompletion lister; can now autocomplete procedures, types, globals in watch window 2024-09-17 11:52:33 -07:00
Ryan Fleury a368d04e3b checkpoint on new universal drag/drop stuff 2024-09-17 11:26:13 -07:00
Ryan Fleury ca9ee9a658 checkpoint in new universal regs-based rich hover / context menu / drag-drop systems 2024-09-17 11:05:43 -07:00
Ryan Fleury 8ce7626099 fix run-to-line & run-to-address (was accidentally zeroing extra_bps) 2024-09-16 18:09:19 -07:00
Ryan Fleury d66703a044 filter commands in views by view rather than window/panel 2024-09-16 17:57:48 -07:00
Ryan Fleury fa64116048 notes 2024-09-16 17:54:53 -07:00
Ryan Fleury cff6222863 additional small fixes 2024-09-16 17:48:39 -07:00
Ryan Fleury 515724f264 small fixes 2024-09-16 17:43:38 -07:00
Ryan Fleury a7ca8dd0a0 sketch out thread color events & client-driven thread color state, plug thread colors back into ui 2024-09-16 17:37:50 -07:00
Ryan Fleury 35659a4525 checkpoint on new drag/drop system; eliminate old drag/drop payload, just use regs like everything else 2024-09-16 17:25:21 -07:00
Ryan Fleury 4b382777e9 fix debug engine incorrectly using visual run state to soft halt, when ctrl thread did not necessarily report it was running; was leading to 'phantom halts'; other small fixes, dead code elimination, and begin sketching out proper cross-window drag/drop 2024-09-16 17:09:41 -07:00
Ryan Fleury 3cf27169b6 fix view snapping in frame selection & disasm 2024-09-16 16:25:02 -07:00
Ryan Fleury ba647a0b1d fix open-tab path; fix pending-file setup 2024-09-16 16:13:40 -07:00
Ryan Fleury 2f86e289a4 get all view code off of explicit view parameterization; merge row value cell ui hook with regular view ui hook 2024-09-16 15:59:01 -07:00
Ryan Fleury 9899efe93c merge view rules & view specs entirely; simplify graphical view rules down to single hook 2024-09-16 14:44:28 -07:00
Ryan Fleury 84f685803d fix set-space ir extension instruction; expand ctrlbits to u16, so that it can encode modern register sized decodes 2024-09-16 11:59:06 -07:00
Ryan Fleury c00fede4f1 fill out meta eval info system in frontend; get eval back up and running 2024-09-16 11:51:55 -07:00
Ryan Fleury adc9e0e512 begin sketching out meta eval info, to allow for debugger meta evaluations on both ctrl thread & on ui thread - e.g. breakpoint hit count evaluation in conditional bps 2024-09-16 10:36:22 -07:00
Ryan Fleury 17d062934e dead code elimination 2024-09-16 10:13:28 -07:00
Ryan Fleury e8c8df9c6e eliminate setup hook for views 2024-09-16 09:53:24 -07:00
Ryan Fleury 23a5c9eb44 eliminate view cmds hook; just use ui hook 2024-09-16 09:45:54 -07:00
Ryan Fleury 3c262fccf3 adjust top-level rd_frame structure to allow N cycles (rather than 1) of [rd cmds], [d tick] per frame; fix a few ctrl thread driving issues in dbg engine 2024-09-15 12:46:03 -07:00
Ryan Fleury 114ebfa27b adjust raddbg command queue to have two phases; first phase, r/w, core gets chance to push extra commands & consume them immediately same-frame; views get second phase, read-only, where they can consume all commands, but when they push new commands, those are distributed back at the top of the chain, where the core gets first chance 2024-09-15 09:47:37 -07:00
Ryan Fleury 7a1811fb71 begin eliminating setup hook for views 2024-09-14 08:12:26 -07:00
Ryan Fleury f396a88bac mdesk layer extensions for mutable tree manipulations 2024-09-13 17:16:42 -07:00
Ryan Fleury 4b526db0dd organization pass & straightening some things out before entity simplification/replacement 2024-09-13 16:12:55 -07:00
Ryan Fleury 8ffc9f4a9b more progress on entity simplification; df -> rd; eliminate dbg_frontend distinction from raddbg layer 2024-09-13 15:55:58 -07:00
Ryan Fleury 48ae9b6973 move rest of cfg-related stuff into frontend 2024-09-13 14:51:07 -07:00
Ryan Fleury 793ad8fe1e new view rule table definition in df, merging graphical view rules & views totally 2024-09-13 13:39:40 -07:00
Ryan Fleury 7cd1d175de deduplicate string escaping paths in eval/cfg/etc 2024-09-13 12:08:22 -07:00
Ryan Fleury 306f8d84c5 remainder of entity code -> df; exception code filters -> df 2024-09-13 11:59:46 -07:00
Ryan Fleury 573bad8487 entity from d -> df 2024-09-13 11:46:17 -07:00
Ryan Fleury 9b66a9c60e fix df/ctrl kind mismatch 2024-09-13 11:26:53 -07:00
Ryan Fleury 96b5f82964 run-to-line/address porting from old df_entity-based behavior 2024-09-13 11:21:13 -07:00
Ryan Fleury 6b758f08fa eliminate dead code; port breakpoint hit counting to frontend; begin floating entity code into frontend, prepping for simplification/replacement 2024-09-13 10:48:40 -07:00
Ryan Fleury 7fb711b07c eliminate more dead code 2024-09-13 10:41:42 -07:00
Ryan Fleury c8a892ad8f eliminate d_entity-based module mapping code; all of this is done via ctrl systems now 2024-09-13 10:39:32 -07:00
Ryan Fleury f9c541ea7b eliminate regs concept from engine; eliminate more d_entity mirroring ctrl_entity 2024-09-13 10:26:34 -07:00
Ryan Fleury 2dfa3dae42 snap-to-thread if none selected in frontend; fix soft halt logic to match old logic; fix ctrl entity store alloc gen on release 2024-09-12 17:10:39 -07:00
Ryan Fleury f13806b19f another checkpoint in moving previously engine-controlled behavior to frontend, and getting engine completely off d_entities 2024-09-12 16:51:48 -07:00
Ryan Fleury 71cb03f3be checkpoint in getting off of d_entities and onto ctrl_entities for frontend paths, including thread selection & df_regs 2024-09-12 16:30:26 -07:00
Ryan Fleury 3641c212b2 begin floating thread/frame selection mechanisms into frontend and out of engine 2024-09-12 14:58:48 -07:00
Ryan Fleury 638140ab87 another checkpoint, moving d_regs -> df_regs; eliminating more state & responsibilities from dbg_engine 2024-09-12 14:10:41 -07:00
Ryan Fleury 65ed1f0997 another checkpoint - eliminate cmd specs from engine, move all dynamic command definition things into frontend 2024-09-12 12:11:00 -07:00
Ryan Fleury 472e73137d checkpoint 2024-09-11 18:25:48 -07:00
Ryan Fleury 2f299e087a fix busted stepping mechanism 2024-09-11 17:44:30 -07:00
Ryan Fleury c8efacf707 split engine from frontend cmd structure; use to begin fixing/hardening engine commands and decoupling them from frontend complications 2024-09-11 17:42:34 -07:00
Ryan Fleury deef05d0d2 extend eval space size to allow u128 key for hash store & related cache keys, + some extra metadata determined by user (user-defined kind & extra u64) 2024-09-11 17:11:33 -07:00
Ryan Fleury 26fb91d539 fix top-level frontend exit logic; eliminate path -> entity code, since we are totally off filesystem entities 2024-09-11 16:25:02 -07:00
Ryan Fleury f59694fcfb float cfg from engine -> frontend; more elimination of dead code in engine 2024-09-11 15:40:11 -07:00
Ryan Fleury f4726eee0a eliminate old eval viz code in engine 2024-09-11 15:22:51 -07:00
Ryan Fleury cc2b5138b0 more dead code elimination & simplification & floating from engine -> frontend 2024-09-11 15:04:12 -07:00
Ryan Fleury e7b4912e4a eliminate more dead code in engine 2024-09-11 14:35:30 -07:00
Ryan Fleury af5825c89a move interaction register stack into frontend layer 2024-09-11 14:24:16 -07:00
Ryan Fleury be6458690f ctrl layer defined handle system, to replace machine-id/demon-handle pairs used everywhere by users 2024-09-11 14:01:38 -07:00
Ryan Fleury e6872cb71e eliminate all old debug engine eval visualization code; we're now moved over to the new more standalone eval viz codebase layer 2024-09-10 17:22:24 -07:00
Ryan Fleury 20aba085cd oops 2024-09-10 17:14:10 -07:00
Ryan Fleury 299ea04539 port debugger frontend to using eval visualization layer, over old debug engine code 2024-09-10 17:10:48 -07:00
Ryan Fleury bb50e88141 eval_visualization layer: builtin view rules, porting of more debug engine code over 2024-09-10 16:14:11 -07:00
Ryan Fleury e989da4087 float down dbg engine eval visualization stuff into formal codebase layer which just builds on top of eval 2024-09-10 15:46:05 -07:00
Ryan Fleury d3bf9cbb53 eliminate now-unnecessary config writing mechanism 2024-09-10 14:11:54 -07:00
Ryan Fleury d35bc56f8f further coalesce all frontend command processing into top-level frame path; have frontend commands for all possible engine commands 2024-09-10 14:01:06 -07:00
Ryan Fleury 9e7ce6a6c7 do not bake in this parameters in static methods 2024-09-10 13:51:59 -07:00
Ryan Fleury 09db3aacd0 formally split dbg engine/frontend commands; float entity operations & all ui-related operations up to frontend layer, keep engine to small set of control operations (we are trying to get the engine out of the mix in managing entity state) 2024-09-10 11:37:01 -07:00
Ryan Fleury 6534bff5d0 eliminate state delta history experiment codef 2024-09-10 07:24:33 -07:00
Ryan Fleury baaa853c7f dead code & unnecessary helper elimination 2024-09-08 16:49:27 -07:00
Ryan Fleury 8831781af4 reorder top-level frame structure; frontend gets chance first 2024-09-08 14:28:06 -07:00
Ryan Fleury dfe0c17b89 oops; fix incorrect usage of thread instead of process entity 2024-09-08 13:16:57 -07:00
Ryan Fleury 6cf0c7ee92 promote thread freeze state to ctrl entity tree; communicate via msgs for user -> ctrl, and communicate entity state changes back via events for ctrl -> user 2024-09-08 13:09:52 -07:00
Ryan Fleury fee500578a get trap net generation off of d_entities and onto ctrl entities; decouple debug engine stepping/running from d_entities 2024-09-08 10:50:00 -07:00
Ryan Fleury 43b83b56f1 float eval system preparation to frontend & out of engine 2024-09-08 10:30:05 -07:00
Ryan Fleury 9b95e60894 feed flattened breakpoints into ctrl message instead of entities 2024-09-08 10:26:14 -07:00
Ryan Fleury 2272b4a14c eliminate d_ctrl_run helper intermediate; switch to using simplified passdown types for breakpoints, rather than entities, in ctrl run parameterization 2024-09-08 10:23:32 -07:00
Ryan Fleury 6b172396f5 eliminate messages - too early for that change; eliminate many usage sites of d_ctrl_run; focus all ctrl thread driving code into one spot 2024-09-08 10:12:10 -07:00
Ryan Fleury 2cc81baffa sketch out simplified input types for engine; port over animation cache from reverted changes 2024-09-08 09:44:39 -07:00
Ryan Fleury a204018e94 Revert "checkpoint on pass to majorly simplify debug frontend state, and eliminate df entities, and move from cmds -> msgs"
This reverts commit 06a685221a.
2024-09-07 14:50:27 -07:00
Ryan Fleury 3ed8f4af98 Revert "begin sketching out live cfg mutation code, as replacement for frontend entity tree formation/mutation"
This reverts commit c8c9c7ea27.
2024-09-07 14:48:47 -07:00
Ryan Fleury 5ffab0439b Revert "more msgs -> cmds & df entity elimination progress"
This reverts commit 9968c6e491.
2024-09-07 14:48:42 -07:00
Ryan Fleury cccbd265ff Revert "another checkpoint in big df entity elimination pass"
This reverts commit f8fd32e328.
2024-09-07 14:48:34 -07:00
Ryan Fleury 6180da1b0f Revert "yet another checkpoint"
This reverts commit 5ad8d523ba.
2024-09-07 14:48:29 -07:00
Ryan Fleury 30766f93ae Revert "checkpoint"
This reverts commit 3631de648b.
2024-09-07 14:48:21 -07:00
Ryan Fleury 3631de648b checkpoint 2024-09-07 13:37:35 -07:00
Ryan Fleury 5ad8d523ba yet another checkpoint 2024-09-05 19:19:00 -07:00
Ryan Fleury f8fd32e328 another checkpoint in big df entity elimination pass 2024-09-04 15:50:59 -07:00
Ryan Fleury 9968c6e491 more msgs -> cmds & df entity elimination progress 2024-09-03 16:50:16 -07:00
Ryan Fleury c8c9c7ea27 begin sketching out live cfg mutation code, as replacement for frontend entity tree formation/mutation 2024-09-03 15:20:04 -07:00
Ryan Fleury 06a685221a checkpoint on pass to majorly simplify debug frontend state, and eliminate df entities, and move from cmds -> msgs 2024-09-03 12:46:30 -07:00
Ryan Fleury 6b02c8a7d6 more progress on converting cmds codepaths -> msgs codepaths 2024-09-01 16:20:26 -07:00
Ryan Fleury 06f65857db more progress in df cmds -> msgs 2024-09-01 15:49:06 -07:00
Ryan Fleury 6ead03ac17 strip out update/render/repaint window cruft; promote layer per-tick APIs to base layer 2024-09-01 09:00:58 -07:00
Ryan Fleury 98840c73d8 finish initial pass over df msgs 2024-09-01 08:39:18 -07:00
Ryan Fleury 45d3702c5b further progress on cmds -> msgs in debug frontend 2024-08-31 09:02:42 -07:00
Ryan Fleury 2696c96f75 continue coalescing df frame 2024-08-31 07:36:53 -07:00
Ryan Fleury 7645d00392 eliminate more cruft in engine/frontend layers; sketch out new frontend msg processing loop 2024-08-30 18:08:29 -07:00
Ryan Fleury 7004994b25 sketch out msg processing loop, to replace cmd processing loop, in dbg engine 2024-08-30 17:52:45 -07:00
Ryan Fleury 8770a43678 set up scaffolding for dbg engine/frontendm sgs 2024-08-30 15:24:35 -07:00
Ryan Fleury 533fd0041f begin flattening d/df tick paths 2024-08-30 14:10:12 -07:00
Ryan Fleury 2ceff4293f begin eliminating begin/end frame concept in debug engine, and moving to single debug engine tick 2024-08-30 12:24:47 -07:00
Ryan Fleury 13f2de6e88 d regs -> mdesk 2024-08-30 10:07:56 -07:00
Ryan Fleury ecf9cd1dab fix markup vsnprintf fwd declare warning 2024-08-30 09:33:54 -07:00
Ryan Fleury b0d10d457e notes 2024-08-29 17:14:50 -07:00
Ryan Fleury e1806d2d61 notes 2024-08-29 17:02:26 -07:00
Ryan Fleury facf0dafe6 move remaining per-window cmds to top-level 2024-08-29 16:29:10 -07:00
Ryan Fleury 37f771ae9b begin moving all frontend command processing into top-level layer, rather than doing it per-window 2024-08-29 16:24:15 -07:00
Ryan Fleury 84bc078e9f watch commands -> core layer 2024-08-29 15:54:10 -07:00
Ryan Fleury df777a4c07 eliminate old code slice cruft 2024-08-29 13:39:53 -07:00
Ryan Fleury e81fbe4bf2 eliminate old code; organization pass over dbg frontend 2024-08-29 13:37:28 -07:00
Ryan Fleury 9932a30ef9 entity parameter tree equipment; architecture -> arch 2024-08-29 13:16:50 -07:00
Ryan Fleury df6150c811 always produce inheritance child cfg tables for each viz block 2024-08-29 12:48:54 -07:00
Ryan Fleury 719c453bfc eliminate old type 2024-08-29 11:57:57 -07:00
Ryan Fleury 0f4d2cfbc1 entity name -> string 2024-08-29 11:48:55 -07:00
Ryan Fleury bb553b4ec0 eliminate manual notification of entity / panel mutations for soft halts & config changes; just compute a hash of all run parameterization state every time you run, and every frame, and if they change, soft halt refresh 2024-08-29 11:34:29 -07:00
Ryan Fleury 9bba4f224c ctrl flow analysis -> dasm layer 2024-08-29 10:58:16 -07:00
Ryan Fleury 5907783a2e d_interact_regs -> d_regs 2024-08-29 10:54:54 -07:00
Ryan Fleury 4944652331 introduce debug engine entity kinds for windows/panels/tabs, to begin process of formally moving all view parameterizations to watch entities; eliminate redundant passthrough of window/panel parameters 2024-08-29 10:49:35 -07:00
Ryan Fleury e9304b5eff parameter tree editing in tab right-click menu 2024-08-28 17:54:49 -07:00
Ryan Fleury 61a264e20c fix empty language option in autocompletion lister 2024-08-28 17:22:27 -07:00
Ryan Fleury 4439aab721 split more frontend-only information from debug engine core definitions 2024-08-28 17:14:59 -07:00
Ryan Fleury 1c62787758 dbg_gfx -> dbg_frontend; fix force-confirm commands; more naming passes 2024-08-28 16:59:21 -07:00
Ryan Fleury 269abf661f switch to simplified debug engine command interface; rely on interact registers, rather than explicit pass-down, for contextually-obvious parameters 2024-08-28 16:47:05 -07:00
Ryan Fleury e3dc29d7ae push_cmd__root -> push_cmd 2024-08-28 15:37:55 -07:00
Ryan Fleury cb25e261e4 eliminate all cmd param slot marking 2024-08-28 15:37:03 -07:00
Ryan Fleury 818c5a9160 eliminate dependence on 'command parameter slots' 2024-08-28 15:34:46 -07:00
Ryan Fleury c60809f02b df -> dbg_engine and dbg_gfx layers; df (core) -> d 2024-08-28 15:16:55 -07:00
Ryan Fleury ca4b602b28 f -> fnt 2024-08-28 13:45:54 -07:00
Ryan Fleury 83542d4010 re-slice views code; begin prepping for view rules / views being organized together 2024-08-28 13:38:49 -07:00
Ryan Fleury 01236ca3b9 make all view, core view rule, and gfx view rule names completely consistent, use the name as the unique key among all tables 2024-08-28 13:11:00 -07:00
Ryan Fleury 31810bb221 fix incorrect lifetime of cfg table trees 2024-08-28 12:01:19 -07:00
Ryan Fleury 22c4336375 finish trimming old view rule code; get 3d geometry viewer back in good shape and integrated as a full view 2024-08-28 11:36:44 -07:00
Ryan Fleury 5ff9e47f8a fix loading in transient views 2024-08-27 17:18:42 -07:00
Ryan Fleury d956f7a266 view rule table notes 2024-08-27 16:46:19 -07:00
Ryan Fleury 0c2502c89f partway through fixing regressions of color view rule 2024-08-27 16:35:15 -07:00
Ryan Fleury be93968c8d fix incorrect resource kind string table; fix incorrect usage of resource kind table when doing texture format lookups in bitmap view 2024-08-27 15:48:27 -07:00
Ryan Fleury 32ac4f10bb support loading overlay in transient views; fix incorrect transient view state caching when view parameters change 2024-08-27 15:23:19 -07:00
Ryan Fleury 59360f770c file drop support 2024-08-27 14:49:57 -07:00
Ryan Fleury 32fcc6d34c expand pending file view to actually analyze files a bit before picking appropriate viewer; for now just do code if text, memory if not 2024-08-27 14:27:14 -07:00
Ryan Fleury 645db07493 add memory view rule; adjust memory view to appropriately use eval parameterizations, so that it can be used as a view rule correctly 2024-08-27 13:47:38 -07:00
Ryan Fleury 4b75145ec0 only consider non-queried disassembly views in general-purpose find-code-locationp ath 2024-08-27 13:08:32 -07:00
Ryan Fleury e59e014b2b shift disassembly view to being usable as a view rule too; arbitrary disassembly view parameterization 2024-08-27 13:00:21 -07:00
Ryan Fleury 08652e8b0a cast view rule 2024-08-27 11:46:54 -07:00
Ryan Fleury 511e81b188 eliminate eval resolution stage; we can just use expr resolution stage for everything 2024-08-27 11:39:46 -07:00
Ryan Fleury 90273e7a2e bswap view rule 2024-08-27 11:37:27 -07:00
Ryan Fleury cf7b664ab2 bswap expression & ir 2024-08-27 11:35:45 -07:00
Ryan Fleury accc77e03e eliminate type resolution eval viz stage (can just be done via the expr resolution stage, which is more powerful); fix elements expansion for non-pointers 2024-08-27 11:17:05 -07:00
Ryan Fleury 5b29f0db47 new expr resolution eval visualization stage; use to implement array & slice view rules 2024-08-27 11:04:22 -07:00
Ryan Fleury a97c8bd070 fix new param tree generation; stop string viz for padding members; fix relative file path serialization in new cfg saving path 2024-08-27 09:13:28 -07:00
Ryan Fleury 6a8c110b83 remove old cursor/mark decls 2024-08-26 16:15:28 -07:00
Ryan Fleury c97c351508 move cursor/mark state out of being hardcoded in view, and into param tree 2024-08-26 16:13:50 -07:00
Ryan Fleury 567aea2b15 new view serialized/deserialized params storage 2024-08-26 15:55:12 -07:00
Ryan Fleury 895c4dd199 fix press detection in watch view canvases 2024-08-26 15:16:23 -07:00
Ryan Fleury 3691b59af3 set up system for per-view param tree mutations; fix duplicate param key serialization 2024-08-26 15:13:53 -07:00
Ryan Fleury ec16f59a1e fix incorrect usage of new ui events pump 2024-08-26 14:34:24 -07:00
Ryan Fleury c16e21db71 eliminate dead code 2024-08-26 14:27:51 -07:00
Ryan Fleury 1de57557b5 get off cfg node duplicates of mdesk trees; use md trees for params consistently across view rules, tabs, etc. 2024-08-26 14:26:23 -07:00
Ryan Fleury aed18eb71c eliminate string-from-state function for view specs - we will be doing everything via the cfg tree; clean up & fix view titles for all of the different visualizer circumstances; do general path for serializing cfg trees for each view 2024-08-26 11:26:34 -07:00
Ryan Fleury 14f617db85 begin eliminating separate hook system for view rule uis; shift over to regular views, so there is just one codepath for all visualizers; move ui to event pump system, with permissions stack, so that callers of sub-ui-codepaths can mask off event consumption as needed 2024-08-26 09:56:47 -07:00
Ryan Fleury 74471e4b8d fix tab title rules; fix watch keyboard navigation with new dynamic columns 2024-08-26 06:12:42 -07:00
Ryan Fleury 43eac9f332 add entity labels to macro map 2024-08-23 16:28:09 -07:00
Ryan Fleury 729a4aa1f9 first step to collapsing separate view parameterization path, and just having views be parameterized by evaluation strings 2024-08-23 16:17:19 -07:00
Ryan Fleury e395ef42a1 eval system syntax for opaque id evaluations 2024-08-23 14:45:48 -07:00
Ryan Fleury 8ae8e2f943 extend file streaming cache to support range-based file stream queries; begin plugging in file stream queries as alternative to ctrl stream queries; further bugfixes & unification in eval system 2024-08-23 12:29:52 -07:00
Ryan Fleury ff922fa087 fix expandability/block/row building for block ui view rules 2024-08-22 17:11:12 -07:00
Ryan Fleury 47462f4789 first pass at filesystem evaluation in eval system 2024-08-22 16:55:07 -07:00
Ryan Fleury 341f9c6cf7 introduce resolution qualifiers to evaluation syntax, to specifically denote resolution to registers, locals, types, etc., or file paths 2024-08-22 15:56:43 -07:00
Ryan Fleury b7cc2e8d93 entity evaluation committing; checkbox view rule; per-column view rules in watch views 2024-08-22 15:28:13 -07:00
Ryan Fleury acd7435553 collapse register mode into being a thread space, unify process/thread/debugger read/write paths, keep differences in core eval read/write paths 2024-08-22 14:50:27 -07:00
Ryan Fleury a7cf64d5e2 extend watch view column parameterization; further progress on replacing entity views with watch views 2024-08-22 12:01:53 -07:00
Ryan Fleury 1848acd47e eliminate eval assumption of single architecture; equip each eval module with an architecture; use to correctly specify the debugger process architecture; do initial pass of debugger space evaluation 2024-08-21 12:55:50 -07:00
Ryan Fleury 1ec62b40ae reverse decision to show inheritance type prefix in member names, because I forgot that C++ STL / other codebase types are completely insane; go back to showing inheritance info as a tooltip 2024-08-21 11:24:52 -07:00
Ryan Fleury 70fa90bb87 fix incorrect os_window_first_paint rules 2024-08-20 17:07:59 -07:00
Ryan Fleury c77d61fb4c ellipses for unfinished arrays/structs in eval single-line visualization 2024-08-20 16:33:08 -07:00
Ryan Fleury 4611ddb536 eval value array indexing; type-only evaluation of array indexing and member accesses; various fixes 2024-08-20 16:13:01 -07:00
Ryan Fleury 156a94b286 string/char literal escaping in eval 2024-08-20 14:57:23 -07:00
Ryan Fleury b5b6f61811 fix various edge cases in visualizer paths 2024-08-20 14:48:25 -07:00
Ryan Fleury 67a719f2c6 fix parse error visualization; fix invalid cases in eval expression parser 2024-08-20 14:12:40 -07:00
Ryan Fleury c896d05afc relocate entity; fix incorrect eval mode for procedures view; fix incorrect evaluation of callstack frames in new callstack view 2024-08-20 13:53:54 -07:00
Ryan Fleury b44a5db97f further progress on cleaned up eval watch system; visual fixes/improvements in hover eval 2024-08-20 13:41:36 -07:00
Ryan Fleury 408b689245 eliminate old eval/eval-viz paths 2024-08-20 12:06:02 -07:00
Ryan Fleury 639239d758 convert all eval visualization paths to incrementally building expression trees, rather than using final eval bundles; ensure all evaluation paths, in various circumstances (single line viz, row viz), go through exactly the same path; deduplicate single-row-expr evaluation paths 2024-08-20 12:04:23 -07:00
Ryan Fleury be2daf570a checkpoint on eval / eval-viz simplification pass 2024-08-19 11:26:28 -07:00
Ryan Fleury 9f593f9971 callstack frame selection in watch views 2024-08-16 16:17:50 -07:00
Ryan Fleury 04b38eb405 more progress on new expanded watch path; mostly feature convergent for procedures & callstack 2024-08-16 15:28:16 -07:00
Ryan Fleury 2d1adaf932 watch view feature parity for error visualization 2024-08-16 13:00:02 -07:00
Ryan Fleury d749a5e965 progress on single path for building all cells in watch window, reaching feature parity with old watch windows 2024-08-16 12:49:35 -07:00
Ryan Fleury 25f30f6a72 begin pass to make watch view columns dynamic; will use to specialize watch views for the new expanded set of purposes it has 2024-08-16 11:49:10 -07:00
Ryan Fleury 6bdaf9b4df plug watch pins into new watch-driven ui 2024-08-15 15:12:58 -07:00
Ryan Fleury 82fcc9ed4d evaluate breakpoints in per-breakpoint space, rather than a top-level space for all of the debugger entities 2024-08-15 14:57:16 -07:00
Ryan Fleury 01cf3d39f1 further progress on using the upgraded eval system; sketch out replacement breakpoints & callstack views, which are just specializations of watch window 2024-08-15 14:34:47 -07:00
Ryan Fleury 8b5be64507 fix primary module selection in multi-process scenarios 2024-08-15 12:23:08 -07:00
Ryan Fleury 20bde07c46 fix ir generation for set-space opcode 2024-08-15 12:16:00 -07:00
Ryan Fleury b98a75e056 switch eval memory reads -> more generalized space reads; apply to register reads as well 2024-08-15 11:55:22 -07:00
Ryan Fleury 59c01a73af pipe through space information through eval compiler/interpreter 2024-08-15 11:21:52 -07:00
Ryan Fleury a0d91862a7 bundle per-module info in eval system; use all modules in all processes in ctrl layer evaluations; further sketching out of space info 2024-08-15 10:04:52 -07:00
Ryan Fleury ed75b253f7 notes on 'eval space'; first step to evaluating debugger-space things 2024-08-14 16:26:47 -07:00
Ryan Fleury 857bf44001 converge watch pin / breakpoint commands & mapping, without file entity structure 2024-08-14 15:41:18 -07:00
Ryan Fleury 94791e62ff eliminate old serialization/deserialization paths 2024-08-14 15:27:36 -07:00
Ryan Fleury 52f4474cc8 legacy config exe key for targets 2024-08-14 15:27:01 -07:00
Ryan Fleury 4a2aaf650a add legacy config deserialization paths, for old config files 2024-08-14 15:25:11 -07:00
Ryan Fleury bb9e5057d7 fix go-to-location path to adjust for no file entities; write single deserialization path for all entities, instead of handwritten special casedo nes 2024-08-14 15:08:48 -07:00
Ryan Fleury 33fe9ba485 formally support hresult codes as distinct from handles in debug info & visualization 2024-08-14 13:48:09 -07:00
Ryan Fleury a9f4a11c0a fix run-to-line and run-to-address for new breakpoint entity setup 2024-08-14 12:39:34 -07:00
Ryan Fleury afdb0e5b2e remove addr-mode assumption for string visualizing; eliminate entity deleted flag 2024-08-14 12:26:53 -07:00
Ryan Fleury 728120690d ptr/array-value comparison path in eval 2024-08-14 11:29:45 -07:00
Ryan Fleury 918895c091 small string evaluation; strings as values in eval 2024-08-14 10:49:56 -07:00
Ryan Fleury eac1672c4e begin sketching out eval paths for small string operations 2024-08-13 16:16:55 -07:00
Ryan Fleury 07c4e6ee87 evaluation compiler debug tooltip visualizer 2024-08-13 15:41:01 -07:00
Ryan Fleury c64d207d4d finish sketching out complex synthetic type construction; tear out unneeded leaf external evaluation (we can just use the macro map & separate address spaces); sketch out scaffolding for a thread evaluation type 2024-08-13 13:40:14 -07:00
Ryan Fleury a1605acb7b correct procedural struct/union byte size calculation in eval types 2024-08-13 13:07:13 -07:00
Ryan Fleury 0eff5aca06 extend constructed types in eval system to support procedural construction of structs/unions/enums; can be used for synthetic evals in debugger frontend & ctrl layer 2024-08-13 13:04:05 -07:00
Ryan Fleury 6d30455e76 further progress on eliminating file entities; further entity simplification; set up external identifier resolution map for evaluating 'meta' variables; sketch out generalized entity serialization path 2024-08-13 11:39:25 -07:00
Ryan Fleury 057d4d485e begin entity simplification pass; begin eliminating frontend file system entity cache; build new path-based file override systems, instead of relying on the entity tree 2024-08-12 17:06:59 -07:00
Ryan Fleury 86f45ce5e7 do not assume valid identifier maps if location info is not present 2024-08-12 09:26:44 -07:00
Ryan Fleury 77edf0d8da further progress on undo 2024-08-09 12:11:14 -07:00
Ryan Fleury e506d8389c strip out old undo/redo scaffolding 2024-08-09 10:19:29 -07:00
Ryan Fleury a541ca50d9 rdi_from_pdb: robustify to malformed/unexpected pdb characteristics; df: display errors with inline code better; eval: fix incorrect assumption of addr mode being required for member access operators 2024-08-09 09:27:18 -07:00
Ryan Fleury eda3d6f8b5 fix incorrect assumption of 0 slot -> primary rdi; fixes mistyped locals 2024-08-08 15:56:38 -07:00
Ryan Fleury 896f84369b ues correct unwound registers for eval context 2024-08-08 15:32:18 -07:00
Ryan Fleury 18237a1464 eliminate old architecture info tables 2024-08-07 16:48:20 -07:00
Ryan Fleury 6563cb9e2c split command lister-omission to being either included in ui lists, and included in lower level ipc driving documentation 2024-08-07 15:17:27 -07:00
Ryan Fleury 6a886e096e fix ternary operators in eval; fix incorrect oplist concatentation path 2024-08-07 13:10:41 -07:00
Ryan Fleury 607442b92a fix member lookup rules in new eval ir tree builder 2024-08-07 08:22:22 -07:00
Ryan Fleury fee31daa55 fix system processes lister 2024-08-06 15:08:41 -07:00
Ryan Fleury 44fb75228a fix incorrect symbol name font in symbol lister tooltips 2024-08-06 14:12:18 -07:00
Ryan Fleury ba095129e6 fix incorrect index space usage in debug-info-wide tables 2024-08-06 14:05:39 -07:00
Ryan Fleury a4978e75a3 eliminate separate helper for eval viz block list building 2024-08-06 14:01:30 -07:00
Ryan Fleury 5a682e5888 split eval systems, to decouple types/exprs/parsing (debug info dependent), from irization (macro map dependent), from interpretation (completely independent of the former two stages & all their dependencies) 2024-08-06 13:57:48 -07:00
Ryan Fleury c1cea82ae7 eliminate old eval/type-graph layers 2024-08-06 10:20:37 -07:00
Ryan Fleury e951d788ed fix watch window snap to cursor; begin introducing string literals into eval 2024-08-06 10:19:10 -07:00
Ryan Fleury 615a05e423 fix watch window snap-to-cursor rules; fix eval path for command parameter filling 2024-08-06 09:22:03 -07:00
Ryan Fleury 24d398e3c0 fix resolution to address value in array case; reintroduce macro map building (but this time it is frontend-wide rather than locked to a watch window) 2024-08-06 08:58:30 -07:00
Ryan Fleury 26f75fe7c1 shift watch view expressions from being a watch view implementation detail to being a top-level entity 2024-08-06 08:39:52 -07:00
Ryan Fleury 784a77bdff be a bit more forgiving in eval interpreter, to allow for graceful type (and thus empty bytecode) evaluation 2024-08-06 07:15:03 -07:00
Ryan Fleury ebaf83172f eliminate mid-frame calls into full update step via os_window_first_paint; pull up outside regular frontend frame boundaries; fixes incorrect per-frame dbgi scope usage 2024-08-06 07:07:44 -07:00
Ryan Fleury 3e6b8a3c66 first pass at converting frontend over to using new eval system 2024-08-05 17:05:43 -07:00
Ryan Fleury ba45dd161d complete eval2 first pass 2024-07-30 13:50:27 -07:00
Ryan Fleury d2c363ada2 eval2; ir tree compiler pass, type operations pass 2024-07-30 13:40:24 -07:00
Ryan Fleury 87b9b833d1 multi-module eval; new eval vm 2024-07-29 16:40:36 -07:00
Ryan Fleury ff90223dcb multi-module eval: type graph; eval parser 2024-07-29 16:23:13 -07:00
Ryan Fleury 3a61a0363b fix built exes to refer to their pdbs relatively, so that relocated builds can still locate pdbs relatively; eliminate old unused targets; simplify project.4coder 2024-07-29 11:38:15 -07:00
Ryan Fleury 6bef60b306 begin sketching out new eval layer upgrade, to support (a) many modules, (b) string operations, (c) many address spaces (?) 2024-07-26 16:56:21 -07:00
Ryan Fleury 23da2f8901 always serialize tab filters, if filtering is possible 2024-07-26 16:13:26 -07:00
Ryan Fleury 361be3f6e8 actually fix clang 2024-07-26 15:02:41 -07:00
Ryan Fleury f7dd96a5d1 fix clang 2024-07-26 14:58:17 -07:00
Ryan Fleury 333d9d9eb3 strip out unneeded info from df entities; raddbg_markup windows thread names 2024-07-26 14:52:11 -07:00
Ryan Fleury e80dc54aa7 fix inline frame snapping rules 2024-07-26 12:08:21 -07:00
Ryan Fleury 78d07b8d80 up-one-frame & down-one-frame commands for new rich unwind structure 2024-07-26 11:45:10 -07:00
Ryan Fleury e637ffa523 fix incorrect inline depth check 2024-07-26 11:24:08 -07:00
Ryan Fleury b18e437337 git normalize all files 2024-07-26 11:13:47 -07:00
Ryan Fleury c13833f74f fix line info voff baking; default selected inline frame depth to being shallowest; rework rich unwind to not lose concrete/inline frame structured info 2024-07-26 11:09:55 -07:00
Ryan Fleury 1d87c34dca fix big growth path in arena; make rdi parse code slightly more robust to malformed rdis 2024-07-26 08:37:13 -07:00
Ryan Fleury 1f89d4de9e do not overly-ambitiously hold debug info access scopes in ctrl thread run loop 2024-07-25 10:40:35 -07:00
Ryan Fleury b555655f3a fix incorrect chain size computation in new arena push implementation 2024-07-25 10:33:40 -07:00
Ryan Fleury e48baf9666 begin some work on extending rich hovering; working towards correllating rich hover info from everywhere, to everywhere; memory view <-> source view <-> bitmap viewer <-> watch window <-> etc. 2024-07-23 17:15:00 -07:00
Ryan Fleury ccf8504dd1 switch ctrl flow analysis etc. to zydis from udis86; unify disassembling path in dasm_cache layer, use single instruction decode path in frontend for ctrl flow analysis; use in dasm cache layer for disassembly textualization 2024-07-23 16:23:29 -07:00
Ryan Fleury 926b5e3546 apply linux notes from martins; simplify build.sh; simplify some linux layer code; fix incorrect linux api usage; get gcc builds up and running 2024-07-23 14:31:10 -07:00
Ryan Fleury e0b67f0ecb initial integration of zydis into dasm cache layer 2024-07-23 14:30:26 -07:00
Ryan Fleury 72c940d2b3 project.4coder 2024-07-23 08:45:10 -07:00
Nikita e18e136f82 fixed line number binary search for last range in line number map 2024-07-23 08:44:08 -07:00
Martins Mozeiko ce7c8d5244 avx512 registers & fixes for getting & setting x64 context 2024-07-23 08:43:35 -07:00
Henry Goschütz 14759e49e9 Fixed a typo. 2024-07-23 08:33:33 -07:00
Ryan Fleury d143fec0d1 fix mmap error case 2024-07-18 14:45:16 -07:00
Ryan Fleury 4835264059 stub out linux demon; linux font provider; begin work, get windows/events up and running in os_gfx 2024-07-18 13:37:22 -07:00
Ryan Fleury ec9c68f55e start work on raddbg building 2024-07-16 17:23:08 -07:00
Ryan Fleury de131b0c18 add rdi_dump to build.sh 2024-07-16 16:51:20 -07:00
Ryan Fleury fdd6c20c78 add cli utilities to build.sh 2024-07-16 16:49:49 -07:00
Ryan Fleury d5338c05f2 os_core: fix file tree iteration 2024-07-16 16:44:05 -07:00
Ryan Fleury d0d9327236 update metagen base/os & entry point 2024-07-16 16:09:53 -07:00
Ryan Fleury d82b54597f os_core: linux port of condition variables 2024-07-16 16:01:23 -07:00
Ryan Fleury 90065e535f os_core: linux port for shared memory, system info, process info, safe call, guid, mutexes, threads 2024-07-16 15:25:19 -07:00
Ryan Fleury b3f69f30ad os_core: linux port for file maps, file iters 2024-07-16 14:11:37 -07:00
Ryan Fleury 3cc51038df os_core: linux port for memory, thread info, filesystem apis 2024-07-16 13:24:54 -07:00
Ryan Fleury 1b74fb0760 simplification pass over os core layer; simplification pass over base arena; set up build.sh; stub out new spot for linux os core 2024-07-15 17:23:01 -07:00
Ryan Fleury 6447a2a993 notes 2024-07-15 10:41:03 -07:00
Ryan Fleury 2539e2ef45 full pass over ui to centralize text rasterization settings by font slot 2024-07-15 10:40:42 -07:00
Ryan Fleury 45656194f4 fix some text spacing issues after text rendering pass 2024-07-15 09:55:30 -07:00
Ryan Fleury 3bb8dc9089 adjust hover eval focus rules; require manual interaction to focus 2024-07-15 09:39:56 -07:00
Ryan Fleury ebbf927fc1 fix interaction register propagation rules on unfocused windows (still propagate if window was last focused) 2024-07-15 09:28:12 -07:00
Ryan Fleury 044e78bea2 fix incorrect scratch usage in new code view ui build path 2024-07-15 09:07:02 -07:00
Ryan Fleury d78afc5000 reintroduce out-of-date file warning 2024-07-04 09:56:44 -07:00
Ryan Fleury aed9a285f5 fix misuse of inactive panel overlay 2024-07-02 16:07:29 -07:00
Ryan Fleury f03d0fb974 correctly apply deserialized window settings 2024-06-28 17:36:44 -07:00
Ryan Fleury 80690d7b20 notes 2024-06-28 16:07:39 -07:00
Ryan Fleury 843749c8ae ui for editing multiple keybindings per command 2024-06-28 16:07:05 -07:00
Ryan Fleury 38090b6273 extend font provider backend with ability to independently toggle hinting & full anti-aliasing; fix up ui text measurement/placement; introduce per-window settings for adjusting font rendering parameters 2024-06-28 15:31:27 -07:00
Ryan Fleury b0259b7a49 visual cleanup / fixes 2024-06-28 09:47:55 -07:00
Ryan Fleury f7b97b302f fix visual issues in completion behavior of autocomplete lister 2024-06-28 09:42:38 -07:00
Ryan Fleury f2a7103461 watch-expr-at-mouse command 2024-06-28 09:14:58 -07:00
Ryan Fleury d1c0bf5fe2 fix add-tab button corners/placement with max-side tabs 2024-06-28 09:02:08 -07:00
Ryan Fleury 8ca67ff892 fix possible incorrect panel being used in commands fired from tab right-click menu 2024-06-27 14:24:45 -07:00
Ryan Fleury 13aa41910e default settings categories to closed 2024-06-27 13:17:44 -07:00
Ryan Fleury c05ceedfcb fix clang build 2024-06-26 18:12:27 -07:00
Ryan Fleury 5e093a9b4c notes 2024-06-26 17:54:54 -07:00
Ryan Fleury 08bc2b0a79 fix up color config remapping table 2024-06-26 17:48:28 -07:00
Ryan Fleury 4ebc38d9f9 fill theme presets for new theme color codes 2024-06-26 17:39:40 -07:00
Ryan Fleury 5e2c6b5107 setting view categories 2024-06-26 15:47:28 -07:00
Ryan Fleury 7584890edd theme presets in new settings view 2024-06-26 15:16:41 -07:00
Ryan Fleury 4bbf64de7e first pass at new settings view 2024-06-26 15:00:45 -07:00
Ryan Fleury e10bef9d2b fix function breakpoints using hit-count as voff; pass over entity ref buttons in various uis; go-to-location with address values in watch views 2024-06-26 12:05:56 -07:00
Ryan Fleury 1229a50c68 eliminate txti layer 2024-06-26 11:09:58 -07:00
Ryan Fleury 6e2353d302 eliminate margin from output 2024-06-26 11:01:51 -07:00
Ryan Fleury 3d272a598b complete convergence of new disasm view, which uses the core code view path 2024-06-26 10:57:49 -07:00
Ryan Fleury dbdf6e7c02 eliminate old duplicative disasm path; use same code view path 2024-06-26 10:44:24 -07:00
Ryan Fleury 0904de74de eliminate old duplicative code/output views 2024-06-26 10:07:26 -07:00
Ryan Fleury e3077cf6f5 pick-file path for new code view 2024-06-26 10:06:16 -07:00
Ryan Fleury 9ad52d25b5 more progress on top-level interaction-register-based cursor commands, getting more out of unified source view 2024-06-26 10:02:26 -07:00
Ryan Fleury c2ddffd424 set up interaction register push/pops for windows & views; use to implement top-level cursor-breakpoint operations; more convergence with new unified src view path 2024-06-26 09:21:51 -07:00
Ryan Fleury 7d351d03c5 txt: split symbol tokens in language lexers to defaultly do single-char symbols unless in special cases; this resolves weird indirection-size-change code label displays 2024-06-26 07:37:52 -07:00
Ryan Fleury 2e12b1485a some light mode fixes, light mode theme preset re-filled 2024-06-25 17:53:39 -07:00
Ryan Fleury 653eb08d43 set up interaction register stack 2024-06-25 17:21:59 -07:00
Ryan Fleury 9be3c2affc sketch out 'interaction registers'; fix bp hit count tracking 2024-06-25 17:02:43 -07:00
Ryan Fleury 6fa8af5e1a checkpoint on unified code ctx menu & all of its operations 2024-06-25 16:31:31 -07:00
Ryan Fleury 010d5609c6 checkpoint in first pass at new unified code view impl.; start setting up unified top-level code ctx menu 2024-06-25 12:00:50 -07:00
Ryan Fleury d12c5ec2e8 first pass at mutable text layer, which allows debugger-produced/controlled buffers to be fed into text visualization systems; start pulling out code view into single path, which will be used for disassembly/source/output 2024-06-25 11:09:02 -07:00
Ryan Fleury c10ac170a8 config settings, for top-level toggles or simple numeric parameters; use to mask off animations, background blurs, and so on; use to control tab width 2024-06-25 09:09:10 -07:00
Ryan Fleury 7a185f9560 auto-fill ctrl+f query from selection; fix single-cell copy/paste in watch views; tweaks/fixes 2024-06-25 08:04:00 -07:00
Ryan Fleury 0d581694e6 notes; tweaks; fixes 2024-06-24 16:35:23 -07:00
Ryan Fleury b4b8f5f0ab fix some escape-to-cancel & context menu behavior; notes 2024-06-24 16:14:06 -07:00
Ryan Fleury 15d42027e7 adjust memory view for new ui palettes & themes 2024-06-24 15:39:12 -07:00
Ryan Fleury 883aa2d1de fix binding ui interaction with group keys 2024-06-24 15:34:56 -07:00
Ryan Fleury 586b3e3072 fix incorrect margin measurement in output view 2024-06-24 15:32:50 -07:00
Ryan Fleury 2588bbcd12 notes 2024-06-24 15:25:22 -07:00
Ryan Fleury 0a5cc5df6f ui: group key, for menu-bar-style interactions, where you have several distinct boxes, but want one interaction to continuously flow between them 2024-06-24 15:23:56 -07:00
Ryan Fleury ff32449ba2 adjust rich hover info in source/disasm view to be less noisy; require hovering over line number margin, rather than always displaying it for whatever line the mouse is over 2024-06-24 15:14:13 -07:00
Ryan Fleury 614954b7ef checkpoint on palettes, fix source view overlay margin building/drawing 2024-06-24 14:46:16 -07:00
Ryan Fleury 31c671e3f5 more progress on simplifying/condensing new theme colors 2024-06-24 14:08:28 -07:00
Ryan Fleury 6d75d6b63b simplification/consolidation pass over theme colors 2024-06-24 11:59:19 -07:00
Ryan Fleury 4d2b524400 notes, ui pass tweaks 2024-06-23 23:21:18 -07:00
Ryan Fleury 16863b1f5a fix run-list size calculation, accounting for advance vs. end pad 2024-06-22 20:29:38 -07:00
Ryan Fleury f9abb397f3 adjust px offset -> byte offset path for new text measuring fixes 2024-06-22 20:19:24 -07:00
Ryan Fleury db5a7d4be2 adjust title bar 2024-06-22 16:12:53 -07:00
Ryan Fleury 6ac870dac0 improvements in text layout, focus visualization, smooth text rasterization for icons; checkpoint in ui visuals pass 2024-06-22 15:58:40 -07:00
Ryan Fleury 5f23820f9d checkpoint on ui/palettes/visuals pass 2024-06-21 22:06:40 -07:00
Ryan Fleury fc77844452 color scheme -> palette; fix eval/watch views after cleanup; make more progress on new palette system 2024-06-21 09:49:51 -07:00
Ryan Fleury 3b27abd5c7 first pass at new theme color table, scheme-based ui color specification 2024-06-20 15:28:48 -07:00
Ryan Fleury ce1f54a931 notes 2024-06-20 09:06:35 -07:00
Ryan Fleury c60d3aab22 mouse-driven ui path for query completion; show-in-explorer ui for tab ctx menu 2024-06-20 08:02:01 -07:00
Ryan Fleury b76c605eba sort locals by debug info order; still likely not sufficient for all the options, but at least marginally better & introduces the sorting path 2024-06-20 07:35:59 -07:00
Ryan Fleury 6eef8c3e16 rdi_format_parse: prefer line info idxs with file coordinates in line mapping helper 2024-06-19 13:27:34 -07:00
Ryan Fleury b5b5aca691 log win32 demon resume code 2024-06-19 12:07:08 -07:00
Ryan Fleury 435877824a oh NO... never mind... mystery solved... be VERY CAREFUL ABOUT STATE MACHINES! fixes incorrect non-resets of win32 demon 'exception not handled' state, which was buggily leading to DBG_EXCEPTION_NOT_HANDLED being passed to ContinueDebugEvent 2024-06-19 11:56:47 -07:00
Ryan Fleury 3327d73373 notes on memory-execution-exception spoof implementation situation, and toggles to switch to old behavior, for later investigation 2024-06-19 11:32:44 -07:00
Ryan Fleury 376a7c48a5 pass over logging, include a lot of extra info in ctrl thread log; demon abstraction for target-process memory allocation/protection; switch spoofs to being in allocated page, rather than at bogus address 2024-06-19 11:12:21 -07:00
Ryan Fleury f6eec680bc adjust single stepping rule to be robust to non-single-step events; this is still not what the issue is pertaining to the stepping bug... 2024-06-18 17:19:17 -07:00
Ryan Fleury 41fd224956 log ctrl events on user thread; do not use cached register block reading path for ctrl stepping machine, as it must not prematurely update cache for all readers, since runs are not complete 2024-06-18 12:07:46 -07:00
Ryan Fleury c794d896c9 oops - fix logging for trap net 2024-06-18 10:59:35 -07:00
Ryan Fleury 1a8b39ad9d fix builds github workflow for new build names 2024-06-18 10:56:41 -07:00
Ryan Fleury a8891b3ca4 fix rdi_from_dwarf build 2024-06-18 10:55:54 -07:00
Ryan Fleury ada1b8dfe2 log final trap net 2024-06-18 10:51:29 -07:00
Ryan Fleury 9461e79268 adjust build script to warn if valid build target was not specified 2024-06-18 10:46:50 -07:00
Ryan Fleury 4fc5b61676 also disable overly-ambitious cursor centering in memory view 2024-06-18 10:28:49 -07:00
Ryan Fleury 6cc1dfb39a trap net generation logging; log markers 2024-06-18 10:14:54 -07:00
Ryan Fleury d44f098e84 disallow override detection with nil overrides 2024-06-17 13:06:23 -07:00
Ryan Fleury 749821dd27 adjust unwind loop to be robust to noop-unwind-steps that would otherwise result in infinite unwind loops 2024-06-17 12:14:10 -07:00
Ryan Fleury 6ad94978ce correctly adjust dbgi timestamp in ctrl entity store, upon debug info changes 2024-06-17 10:55:17 -07:00
Ryan Fleury bc5d0b1888 fix rich hover reset behavior 2024-06-17 10:18:41 -07:00
Ryan Fleury 3c2c98b08a rdi_make: fix incorrect line table count calculation 2024-06-17 10:08:11 -07:00
Ryan Fleury 31d7be8f8a tweak snap-to-cursor behavior when dragging 2024-06-17 09:42:12 -07:00
Ryan Fleury 0b3e3228d1 rdi_from_pdb: fix incorrect bounds checks on procedure frameproc lookup for local location info 2024-06-17 09:34:27 -07:00
Ryan Fleury 794f212501 dasm address consistency 2024-06-14 14:17:26 -07:00
Ryan Fleury 723c7c5d4d further tightening up of win32 demon run path; take a few fastpaths on x64; speeds up conditional breakpoints 2024-06-14 09:50:33 -07:00
Ryan Fleury fb9824dc24 remove unnecessary ctrl log flushes, which seriously bloated the ctrl thread running path 2024-06-14 07:57:46 -07:00
Ryan Fleury 933b4c90de fix rdi_format_parse and rdi_breakpad_from_pdb build 2024-06-13 17:12:31 -07:00
Ryan Fleury 5349838633 rdi: producer name in top-level-info 2024-06-13 16:55:47 -07:00
Ryan Fleury f655758060 extend tooltips & stringization of callstacks with rich unwind info 2024-06-13 16:48:27 -07:00
Ryan Fleury fa4d0bc262 ctrl: break debug string events apart if needed; enforce size cap on serialized ctrl events 2024-06-13 16:24:54 -07:00
Ryan Fleury 3c39a88abf correctly transform saved relative project paths to absolute project paths on config deserialization 2024-06-13 15:52:11 -07:00
Ryan Fleury fb6689a74d always report debug string events earlier in queue 2024-06-13 15:28:56 -07:00
Ryan Fleury a5e29f65f6 Merge branch 'inline_merge' of https://github.com/EpicGamesExt/raddebugger into inline_merge 2024-06-13 15:20:35 -07:00
Ryan Fleury b6f50cc4be intersect line voff ranges across all overlapping line tables when mapping voffs to line info; fixes inline stepping 2024-06-13 15:18:29 -07:00
Ryan Fleury b47b22bdce correct thread -> src mapping, given inline info 2024-06-13 15:18:29 -07:00
Ryan Fleury 41e99bd2f6 proper inline frame unwind selection & storage & command parameterization 2024-06-13 15:18:29 -07:00
Ryan Fleury 2c7d15de59 pull out 'rich unwind' gathering path, which takes a 'concrete unwind'
and produces a full unwind with debug-info-derived inline frames
2024-06-13 15:18:29 -07:00
Ryan Fleury bf2d5640fa go back to per-inline-site line tables; eliminate call location for inline tables; these can be encoded via parent line tables; wire up parsed line tables to inline site production from symbol conversion phase 2024-06-13 15:18:29 -07:00
Ryan Fleury 1880eca295 do not assume non-empty name map bakes 2024-06-13 15:18:29 -07:00
Ryan Fleury 59a20a5574 fix missing line chunks in inline line table parsing 2024-06-13 15:18:29 -07:00
Ryan Fleury 852ff5f054 oops! 2024-06-13 15:18:29 -07:00
Ryan Fleury ac3d7be4de look up into inline site info in call stack view; display both concrete & inline frames 2024-06-13 15:18:29 -07:00
Ryan Fleury 07b56a920c parse inline site scope ranges in symbol conversion pass 2024-06-13 15:18:29 -07:00
Ryan Fleury 1cc829512f fix disasm cmd/ui discrepancy 2024-06-13 15:18:29 -07:00
Ryan Fleury dafbe32e85 adjust line info lookup apis to be range-based, with a first-and-shallowest-only helper 2024-06-13 15:18:29 -07:00
Ryan Fleury 2419a00b11 fix cases where decorative disasm lines were being confused with non-decorative 2024-06-13 15:18:29 -07:00
Ryan Fleury 6e9b2bd107 extend rdi line info lookups with depth; fix bad panel deref in target view cmds 2024-06-13 15:18:29 -07:00
Ryan Fleury 123232ab32 correctly apply procedure base voffs in inline line info parsing 2024-06-13 15:18:29 -07:00
Ryan Fleury 1dbc37fe1f eliminate per-inline-site line tables; merge inline site line info with unit's line table 2024-06-13 15:18:29 -07:00
Ryan Fleury 4c10967cec merged line table sort experiments 2024-06-13 15:18:29 -07:00
Ryan Fleury e543abd478 rdi_from_pdb: next checkpoint on inline line table parsing/conversion 2024-06-13 15:18:29 -07:00
Ryan Fleury 3b94fa55fb rdi_from_pdb: inline binary annotations parsing 2024-06-13 15:18:29 -07:00
Ryan Fleury 3b6d8cb761 rdi_from_pdb: sketch out unified inlinee parsing/gathering path in units conversion task 2024-06-13 15:18:29 -07:00
Ryan Fleury a73cde2864 codeview c13 inlinee lines info parsing, lookup in inline site parsing path 2024-06-13 15:18:29 -07:00
Ryan Fleury fe12f2fdf9 inline site info extraction 2024-06-13 15:18:29 -07:00
Ryan Fleury c80555c49d rdi_make, rdi_from_pdb, rdi_dump: sketch out the building (no parsing/filling yet), dumping, and baking/serializing of inline sites 2024-06-13 15:18:29 -07:00
Ryan Fleury a3f411ddd4 more progress on rdi parsing library high-level composite helpers; update breakpad_from_pdb to new format/maker changes 2024-06-13 15:18:29 -07:00
Ryan Fleury 084cabad39 pass over high level composite rdi parsing helpers 2024-06-13 15:18:29 -07:00
Ryan Fleury 64d7bae845 rdi_make: eliminate old baking/serializing code 2024-06-13 15:18:29 -07:00
Ryan Fleury 93d5bab41c eliminate base node idx from per-node info; nodes can be stored all relative to their name map's base indices, and this is naturally applied on lookup, no need to bake it in 2024-06-13 15:18:29 -07:00
Ryan Fleury 772bc37504 fix fuzzy search layer for new table extraction code 2024-06-13 15:18:29 -07:00
Ryan Fleury 2ff0abb91e rdi_make, rdi_from_pdb: complete next pass over new serialization/compression interface, including for new top-level-only name map data sections; eliminate determinism issues from string map build (task dispatch was busted) 2024-06-13 15:18:28 -07:00
Ryan Fleury b05cfa4b24 checkpoint on new baking implementation 2024-06-13 15:18:28 -07:00
Ryan Fleury 379885421e rdi make: xfer over per-name-map building path 2024-06-13 15:18:28 -07:00
Ryan Fleury 809a888ce7 rdi make: first pass at new baking paths 2024-06-13 15:18:28 -07:00
Ryan Fleury 9dadd3ed3c sketch out new rdi make baking codepaths 2024-06-13 15:18:28 -07:00
Ryan Fleury d0d1e7d7e6 sketch out artifact types for new rdi baking pass 2024-06-13 15:18:28 -07:00
Ryan Fleury 10ead2f999 rdi: first pass of eliminating remainder of non-top-level sections; simplification/cleanup of rdi parsing layer 2024-06-13 15:18:28 -07:00
Ryan Fleury 550e8a0451 set up inline site info building scaffolding 2024-06-13 15:18:28 -07:00
Ryan Fleury 7495096e05 fix baking of joined line tables 2024-06-13 15:18:28 -07:00
Ryan Fleury 7e85335f3b move per-source-file line maps to top-level sections, and move source line -> voff maps to separate top-level info table 2024-06-13 15:18:28 -07:00
Ryan Fleury 3ad6197b88 eliminate old per-unit line info code 2024-06-13 15:18:28 -07:00
Ryan Fleury 81b45f1a2f do not broadcast unnecessarily in task system kickoff 2024-06-13 15:18:28 -07:00
Ryan Fleury 44868c0e85 rdi, rdi_make, rdi_from_pdb, rdi_dump, df, dasm, etc: extract line tables from per-unit data sections, have top-level line info tables with units referring to line tables, and line tables just referring to sub-ranges of top-level sections; fix off-by-one string index in rdi generation 2024-06-13 15:18:28 -07:00
Ryan Fleury f7ce1b73bc introduce separate rdi table element types for isolated line tables & inline sites 2024-06-13 15:18:28 -07:00
Ryan Fleury a4a0452d0c fix project.4coder 2024-06-13 15:18:28 -07:00
Ryan Fleury 45090de3fb appease clang 2024-06-13 15:18:28 -07:00
Ryan Fleury 6824ffddc0 intersect line voff ranges across all overlapping line tables when mapping voffs to line info; fixes inline stepping 2024-06-13 15:17:12 -07:00
Ryan Fleury dc34cdb59a correct thread -> src mapping, given inline info 2024-06-13 15:04:12 -07:00
Ryan Fleury 98290ff29b proper inline frame unwind selection & storage & command parameterization 2024-06-13 14:58:18 -07:00
Ryan Fleury 5a24649a31 pull out 'rich unwind' gathering path, which takes a 'concrete unwind'
and produces a full unwind with debug-info-derived inline frames
2024-06-13 11:28:38 -07:00
Ryan Fleury 97a96cfdd4 go back to per-inline-site line tables; eliminate call location for inline tables; these can be encoded via parent line tables; wire up parsed line tables to inline site production from symbol conversion phase 2024-06-13 10:41:19 -07:00
Ryan Fleury e25c3044b0 do not assume non-empty name map bakes 2024-06-10 15:59:19 -07:00
Ryan Fleury af80e1bfc8 fix missing line chunks in inline line table parsing 2024-06-10 15:42:50 -07:00
Ryan Fleury 6488e2d5e2 oops! 2024-06-10 15:26:02 -07:00
Ryan Fleury 649932cce0 look up into inline site info in call stack view; display both concrete & inline frames 2024-06-10 15:06:25 -07:00
Ryan Fleury dd5cc89483 parse inline site scope ranges in symbol conversion pass 2024-06-10 14:36:00 -07:00
Ryan Fleury 8a6837c553 fix disasm cmd/ui discrepancy 2024-06-10 13:33:32 -07:00
Ryan Fleury a009473557 adjust line info lookup apis to be range-based, with a first-and-shallowest-only helper 2024-06-10 13:28:08 -07:00
Ryan Fleury c18c02a37e fix cases where decorative disasm lines were being confused with non-decorative 2024-06-10 13:23:32 -07:00
Ryan Fleury c61f820aef extend rdi line info lookups with depth; fix bad panel deref in target view cmds 2024-06-10 12:34:22 -07:00
Ryan Fleury 5c8c1a89e3 correctly apply procedure base voffs in inline line info parsing 2024-06-10 11:35:31 -07:00
Ryan Fleury 61630f4cf9 eliminate per-inline-site line tables; merge inline site line info with unit's line table 2024-06-10 11:26:54 -07:00
Ryan Fleury 21b439e7e5 merged line table sort experiments 2024-06-10 11:12:21 -07:00
Ryan Fleury 4888f90f7f rdi_from_pdb: next checkpoint on inline line table parsing/conversion 2024-06-10 09:45:41 -07:00
Ryan Fleury 6f92fe971a rdi_from_pdb: inline binary annotations parsing 2024-06-10 09:18:05 -07:00
Ryan Fleury cfd2380caa rdi_from_pdb: sketch out unified inlinee parsing/gathering path in units conversion task 2024-06-07 17:22:45 -07:00
Ryan Fleury 07d56ee27c codeview c13 inlinee lines info parsing, lookup in inline site parsing path 2024-06-07 16:40:21 -07:00
Ryan Fleury 334bd3b06f inline site info extraction 2024-06-07 15:22:53 -07:00
Ryan Fleury a14a2f34f5 rdi_make, rdi_from_pdb, rdi_dump: sketch out the building (no parsing/filling yet), dumping, and baking/serializing of inline sites 2024-06-07 14:54:13 -07:00
Ryan Fleury 9dcb5a209a more progress on rdi parsing library high-level composite helpers; update breakpad_from_pdb to new format/maker changes 2024-06-07 13:45:26 -07:00
Ryan Fleury 300b14ffb4 pass over high level composite rdi parsing helpers 2024-06-07 11:45:18 -07:00
Ryan Fleury 8c63478d9b rdi_make: eliminate old baking/serializing code 2024-06-07 11:17:48 -07:00
Ryan Fleury 8f03fb0cc5 eliminate base node idx from per-node info; nodes can be stored all relative to their name map's base indices, and this is naturally applied on lookup, no need to bake it in 2024-06-07 11:17:11 -07:00
Ryan Fleury b48fcea28a fix fuzzy search layer for new table extraction code 2024-06-07 11:07:58 -07:00
Ryan Fleury 431884dce8 rdi_make, rdi_from_pdb: complete next pass over new serialization/compression interface, including for new top-level-only name map data sections; eliminate determinism issues from string map build (task dispatch was busted) 2024-06-07 11:03:00 -07:00
Ryan Fleury d931aed462 checkpoint on new baking implementation 2024-06-06 17:13:44 -07:00
Ryan Fleury 2c4c9e9d75 rdi make: xfer over per-name-map building path 2024-06-06 16:50:02 -07:00
Ryan Fleury 11978904e1 rdi make: first pass at new baking paths 2024-06-06 16:47:33 -07:00
Ryan Fleury 8d99f4859b sketch out new rdi make baking codepaths 2024-06-06 16:06:50 -07:00
Ryan Fleury 6e84c078a8 sketch out artifact types for new rdi baking pass 2024-06-06 15:37:27 -07:00
Ryan Fleury 14034c8bea rdi: first pass of eliminating remainder of non-top-level sections; simplification/cleanup of rdi parsing layer 2024-06-06 14:37:22 -07:00
Ryan Fleury 0a88e08dee Merge branch 'dev' of https://github.com/EpicGamesExt/raddebugger into inline_merge 2024-06-05 18:06:47 -07:00
Ryan Fleury c04a97f991 eval: fix enum type unwrapping; unwrap enum types on array indexing 2024-06-05 18:06:09 -07:00
Ryan Fleury 0b35224cf8 set up inline site info building scaffolding 2024-06-04 17:04:53 -07:00
Ryan Fleury 3f50169fee fix baking of joined line tables 2024-06-04 15:46:51 -07:00
Ryan Fleury ebd5cf9e47 move per-source-file line maps to top-level sections, and move source line -> voff maps to separate top-level info table 2024-06-04 13:33:38 -07:00
Ryan Fleury f7e67a80c9 eliminate old per-unit line info code 2024-06-03 16:45:33 -07:00
Ryan Fleury 063975693d do not broadcast unnecessarily in task system kickoff 2024-06-03 16:25:37 -07:00
Ryan Fleury 44fbbc24ee rdi, rdi_make, rdi_from_pdb, rdi_dump, df, dasm, etc: extract line tables from per-unit data sections, have top-level line info tables with units referring to line tables, and line tables just referring to sub-ranges of top-level sections; fix off-by-one string index in rdi generation 2024-06-03 15:32:14 -07:00
Ryan Fleury fcb839b788 introduce separate rdi table element types for isolated line tables & inline sites 2024-06-02 21:22:01 -07:00
Ryan Fleury 139d00e660 Merge branch 'dev' of https://github.com/EpicGamesExt/raddebugger into inline_merge 2024-06-02 18:24:30 -07:00
Ryan Fleury 41afe1af64 Merge branch 'dev' of https://github.com/EpicGamesExt/raddebugger 2024-06-02 18:23:38 -07:00
Ryan Fleury 3927d333ae remove unnecessary and sometimes unsupported win_noexcept keyword 2024-06-02 18:22:51 -07:00
Ryan Fleury 8438faca06 fix project.4coder 2024-06-01 21:09:44 -07:00
Ryan Fleury 061abb4545 appease clang 2024-06-01 21:09:36 -07:00
Ryan Fleury 011c980646 fix project.4coder 2024-06-01 21:09:10 -07:00
Ryan Fleury 26626c3946 appease clang 2024-06-01 21:09:06 -07:00
Ryan Fleury 281849b4e8 fix project.4coder 2024-06-01 21:06:28 -07:00
Ryan Fleury d3f7bef2b7 appease clang 2024-06-01 21:06:22 -07:00
Ryan Fleury ab5259a3d3 Merge branch 'inline_merge' of https://github.com/EpicGamesExt/raddebugger into inline_merge 2024-06-01 19:25:33 -07:00
Ryan Fleury 57da328c2a d3d11 render backend c++ -> c; raddbg build c++ -> c 2024-06-01 19:24:47 -07:00
Ryan Fleury ebc19ded62 font provider dwrite c++ -> c 2024-06-01 19:24:47 -07:00
Ryan Fleury aff3da8256 move font provider directwrite backend to using martins' auto-generated dwrite c declarations, get it almost off C++ entirely 2024-06-01 19:24:47 -07:00
Ryan Fleury c1764cee07 adjust builds to new rdi library setup 2024-06-01 19:24:46 -07:00
Ryan Fleury cc58703185 reorganize generated & handwritten library (relocatable) rad debug info format files; separate from codebase-local tools for managing or internally including the libraries 2024-06-01 19:24:46 -07:00
Ryan Fleury 6a57555882 lld no_aslr 2024-06-01 19:24:46 -07:00
Ryan Fleury cdf0b67354 clean up metaprogram multiline string line endings; fix rdi_from_pdb build 2024-06-01 19:24:46 -07:00
Ryan Fleury 45f69b6f98 further progress on metacode-driven generation of rdi headers; metaprogram xlist generation; getting rdi_dump up-to-speed 2024-06-01 19:24:46 -07:00
Ryan Fleury 47df50b6dc generation folder output override in metaprogram 2024-06-01 19:24:46 -07:00
Ryan Fleury f50b54cff7 complete metacodification of rdi format info into tables 2024-06-01 19:24:46 -07:00
Ryan Fleury 8492693df2 initial pass of moving rdi definitions to metacode tables 2024-06-01 19:24:45 -07:00
Nikita Smith 652a9b5cee codeview: inline binary annot format and decode helpers 2024-06-01 19:23:59 -07:00
Ryan Fleury 7f87f89aa8 rdi_dump: stringize source file's path 2024-06-01 19:22:30 -07:00
Nikita Smith 92b3356526 codeview: struct defs for $$INLINEE_LINES 2024-06-01 19:22:30 -07:00
Nikita Smith 98486f0795 codeview: new sub-section types 2024-06-01 19:22:29 -07:00
Ryan Fleury 729a5a9392 clean up & merge inline binary annotation decoders 2024-06-01 19:22:29 -07:00
Nikita Smith ffa802f583 codeview: inline binary annot format and decode helpers 2024-06-01 19:22:29 -07:00
Ryan Fleury b192e38d12 d3d11 render backend c++ -> c; raddbg build c++ -> c 2024-06-01 19:21:43 -07:00
Ryan Fleury 3c0831ec09 font provider dwrite c++ -> c 2024-06-01 18:21:29 -07:00
Ryan Fleury 02e1b8cf00 move font provider directwrite backend to using martins' auto-generated dwrite c declarations, get it almost off C++ entirely 2024-06-01 18:20:13 -07:00
Ryan Fleury 448baf68a8 adjust builds to new rdi library setup 2024-06-01 12:07:55 -07:00
Ryan Fleury 82c1badcdc reorganize generated & handwritten library (relocatable) rad debug info format files; separate from codebase-local tools for managing or internally including the libraries 2024-06-01 12:05:51 -07:00
Ryan Fleury 01a21af955 lld no_aslr 2024-06-01 11:57:44 -07:00
Ryan Fleury a8b02f9791 clean up metaprogram multiline string line endings; fix rdi_from_pdb build 2024-06-01 11:30:51 -07:00
Ryan Fleury 2c9a6f996d fix zero expression child nodes, commonly produced via partially typed expressions 2024-06-01 10:58:49 -07:00
Ryan Fleury d66bbdc6a7 further progress on metacode-driven generation of rdi headers; metaprogram xlist generation; getting rdi_dump up-to-speed 2024-06-01 10:16:38 -07:00
Ryan Fleury de56231f4a generation folder output override in metaprogram 2024-05-31 17:29:25 -07:00
Ryan Fleury 35c1c463c8 complete metacodification of rdi format info into tables 2024-05-31 17:16:54 -07:00
Ryan Fleury 59e71eb5cc drive iteration in win32 file system api; fix some root-level behaviors of file browser 2024-05-31 12:20:14 -07:00
Ryan Fleury d3adfdeced deduplicate debug string event generation; log ctrl messages 2024-05-31 11:17:59 -07:00
Ryan Fleury ed8731c093 correctly handle copy path in new multicursor-able watch view controls 2024-05-31 10:47:46 -07:00
Ryan Fleury 6d4b4b1526 time-based exit path for demon win32 event consumption loop, to not overly-aggressively-buffer things 2024-05-30 07:10:21 -07:00
Ryan Fleury 9fbcd1ec36 Merge branch 'dev' 2024-05-30 07:06:53 -07:00
Ryan Fleury da54fd1217 majorly improve outputdebugstring performance 2024-05-30 07:06:29 -07:00
Ryan Fleury 34bba95839 import todo notes from awkwardly aggressive user feedback 2024-05-29 21:25:47 -07:00
Ryan Fleury 89fd718a8c Merge branch 'dev' of https://github.com/EpicGamesExt/raddebugger into inline_merge 2024-05-29 12:35:49 -07:00
Ryan Fleury 89c8f84498 more tweaks with new double-margin; do not try to display non-printable ascii characters in watch 2024-05-29 12:25:03 -07:00
Ryan Fleury c426818364 draw line between priority & catchall marging 2024-05-29 11:53:48 -07:00
Ryan Fleury 62fa397e29 split code slice margin into two parts - priority, and catchall. priority for selected thread so it is always necessarily visible, and catchall for other threads, breakpoints, watch pins, etc. also tweak targets view behavior to prioritize selection as the common path, and to make checkboxes less idiosyncratic 2024-05-29 11:51:04 -07:00
Ryan Fleury 0e179f3844 fix clips, occlusion, for ui-tree-wide truncated text tooltips 2024-05-29 10:56:46 -07:00
Ryan Fleury f808e8ae29 adjust force-contain on tooltips; we don't want it for drag/drop, we do for tooltips, so use active interaction as a proxy 2024-05-29 10:43:14 -07:00
Ryan Fleury 8f446d1f9a pass over callstack view to display function type info and properly display richer/weirder C++ symbol names 2024-05-29 10:36:22 -07:00
Ryan Fleury e073ff3218 more notes on the multithreaded access violation stuff! 2024-05-29 08:31:24 -07:00
Ryan Fleury 2512d07c72 correctly roll-back late-hits for int3s 2024-05-29 08:08:44 -07:00
Ryan Fleury f65cf5436e fix code off -> instruction idx lookup - fixes busted instruction pointer drawing in disassembly view 2024-05-29 08:03:06 -07:00
Ryan Fleury 5778e75d66 oops - do not zero unwind cache node after adding it, zero it before adding it 2024-05-28 21:45:14 -07:00
Ryan Fleury 08750c2318 initial pass of moving rdi definitions to metacode tables 2024-05-28 21:31:56 -07:00
Ryan Fleury 9a5a3b9296 Merge remote-tracking branch 'refs/remotes/origin/inline_merge' into inline_merge 2024-05-28 07:41:31 -07:00
Ryan Fleury cab8bdaf38 rdi_dump: stringize source file's path 2024-05-28 07:37:19 -07:00
Nikita Smith afb7aba039 codeview: struct defs for $$INLINEE_LINES 2024-05-28 07:37:19 -07:00
Nikita Smith 0750570081 codeview: new sub-section types 2024-05-28 07:37:18 -07:00
Ryan Fleury 86a9934016 clean up & merge inline binary annotation decoders 2024-05-28 07:37:18 -07:00
Nikita Smith f14686c6fb codeview: inline binary annot format and decode helpers 2024-05-28 07:37:18 -07:00
Ryan Fleury e80008cb7e do not animate disasm load when running 2024-05-28 07:34:10 -07:00
Ryan Fleury 68d3f17ecb do not snap-to-thread on soft-halts 2024-05-28 07:30:54 -07:00
Ryan Fleury e541fce2bc fix non-enumeration of 0 tex2dfmt 2024-05-28 06:13:14 -07:00
Ryan Fleury 6a32c197fa rdi_dump: stringize source file's path 2024-05-28 06:10:43 -07:00
Nikita Smith eea3c6b53c codeview: struct defs for $$INLINEE_LINES 2024-05-28 06:10:43 -07:00
Nikita Smith d2f9bdeefb codeview: new sub-section types 2024-05-28 06:10:43 -07:00
Ryan Fleury c767f03f32 clean up & merge inline binary annotation decoders 2024-05-28 06:10:43 -07:00
Nikita Smith db737941d8 codeview: inline binary annot format and decode helpers 2024-05-28 06:10:43 -07:00
Ryan Fleury 8319850666 fix precision tab alignment issue 2024-05-28 06:10:12 -07:00
Ryan Fleury d04ee598b2 use lower level unwinding path with more generous time allowance, rather than passive cache query, for step-out 2024-05-26 14:35:57 -07:00
Ryan Fleury 15f5894c60 choose debug info key timestamps from debug info path, rather than module timestamp; the module should be allowed to be newer 2024-05-26 13:25:03 -07:00
Ryan Fleury 05c751a61a fix filesystem lister names 2024-05-26 12:47:47 -07:00
Ryan Fleury dd7cce2c3a some progress on the bitmap view rule 2024-05-24 21:20:44 -07:00
Ryan Fleury b1e1752229 oops 2024-05-24 17:19:46 -07:00
Ryan Fleury bddc9c97d9 get rdi_dump off dbgi layer, actually, super bad idea; just dedup decompression code 2024-05-24 17:18:31 -07:00
Ryan Fleury 325474fc49 Merge remote-tracking branch 'refs/remotes/origin/dev' into dev 2024-05-24 16:35:09 -07:00
Ryan Fleury 50d401e4ce formalize tab size in all ui codepaths, per-box; pick 4*columnsize by default in text views 2024-05-24 16:34:42 -07:00
Ryan Fleury 1dbbd351d7 formalize tab size in all ui codepaths, per-box; pick 4*columnsize by default in text views 2024-05-24 16:33:30 -07:00
Casey Muratori 1161c4adbb Added line that got left out when I tried to commit this the first time. 2024-05-24 16:10:40 -07:00
Casey Muratori 320a307e90 Dynamically linked SetThreadDescription to avoid requiring latest SDK/kernel version on Windows 2024-05-24 16:10:40 -07:00
Casey Muratori f835158071 Added call to the build.bat so that rc can be redirected as a batch file 2024-05-24 16:10:40 -07:00
Ryan Fleury f214b7d5f2 eliminate tab picker ui 2024-05-24 15:17:36 -07:00
Ryan Fleury d716159faf feed base column & tab width through all font rendering paths; use temporary constants 2024-05-24 15:12:40 -07:00
Ryan Fleury 5074b7f62e expand f_push_run_from_... to basing its tab-advance logic on what base column it is starting at - currently assume this is 0, basically doing the most naive tab alignment version that will work for leading spaces but for nothing else, and also assume 4-space tab width for now 2024-05-24 14:40:07 -07:00
Martins Mozeiko fd982d38fc Fixes bad resource usage in rendering
D3D11 is quite strict about how resources are supposed to be used - read/write & CPU access.
This changes Tex2DKind and BufferKind into one uniform ResourceKind (because it's the same thing really).

And it is more strict about usage:
1) Static is not allowed to update, resource is immutable, data provided at creation
2) Dynamic allows CPU to update GPU resource occasionally via UpdateSubresource
3) Stream allows CPU to update GPU resource often via Map/Unmap (currently unused)
2024-05-24 14:04:42 -07:00
Ryan Fleury 7e0611e7f1 recent projects history & opener 2024-05-24 14:03:07 -07:00
Ryan Fleury fd7085b690 do not settle for empty unwinds 2024-05-24 13:37:31 -07:00
Ryan Fleury 5f76fcfb6b filter panel tabs by project, if applicable; move all tab controls & so on to working based on this filtering mechanism 2024-05-24 13:33:47 -07:00
Ryan Fleury 9e778b30b6 begin tracking per-tab project info; fix dasm cache request dequeue incorrect cv broadcast 2024-05-24 12:58:54 -07:00
Ryan Fleury 15a1f81545 profile -> project 2024-05-24 12:35:51 -07:00
Ryan Fleury f7ad44a0d7 fix new-file query completion 2024-05-24 12:16:30 -07:00
Ryan Fleury 9349ac9e72 eliminate weird rollback/re-adjust rules for threads hitting int3s - rollback should only ever happen for temporary traps, e.g. user breakpoints or stepping. the fact that the thread shows *after* the trap later is a visualization issue, not a functionality issue 2024-05-24 08:20:10 -07:00
Ryan Fleury 489ae56223 fix moduleless unwinding and find-threads without debug info 2024-05-23 16:17:31 -07:00
Ryan Fleury 35b97d9c20 process name on stop-reason strings 2024-05-23 15:38:51 -07:00
Ryan Fleury bafc2170ca do not consume passthrough --s in command line parser 2024-05-23 15:21:53 -07:00
Ryan Fleury 6837d8d71a move rdi_dump over to dbgi layer 2024-05-23 15:16:53 -07:00
Ryan Fleury 35c599dea3 raddbgi -> rdi 2024-05-23 15:09:53 -07:00
Ryan Fleury dc5dda3f71 visualize handle basic types 2024-05-23 14:47:42 -07:00
Ryan Fleury fdfee37228 oops - only d3d11 flush on resize 2024-05-23 14:45:32 -07:00
Ryan Fleury ece414c575 prioritize title-bar-client-areas over built-in window borders; expand top bar rect a bit to ensure edge of window coverage 2024-05-23 14:40:23 -07:00
Ryan Fleury f431ac7f80 rewrite ipc communication; do ipc message reception on separate thread, wake up main thread; fix various robustness issues. do not necessarily initialize slower-to-initialize layers in conversion/ipc instances 2024-05-23 14:34:01 -07:00
Ryan Fleury e850f6fc93 c++ module extensions 2024-05-23 12:39:14 -07:00
Ryan Fleury 68a9802357 re-implement keyboard-driven path for opening dedicated view rule tabs 2024-05-23 11:36:51 -07:00
Ryan Fleury 905d04ab0b adjust disasm window limits; too often hitting non-read-only memory 2024-05-23 11:34:23 -07:00
Ryan Fleury bc40d1c0b0 rewrite frontend unwind cache to always preserve stale results until a new unwind successfully completes 2024-05-23 11:16:34 -07:00
Ryan Fleury f26b4c3b06 eliminate path-tree-based keying of debug info on frontend; use dbgi-layer-defined debug info keys, which can be more robust to changes to the same debug info path across time (e.g. during hot reloads 2024-05-23 10:30:23 -07:00
Ryan Fleury 68a92e910a eliminate old dbgi layer 2024-05-23 08:26:16 -07:00
Ryan Fleury 1621dc0637 correct nil rdi top-level-info 2024-05-23 07:54:28 -07:00
Ryan Fleury 21fcfd28a4 appease clang 2024-05-23 07:38:30 -07:00
Ryan Fleury 4a3d439c44 adjust symbol lister to apply to all loaded debug infos, rather than just the selected thread's debug info 2024-05-23 07:34:24 -07:00
Ryan Fleury 30f8e1675e new multi-dbgi-capable fuzzy search layer first pass 2024-05-23 07:01:34 -07:00
Ryan Fleury c17072053b adjust d3d11 resize path 2024-05-22 15:27:39 -07:00
Ryan Fleury a5e2235fc6 fix deadlocks on di_close contending with passive scoped dbgi access 2024-05-22 11:54:27 -07:00
Ryan Fleury 0160d05e8a further tweaks to mule_peb_trample 2024-05-22 11:39:23 -07:00
Ryan Fleury 7a4e939886 fix incorrectly referring to root entity for debug info if missing; fix thread register cache issues; fix new dbgi layer issues 2024-05-22 11:13:08 -07:00
Ryan Fleury b33559b081 tweaks to mule_peb_trample 2024-05-21 12:40:21 -07:00
Ryan Fleury b74db17375 peb trampling mule 2024-05-21 11:29:19 -07:00
Ryan Fleury a019115b95 get ctrl and debug frontend layers onto new pdb-path-based debug info loader layer; sketch out standalone fuzzy search layer, to replace old dbgi searching functionality; shift all debug frontend code from referring to debug info via 'binaries' to referring to debug info via 'dbgis', just file entities at the location of o.g. debug info 2024-05-21 10:08:28 -07:00
Ryan Fleury b9ac104276 begin stitching new dbgi layer usage code into ctrl layer; keep track of per-module preferred pdb paths via event-synchronized ctrl entity tree; still need conversion 2024-05-20 17:15:11 -07:00
Ryan Fleury 6e41bdf11b first pass at loader portion of new dbgi layer replacement; set up ctrl entity for per-module debug info selection path info 2024-05-20 16:28:52 -07:00
Ryan Fleury 49eb834e2b eliminate old unwind code 2024-05-20 12:58:02 -07:00
Ryan Fleury fd6befecc3 get tls address calculation off of binary parsing path; do based on in-process memory 2024-05-20 12:55:20 -07:00
Ryan Fleury 5342fab86b bugfix in new unwinder; applying stack ptr read & unwind when doing epilog unwinds 2024-05-20 11:12:29 -07:00
Ryan Fleury 9919ac59bb move module image info parse / cache management to ctrl thread, directly tie to module lifetime as ctrl thread sees it; reduce load from each unwind 2024-05-20 10:58:45 -07:00
Ryan Fleury 2d1fcd7475 fix some unwanted frontend unwind cache behavior; fix staleness calculation in ctrl process memory cache 2024-05-20 08:23:41 -07:00
Ryan Fleury 393fb9e5f2 eliminate old unwinder usage code; more regression fixing 2024-05-17 15:07:21 -07:00
Ryan Fleury 301cf6b7ac regression fixes, better integration, and tightening up the new unwinder 2024-05-17 14:15:11 -07:00
Ryan Fleury 578a56d231 further progress on new unwinder 2024-05-16 17:12:37 -07:00
Ryan Fleury 33ab26dfb3 begin porting unwinder to ctrl layer, just built purely on in-process memory, and getting completely off of parsed binary image artifacts 2024-05-16 15:39:57 -07:00
Ryan Fleury 8901dd30ec eliminate old pending entity code; do not build missing entity interface if data is actually present (but frontend cache still suggests missing) 2024-05-16 10:35:56 -07:00
Ryan Fleury e1a5d131c8 fix clang... sigh 2024-05-15 15:41:03 -07:00
Ryan Fleury 55c1674ec6 notes 2024-05-15 13:38:38 -07:00
Ryan Fleury 364a2160af correctly register jit debugger exe; collect jit_debug_info into dmn win32; notes 2024-05-15 13:25:20 -07:00
Ryan Fleury 56afe8ca60 watch window reordering 2024-05-15 11:57:46 -07:00
Ryan Fleury 6e039430a5 mouse controls for new watch window editing mechanism 2024-05-15 11:22:05 -07:00
Ryan Fleury f1af166fd4 expand ui events to contain semantic 'controls' info, to eliminate most hardcoded escs/returns/f2s/etc; formalize these things as proper commands; keyboard-driven expansions; other various fixes 2024-05-15 10:53:26 -07:00
Ryan Fleury 03844d81d2 further progress on watch window pass; multi-cursor, multi-selection, autocomplete lister, etc 2024-05-15 09:26:16 -07:00
Ryan Fleury aa73e62240 fix clang 2024-05-14 16:31:34 -07:00
Ryan Fleury 16de33245c first half of first pass at multi-cursor watch window 2024-05-14 16:25:24 -07:00
Ryan Fleury f8b688096a fix crash on tpi-less pdbs 2024-05-14 11:39:18 -07:00
Ryan Fleury 4dd1f6f579 eval watch -> watch; prep for more organized event-driven editing path for watch windows, beginning of multi-selection support 2024-05-14 10:33:03 -07:00
Ryan Fleury 58b8ed8974 floating line-nums/margins in source & disasm views, when horizontally scrolled 2024-05-14 09:07:44 -07:00
Ryan Fleury ac9a908464 automatically support insert-based copy/paste shortcuts 2024-05-14 08:27:59 -07:00
Ryan Fleury 5d459d9b7a skip/chop whitespace on launch parameters 2024-05-14 08:23:28 -07:00
Ryan Fleury 3085482e34 expand base layer logging mechanism with bucketing info; make one bucket for passive log collection, another for user-facing errors; always consume user errors at the top-level and display; use user-error mechanism to communicate bad 32-bit app launches from demon 2024-05-14 08:10:02 -07:00
Ryan Fleury 6c200a59cd bugfixes for new autocompletion system 2024-05-14 07:50:13 -07:00
Ryan Fleury 362bcbcda5 fix clang 2024-05-13 16:28:13 -07:00
Ryan Fleury 897949d33a notes 2024-05-13 16:27:15 -07:00
Ryan Fleury 70479e0399 fix autocompletion query word calculation 2024-05-13 16:26:54 -07:00
Ryan Fleury 90fc289ef0 extend autocompletion lister parameter detection, based on cursor position; feed through view rule parameters; correctly support cursor position with multi-arguments, regardless of which argument the cursor is on 2024-05-13 16:19:32 -07:00
Ryan Fleury 7c0f92ab3d sketch out view rule schemas; use them to determine autocompletion lister flags via partial parse of view rule input & matching to cursor; expand autocompletion lister to support lists of various things used in view rule arguments 2024-05-13 15:45:35 -07:00
Ryan Fleury 036d94fff0 autocompletion lister improvements - completions now can be used for sub-expression parts 2024-05-13 14:24:28 -07:00
Ryan Fleury 37dd5cea2d oops - this was not dead code! 2024-05-13 13:11:34 -07:00
Ryan Fleury 05f2cde2ee fix clang 2024-05-13 13:10:49 -07:00
Ryan Fleury e59d71893b bugfix copying & other accidental event consumption issues with new ui events 2024-05-13 12:57:45 -07:00
Ryan Fleury e41eb9430f finish pass to convert everything over to ui events, eliminate nav actions; intermix os events & ui event production with commands 2024-05-13 11:48:42 -07:00
Ryan Fleury 58192b8356 move all ui/df codepaths onto new ui event consumption, rather than os/nav events in parallel 2024-05-13 10:33:30 -07:00
Ryan Fleury 38e38eaf3b sketch out ui event type, to unify type & stream for text ops, nav actions, and all other user inputs 2024-05-13 07:48:48 -07:00
Ryan Fleury 9f89735b01 preserve jeff notes from emails - put into todo list 2024-05-12 14:11:08 -07:00
Ryan Fleury 4cb0073909 stop non-x64 builds with less cryptic errors 2024-05-10 16:32:01 -07:00
Ryan Fleury 6fb8db4d3d getting started view improvements 2024-05-10 10:15:10 -07:00
Ryan Fleury 123276a1c6 choose compact layout by default with smaller monitor size 2024-05-10 09:59:23 -07:00
Ryan Fleury 6e8753f1e1 formalize more compact panel layout 2024-05-10 09:56:06 -07:00
Ryan Fleury dda0e012bf support getting started view in default panel layout 2024-05-10 09:35:03 -07:00
Ryan Fleury 6660446bdd auto-close panels if final tabs are closed; simplify empty panel view, move 'helper' stuff to dedicated 'getting started' tab 2024-05-10 08:48:42 -07:00
Nikita Smith ef175baae4 fix chained unwind info count 2024-05-10 08:47:25 -07:00
Ryan Fleury f45ea18f24 full line bounds check in intermixed dasm 2024-05-01 05:13:17 -07:00
Ryan Fleury 4aeb6d7d03 notes 2024-04-30 11:38:02 -07:00
Ryan Fleury ed0ec4b34d last fixes, improvements, & split operation coverage for new tab drag/drop system 2024-04-30 11:14:24 -07:00
Ryan Fleury 2e971f9e39 do not force contain tooltip if it is above some threshold - otherwise it can occlude important ui 2024-04-30 10:02:50 -07:00
Ryan Fleury d65c263266 new/fixed panel animation 2024-04-30 09:41:57 -07:00
Ryan Fleury cd9437534c remove old animation method for panel pcts; since panels are often rearranged in a hierarchy, having pcts being based on parent rectangle (as opposed to the root rectangle) is unstable and often looks bad 2024-04-30 09:17:00 -07:00
Ryan Fleury 3b2656675e root-level non-split-axis splits; less noisy tab drag/drop ui 2024-04-30 05:39:34 -07:00
Ryan Fleury b4dab84235 always resolve to address mode evaluation when doing a member access 2024-04-29 18:13:50 -07:00
Ryan Fleury 2fc34ffb3d further coverage of split-drop drag/drop sites, for splitting options at non-leaf-panels 2024-04-29 12:17:03 -07:00
Ryan Fleury d419c6e15c formal drop-hot mechanism in ui core; further cleanup/fixes in drop-split combined operation ui 2024-04-29 11:06:18 -07:00
Ryan Fleury 15a2e708a0 hook up new combined move-tab-and-split ui with actual operation; auto-close panels which have their last tab dragged away; etc 2024-04-29 06:15:43 -07:00
Ryan Fleury 5a84fe4949 first half of pass to enable combined, standard split+movetab drag/drop fast-paths; just visualizations, next need the combo mutations 2024-04-28 18:51:57 -07:00
Ryan Fleury 9177299488 improve tab drag/drop 2024-04-28 17:29:41 -07:00
Ryan Fleury b6eb13761f fix breakpad_from_pdb build; robustify to typeless global vars 2024-04-25 11:53:23 -07:00
Ryan Fleury 67eede7513 hot-reloading for dasm_cache, in case of filesystem changes; file stream layer -> expose filesystem-wide generation number, for very coarse-grained generation number to gracefully depend on filesystem changes passively 2024-04-25 09:37:16 -07:00
Ryan Fleury f4ea9e66b0 bugfix on-demand process-dependent breakpoint resolution path & user breakpoint hit logic in stepping machine; more logging 2024-04-25 08:59:00 -07:00
Ryan Fleury 0dbde584bd jump destination symbol name visualization in disassembly 2024-04-23 19:12:58 -07:00
Ryan Fleury 579e3e9637 adjust source code intermixing symbol 2024-04-23 14:01:11 -07:00
Ryan Fleury 425626a275 first pass over mixed-mode disassembly 2024-04-23 13:52:44 -07:00
Ryan Fleury 5b87c2b64a bundle disassembly parameterizations into single dasm params type; extend with exe path & base address, to begin using debug info in the disassembly pass itself 2024-04-23 12:37:53 -07:00
Ryan Fleury 879e649d0e more frontend logging 2024-04-23 10:07:59 -07:00
Ryan Fleury 15e9dec60a fix incorrect entity destruction logging 2024-04-23 10:04:05 -07:00
Ryan Fleury ec13092a35 ui thread logging; more ctrl thread logging 2024-04-23 09:57:17 -07:00
Ryan Fleury 757cd9b9d2 correct createfile params for appending 2024-04-23 08:34:32 -07:00
Ryan Fleury 856c59a949 set up ctrl thread log scopes; ditch ctrl -> user log stuff, just make each log site in control of exporting to a separate file 2024-04-18 15:09:43 -07:00
Ryan Fleury 62d1c6b130 scoped log gathering; communicate ctrl logs -> user via events 2024-04-18 14:48:03 -07:00
Ryan Fleury b995909997 sketch out logging stub, to begin marking up debugger layers with logging - high level stuff still wip 2024-04-17 14:32:09 -07:00
Ryan Fleury a954317500 fix new issues with confirmation popup & top bar 2024-04-17 12:41:49 -07:00
Ryan Fleury b307d3bbed fix top bar issues 2024-04-17 11:50:38 -07:00
Ryan Fleury 8890284f97 zig lexing (syntax highlighting & hover-on-eval) 2024-04-17 11:36:01 -07:00
Ryan Fleury b41e762393 jai syntax highlighting & hover-eval support 2024-04-17 11:12:05 -07:00
Ryan Fleury 72e8ae6e30 actually do redraw on resize - need that win32 window class style.. 2024-04-17 09:58:03 -07:00
Ryan Fleury 9f4aade2e1 stepping fast-paths in top bar 2024-04-17 09:47:36 -07:00
Ryan Fleury 27fef06b6c remove unnecessary window class styles 2024-04-17 09:19:00 -07:00
Ryan Fleury 572fad1f03 first pass at custom window border 2024-04-17 08:46:21 -07:00
Ryan Fleury c31847f785 improve min sampling when applying transforms in ui 2024-04-13 12:18:01 -07:00
Ryan Fleury 9719688bb3 improve query visualization in tabs; don't collapse title before query string 2024-04-13 11:46:55 -07:00
Ryan Fleury a6bed27dff errr, reverse last change 2024-04-10 13:37:32 -07:00
Ryan Fleury b7a14aa41c explicitly show error if decoding line machine code or line info fails 2024-04-10 13:36:52 -07:00
Ryan Fleury 56bc399fd5 initial pass for compression in converter; decompression in debuggerdbgi layer 2024-04-10 09:33:55 -07:00
Ryan Fleury d560f8c734 fix backslash escaping rules in cfg serialization; fix small scrolling (e.g. from trackpad) often being truncated to having no effect; fixed hanging when set-thread-name specifies a non-readable address 2024-04-09 07:37:53 -07:00
Ryan Fleury 36b50981ff fix conditional breakpoints, post demon2/ctrl passes 2024-04-05 11:38:14 -07:00
Ryan Fleury 32114c3215 begin cleanup/naming pass over view rules 2024-04-05 10:17:38 -07:00
Ryan Fleury a8ece647c1 simplify and remove temporary polish from minified bitmap viewer 2024-04-02 15:31:02 -07:00
Ryan Fleury e0879ac569 stub out graph view rule 2024-04-02 15:18:16 -07:00
Ryan Fleury 0eb8216ea0 first pass at dedicated bitmap tab view, & all the machinery of going from watch window w/ view rule -> dedicated ui 2024-04-02 14:33:17 -07:00
Ryan Fleury cd1a0a4cb5 tab query serialization/deserialization; only enable for view rule defined view specs 2024-04-02 10:42:31 -07:00
Ryan Fleury 1b95eacd08 stub out visualizer tab view hooks for bitmap, geo, text, disasm viewers; pass down cfg node trees for open-tab command; visualize query string in tab titles 2024-04-02 10:35:19 -07:00
Ryan Fleury 546c544ae0 eliminate eval-viewer view - instead we can have the gfx view rule spec table optionally define tab view specs itself, and those can be separately registered from the sort of 'base' tab views. then we can map from gfx-view-rule -> dedicated-tab-view-spec 2024-04-02 10:16:53 -07:00
Ryan Fleury 3ea67dd7cf eliminate old disasm layer initialization 2024-04-01 15:09:41 -07:00
Ryan Fleury 52295e5e06 first pass at view rule lookup cache... this might not be the right thing here 2024-04-01 14:48:48 -07:00
Ryan Fleury 63123d69d1 set up auto view rule entities, serialization, & editor ui, for automatically mapping specific types to specific view rules 2024-04-01 14:30:48 -07:00
Ryan Fleury 835eae208a extend eval viz pipeline with split between edit/display expression strings per-block and per-row. this allows reconstruction of the string that would lead to the same eval as a row (even if it is auto-generated by e.g. expanding a root-level row; also allow -- to extend eval expressions with passthrough text, used for view rules 2024-04-01 13:56:07 -07:00
Ryan Fleury cfb34ec560 C++ namespace examples 2024-04-01 11:11:27 -07:00
Ryan Fleury c45b12cfac only export executable name, not full cmdline specified path in converter 2024-04-01 10:25:27 -07:00
Ryan Fleury 7c0ce2ab54 fix incorrect skip-to-end in new pdb -> raddbgi converter member parsing, in some cases (particularly noticeable in C++ structs with vtable members) 2024-03-30 19:44:20 -07:00
Ryan Fleury 693d20ec1a fix incorrect generation of modifier flags, container types, and out-of-order pointer/modifier types in new pdb -> raddbgi converter. fixes many 'nil type' issues, missing this ptr, etc. 2024-03-30 19:29:16 -07:00
Ryan Fleury a6db711f2d quick fix to not omit opl line records in breakpad_from_pdb 2024-03-29 15:53:18 -07:00
Ryan Fleury f2dd1e3c2d further sketching & setting up for escape-hatch-style view rule uis 2024-03-29 14:02:46 -07:00
Ryan Fleury 81c79c0ac2 sketch out parts of 'whole ui' eval viz pipeline build stage; fix copypaste issue with string viz 2024-03-29 12:52:19 -07:00
Ryan Fleury c1b92c1b27 reintroduce support for address/code-bytes toggling in disassembly view; also reintroduce support for toggle-watch-expr and goto-name commands 2024-03-29 11:51:20 -07:00
Ryan Fleury eec124c53b eliminate old text searching thread code 2024-03-29 11:28:45 -07:00
Ryan Fleury 8c5c0be040 ui: further improvements to double/triple dragging detection; df: use double/triple dragging to determine mouse-drag-range. dbl -> use token range, triple -> use line. pick appropriate side of mouse drag range on drag based on side of mark. 2024-03-29 11:17:01 -07:00
Ryan Fleury 2842901f9c ui: extend box->signal path with double-drag, triple-drag info 2024-03-29 10:58:05 -07:00
Ryan Fleury 6eb8e37d4d default to hexadecimal radix in register-mode hover-evaluations 2024-03-29 10:42:14 -07:00
Ryan Fleury 7496f3b8cc dont over-ambitiously respond to exceptions/errors on kill/detach 2024-03-29 10:22:06 -07:00
Ryan Fleury 7c3fabfc39 wchar test in mule_main 2024-03-29 10:13:29 -07:00
Ryan Fleury 4b3941c17f sketch out non-utf8 string visualization in frontend eval paths; simple retry mechanism for large memory reads that may fail across page boundaries in ctrl process memory cache 2024-03-29 10:09:57 -07:00
Ryan Fleury 60030b298b bitfield support in address mode -> value mode evaluation path 2024-03-29 09:51:38 -07:00
Ryan Fleury 60e1f105e4 raddbgi: correctly encode bitfields; type_graph: correctly stringify bitfield types 2024-03-29 09:22:13 -07:00
Ryan Fleury d9675f2565 allow assembly-style dereferences in eval parser; register/register-alias syntax highlighting 2024-03-29 08:52:46 -07:00
Ryan Fleury 7c7b44e940 attempt to auto-resolve numeric evaluations into addresses in frontend eval path 2024-03-29 08:52:45 -07:00
Mohit Sethi 6c8963cd06 Disable Alt+Enter fullscreen 2024-03-29 08:23:24 -07:00
Ryan Fleury 5aa8aa1c66 fix expandability rules for function pointer types; identifiers -> keywords in disassembly 2024-03-28 19:56:33 -07:00
Ryan Fleury 7f50beae2a notes 2024-03-28 15:40:28 -07:00
Ryan Fleury 3931edb3f1 notes 2024-03-28 15:21:25 -07:00
Ryan Fleury 1904d4ca0d support copy from disasm (finally) 2024-03-28 15:19:25 -07:00
Ryan Fleury 0ead1c034c eliminate old dasm layer, since we're all caught up with dasm_cache 2024-03-28 14:58:25 -07:00
Ryan Fleury 09f74805e0 restore old demon layer linux implementation, to not have to seek back in version control to find it when porting 2024-03-28 14:54:52 -07:00
Ryan Fleury f75ae9eb4a transition disassembly command processing paths to dasm cache 2024-03-28 14:53:38 -07:00
Ryan Fleury 2f5cc748d8 use disasm style parameters in dasm_cache disassembly path 2024-03-28 14:42:56 -07:00
Ryan Fleury 614b9bc537 extend dasm cache with style parameters; switch over primary disassembly ui path to dasm cache 2024-03-28 14:38:35 -07:00
Ryan Fleury bcbb4142cf plug in x64 intel-syntax disassembly 'language' into text analysis cache layer, to use that layer to naturally do parser/highlighter work for disassembly 2024-03-28 12:01:14 -07:00
Ryan Fleury d3570e8147 further progress on disassembly cache; instead of caching the text via the disassembly cache, simply submit into the hash store; this allows the disassembly cache to be composed with other caches, like the text analysis cache. + plug this system into the disassembly view rule, so now we can disassemble arbitrary pointers in the watch window 2024-03-28 11:36:57 -07:00
Ryan Fleury c91cd69536 first pass at new hash-store-based disassembly cache layer; can serve as a general-purpose asynchronous disassembly visualization cache layer, regardless of where that data ultimately comes from - can click into a file, process memory cache, etc. 2024-03-28 10:57:34 -07:00
Ryan Fleury f46691d79a dasm -> dasmi; make room for new dasm_cache layer 2024-03-28 09:45:41 -07:00
Ryan Fleury dbb0c1e0a4 file_stream: solidify retry mechanism; df: multiline controls for text_cache-based info, begin porting over txti-based systems 2024-03-28 09:36:09 -07:00
Ryan Fleury 96ff5efe7c allow delete/rename access on exe/debug handles 2024-03-28 08:54:08 -07:00
Ryan Fleury a14d0f5b18 rewire up target colors with processes/modules/threads; use first module path for correllation rather than entities & id correllation 2024-03-27 15:25:27 -07:00
Ryan Fleury 22185cee5f eliminate stuck-step disabling hack 2024-03-27 14:36:11 -07:00
Ryan Fleury 1da92b8dbc store per-launch entry points in ctrl entity store; use to later correllate PIDs to custom entry points in run path 2024-03-27 14:24:06 -07:00
Ryan Fleury 291bf3875d eliminate launch-and-init path, switch fully to separate 'launch' and 'run' paths; snap to selected thread if no stopper thread on stopped events; 2024-03-27 14:09:29 -07:00
Ryan Fleury ee056aa45d collapse user bp gathering helper, used only once 2024-03-27 12:29:45 -07:00
Ryan Fleury 53163f3610 ctrl: kill launch_and_handshake; begin extending run to be usable for launch-and-init and launch-and-run operations 2024-03-27 12:26:15 -07:00
Ryan Fleury 4899f1871b correctly close module file handles on module unloading in new demon layer 2024-03-27 11:19:24 -07:00
Ryan Fleury d73a3d4196 plug txt-layer-provided tokens into text view rule - both source code & text view rule are now completely powered via the txt visualization layer, rather than the special-purpose txti layer, which is now being retired 2024-03-26 16:47:15 -07:00
Ryan Fleury 4272258f99 txti -> txt; checkpoint #5 2024-03-26 16:38:12 -07:00
Ryan Fleury 8792c2280c txti -> txt; checkpoint #4 2024-03-26 16:26:31 -07:00
Ryan Fleury 88798e4453 txti -> txt; checkpoint #3 2024-03-26 16:04:21 -07:00
Ryan Fleury e80c69cb8f txti -> txt; checkpoint #2 2024-03-26 16:00:43 -07:00
Ryan Fleury 40ed36df3f txti -> txt; checkpoint #1 2024-03-26 15:31:39 -07:00
Ryan Fleury 88b692c840 eliminate fallback cache in text cache layer; we can use the hash store layer to rewind 2024-03-26 12:11:00 -07:00
Ryan Fleury 9dc484858a eliminate geo cache fallback key/hash cache; we can just use the hash store to rewind 2024-03-26 11:59:54 -07:00
Ryan Fleury f7e7aec355 bundle 'get key & stream' operation in process memory cache; eliminate old cache interaction in texture view rule hook 2024-03-26 11:55:15 -07:00
Ryan Fleury 7cf8da0b43 eliminate fallback key/hash pair cache in texture cache layer; we can rely on rewinding purely via the hash store layer 2024-03-26 11:50:44 -07:00
Ryan Fleury 4027338a2f adjust stripe counts 2024-03-26 11:30:47 -07:00
righthandprincess 3e911a8c64 Improve disabled overlay
Disabled overlay now respects the theme background color, as well as
the theme inactive overlay color, improving readability across themes.
2024-03-26 11:08:38 -07:00
Ryan Fleury 4bc82db69e deduplicate txti/text_cache language stuff; port over odin lexing 2024-03-26 11:00:37 -07:00
Ryan Fleury ca6e75d466 allow c++14 digit separators in c/c++ lexing 2024-03-26 10:42:46 -07:00
Ryan Fleury 6393766f82 deduplicate txti/txt layer lexing 2024-03-26 10:31:20 -07:00
Ryan Fleury 206d48b363 notes 2024-03-25 15:47:34 -07:00
Ryan Fleury f561abfd63 show stopper-thread exception-info on entity tooltips, when applicable 2024-03-25 15:43:00 -07:00
Ryan Fleury 6d1c0d9f6d louder & more informative exception info viz 2024-03-25 15:37:31 -07:00
Ryan Fleury 55146b547b reading & organization pass over unwinding layer; deduplicate PE info with PE layer, move dwarf info to in-progress dwarf layer 2024-03-25 14:42:54 -07:00
Ryan Fleury 1c3792a3da tighten architecture-specific path for unwinder 2024-03-25 13:34:43 -07:00
Ryan Fleury e5df25b314 use stderr-based fatal crash reporting, rather than windows gui, with programs built as console interfaces rather than guis 2024-03-25 13:24:00 -07:00
Ryan Fleury 23c1ea0e68 ui: if only one view scroll axis is specified on a box, always use scroll info to fill it, regardless of which axis that scroll took place on 2024-03-25 13:02:17 -07:00
Ryan Fleury aa85b2cdbb correctly pass unicode environments to launched child processes; also treat unicode command line arguments correctly 2024-03-25 12:57:00 -07:00
Ryan Fleury e136a67535 demon/win32: correctly report exception repetitions for unhandled exception cases 2024-03-25 11:00:00 -07:00
Ryan Fleury 83ecb4b86a ctrl thread stepping machine: read initial stack-pointer-check-value *before* single-stepping stuck threads, otherwise we can obtain an incorrect stack check value if the single-step causes a call. 2024-03-22 17:27:54 -07:00
Ryan Fleury c26274ac70 disable single-step-stuck-thread behavior when launching-and-initing, such that breakpoints on entry point will not be stepped over 2024-03-22 17:17:08 -07:00
Ryan Fleury 995804cc78 demon2 -> demon; eliminate original demon layer 2024-03-22 16:33:48 -07:00
Ryan Fleury c9df04ca60 merge 2024-03-22 16:31:05 -07:00
Ryan Fleury 71f3d18bf7 notes 2024-03-22 16:30:04 -07:00
Ryan Fleury 928532f386 do not attempt to refresh tls base calculation cache, if targets running 2024-03-22 16:29:50 -07:00
Ryan Fleury 7cd524d39d fix tls base calculation in demon2 2024-03-22 16:19:35 -07:00
Ryan Fleury 2c8c9a497c parameterize ctrl thread registers cache with entity store, rather than relying on implicit demon-api-provided cache 2024-03-22 16:15:20 -07:00
Ryan Fleury c636e1ad2e extend demon2 with explicit separation between blocking ctrl mechanisms & passive access/introspection/writing mechanisms; extend demon2 api with access mechanism 2024-03-22 15:53:04 -07:00
Ryan Fleury 07bbf1b43c organize demon2 by thread api 2024-03-22 15:15:33 -07:00
Ryan Fleury ca01e66ea2 plug in tls root vaddr path 2024-03-22 14:12:40 -07:00
Ryan Fleury 14ac7141e7 double buffer member cache 2024-03-22 13:53:14 -07:00
Ryan Fleury 9de678ec22 disable debug heap by default; get unwindg path off caching layers & use demon reads directly 2024-03-22 13:51:26 -07:00
Ryan Fleury e9129975e3 double buffer locals cache & tls base cache; introduce synchronizing mechanism for run vs. non-run ctrl thread states, to only attempt demon reads/queries during non-running times 2024-03-22 13:32:22 -07:00
Ryan Fleury 3994adae92 double-buffer frontend unwind cache 2024-03-22 11:56:28 -07:00
Ryan Fleury 982f2b6bab extend process memory cache queries with output channel for staleness detection - in some cases this is crucial, in other cases you don't care & want to passively accept stale redsults 2024-03-22 10:33:20 -07:00
Ryan Fleury a694a77eba fix halting, unattached running, and caching generations in demon2 2024-03-21 16:49:34 -07:00
Ryan Fleury 54677e05ec fix incorrect metagen pointer comparisons 2024-03-21 16:21:17 -07:00
Ryan Fleury 236214db25 eliminate unnecessary layers in frontend 2024-03-21 16:13:01 -07:00
Ryan Fleury 2c9ff37b2c sketch out new unwind cache types 2024-03-21 13:53:12 -07:00
Ryan Fleury 1466b27385 tweak registers cache lookup rules, to correctly return stale results on failed reads 2024-03-21 11:48:48 -07:00
Ryan Fleury e0e84c2ee3 further progress on integrating new demon layer 2024-03-21 11:28:47 -07:00
Ryan Fleury c2709d78b8 dont over-ambitiously consider the unwind cache up-to-date if some thread unwinds failed 2024-03-17 12:21:57 -07:00
Ryan Fleury 1269b93588 fix unchecked zero pointers in bake string map joining task, when zero pointers are legal 2024-03-17 12:17:22 -07:00
Ryan Fleury 14d3037aec raddbgi_breakpad_from_pdb: add a few missing null checks for edge cases 2024-03-17 12:17:22 -07:00
Ryan Fleury fbf4cce0e7 make tpi hash parsing gracefully exit on empty input data 2024-03-17 12:17:21 -07:00
Ryan Fleury d3cdb97a4e notes 2024-03-17 12:16:40 -07:00
Ryan Fleury 808d26684e fix unchecked zero pointers in bake string map joining task, when zero pointers are legal 2024-03-15 14:16:30 -07:00
Ryan Fleury 8f0e39024f fix additional demon2 typo 2024-03-14 21:24:12 -07:00
Ryan Fleury aa7c30d85b ctrl: first pass at new thread registers cache; also checkpoint for progress on moving to new demon layer 2024-03-14 21:09:43 -07:00
Ryan Fleury 22e6352056 raddbgi_breakpad_from_pdb: add a few missing null checks for edge cases 2024-03-13 15:25:05 -07:00
Ryan Fleury 2fff68cfcf make tpi hash parsing gracefully exit on empty input data 2024-03-13 15:10:39 -07:00
Ryan Fleury 936c6149e3 remove timeout on thread register cache accessor 2024-03-12 16:35:43 -07:00
Ryan Fleury c417f15912 fix task entry points in breakpad converter 2024-03-12 16:01:30 -07:00
Ryan Fleury ea74f928cd fix process memory cache query mechanism when ring buffer is near capacity 2024-03-12 15:51:26 -07:00
Ryan Fleury 871419de39 bugfixes in new demon layer; adjust retry mechanism in process memory cache query; ui fixes 2024-03-12 15:49:36 -07:00
Ryan Fleury 8639faabdd ctrl entity string allocation & tracking, for thread names & module names; fix process memory cache in edge cases 2024-03-12 14:56:02 -07:00
Ryan Fleury d1e88f781e tweak ctrl entity building to be bucketed per 'entity store' - we can now have multiple 'entity stores', one on the frontend thread, one on the ctrl thread, and keep them in sync at specific points via event lists 2024-03-12 14:20:24 -07:00
Ryan Fleury 4a3cc9bb39 get raddbg building on new demon layer 2024-03-12 13:55:13 -07:00
Ryan Fleury 2749301777 checkpoint - moving ctrl mostly over to demon2; sketching out a few missing cache pieces 2024-03-12 11:41:53 -07:00
Ryan Fleury 90d9f3b7c2 fix task entry points in breakpad converter 2024-03-12 09:05:00 -07:00
Ryan Fleury 49ccf50fd4 first pass at integrating new demon2 layer into debugger, need to change ctrl a bit to adopt some of the things that were previously being left up to demon layers 2024-03-08 12:49:06 -08:00
Ryan Fleury 0d0c599e00 begin process of moving pe unwinding info into pe layer; more demon2 work checkpoint 2024-03-05 16:54:57 -08:00
Ryan Fleury e25364a835 strip out some unnecessary apis from the demon layer, since we'll be doing per-entity caching in ctrl and keep demon as close to a thin abstraction as possible 2024-03-05 14:55:49 -08:00
Ryan Fleury f85718f1e2 fix eval header 2024-03-05 14:48:23 -08:00
Ryan Fleury 4074551a1a hook up demon2 initialization to base layer entry point 2024-03-05 14:27:40 -08:00
Ryan Fleury 0c436f0d5b first pass at demon replacement layer; just trimming out old code & cruft & reading & naming pass 2024-03-05 14:17:41 -08:00
Ryan Fleury 091269b1d8 eliminate synchronous per-thread string map building, just do it as-needed on each thread; 2024-03-04 11:53:12 -08:00
Ryan Fleury 4d6860b3a1 raddbgi_from_pdb/raddbgi_make: kill old synchronous string map code; naming pass 2024-03-04 11:14:54 -08:00
Ryan Fleury 778f4eb08d raddbgi_from_pdb: complete initial parallelization pass over string map building, joining, & sorting 2024-03-04 11:02:48 -08:00
Ryan Fleury 0ad795ba4c eliminate old udt string baking kickoff code 2024-03-01 11:36:03 -08:00
Ryan Fleury ac22e24841 raddbgi_from_pdb: switch string baking to using fixed per-thread maps, rather than per-task maps 2024-03-01 11:21:30 -08:00
Ryan Fleury 2fc0b4eac2 extend task system with thread count, so usage code can easily create per-thread state; pass thread idx into task entry points 2024-03-01 11:08:00 -08:00
Ryan Fleury 7eca2a35cd raddbgi_dump: dump string table 2024-02-29 11:04:53 -08:00
Ryan Fleury 1ea3a14a50 shift to slice-granularity of string map gathering, rather than chunk-granularity - gives a bit more flexibility. set up pdb converter type name gathering tasks for slice subdivision. before going forward with this plan it's imperative that we start sparsely allocating these name maps... 2024-02-28 16:48:25 -08:00
Ryan Fleury a38742d80b adjust string map sorting tasks to be wide, but less granular than per-slot; divide up table into chunks 2024-02-28 16:18:11 -08:00
Ryan Fleury e94b530758 new bake string map gathering/merging passes & async usage in converter 2024-02-28 15:51:17 -08:00
Ryan Fleury 0916c2a3c8 first pass at bake string chunk list, bake string chunk list map, and bake string chunk list sorting paths/datastructures - basic machinery for going wide on the string/name map builds 2024-02-28 13:27:48 -08:00
Ryan Fleury 56690a703f fix padding insertion pass over members gathering 2024-02-27 06:35:11 -08:00
Ryan Fleury bb0ebb5df2 raddbgi prefix on breakpad converter 2024-02-26 17:01:52 -08:00
Ryan Fleury 70d004e5d3 clean up command line arguments & help in converters 2024-02-26 16:49:57 -08:00
Ryan Fleury 3b7a4f3331 clean up pdb -> raddbgi converter parameters; extend conversion parameterization with optional type/udt disabling; use in breakpad converter 2024-02-26 14:11:26 -08:00
Ryan Fleury 1c2c82cc58 breakpad_from_pdb per-function line info writing 2024-02-26 13:34:33 -08:00
Ryan Fleury 03763e3444 raddbgi_from_pdb/raddbgi_make: split top-level units baking from per-unit baking; do per-unit baking wide 2024-02-26 12:15:18 -08:00
Ryan Fleury d9897161c2 first half of first pass at breakpad textual symbol info format exporter 2024-02-26 11:49:19 -08:00
Ryan Fleury 874f40244c eliminate per-executable initialization, just pull that down into the base layer entry point 2024-02-26 10:45:00 -08:00
Ryan Fleury 443c3fb74b get dwarf -> raddbgi converter on new entry point style 2024-02-25 15:03:27 -08:00
Ryan Fleury 8eb0f90f3e move to codebase-defined entry point style, with basic command line argument parsing, capture, thread-ctx, and other boilerplate deduplicated in the base layer's entry point definition 2024-02-25 15:02:05 -08:00
Ryan Fleury dd05eaa21e sketch out some codebase-wide standard thread entry point boilerplate 2024-02-25 14:13:27 -08:00
Ryan Fleury 93ab48ecdf organization/naming/dead-code-elimination pass over base 2024-02-25 14:00:35 -08:00
Ryan Fleury 3ec1edaff1 oops, fix clang 2024-02-25 13:33:27 -08:00
Ryan Fleury d8cf83b4d7 pull out & organize build configuration options, including entry point style, to context cracker 2024-02-25 13:30:15 -08:00
Ryan Fleury c4b8916bcf raddbgi dump - fix bad condition 2024-02-25 09:59:56 -08:00
Ryan Fleury 642acdf474 switch voff -> symbol name path to graceful failure RDI lookups 2024-02-25 09:57:51 -08:00
Ryan Fleury 7c9f127425 cleanup/naming pass over raddbgi_dump, do not require specific named params 2024-02-24 22:03:08 -08:00
Ryan Fleury 93c0e657fd eliminate old test files 2024-02-24 20:08:44 -08:00
Ryan Fleury 10ab27eb43 oops - actually respect operating system file system match flags in dbgi layer 2024-02-24 18:16:59 -08:00
Ryan Fleury 4c76eb73f1 respect operating system file system case sensitivity rules in dbgi layer 2024-02-24 14:04:41 -08:00
Ryan Fleury d9aa49e45c respect wait timeouts in task system join 2024-02-23 12:17:57 -08:00
Ryan Fleury 4da33c0d2c eliminate noop in ui layout pass 2024-02-23 11:21:47 -08:00
Ryan Fleury dd0416f9f9 fix nil expressions mapping to valid expression kinds, thus implying children nodes 2024-02-23 11:18:53 -08:00
Ryan Fleury c1984edadf dont over-eagerly join udt building tassk 2024-02-23 11:13:12 -08:00
Ryan Fleury ac8a7ba988 fix enumerate gathering in new udt building pass 2024-02-23 11:07:09 -08:00
Ryan Fleury 6beb9951e6 adjust default task sizes in raddbgi_from_pdb 2024-02-22 16:54:39 -08:00
Ryan Fleury 5813cb2af8 proper thread names 2024-02-22 16:20:27 -08:00
Ryan Fleury 74d051f383 walk args as dependent types for member function types 2024-02-22 15:51:18 -08:00
Ryan Fleury 7facfb7d08 kill single threaded udt conversion code 2024-02-22 15:50:07 -08:00
Ryan Fleury fe1e0cc2fd move udt info conversion to task threads, divide up itype stream and do it wide 2024-02-22 15:49:46 -08:00
Ryan Fleury bcbd01bf2c eliminate type revisiting task list, just iterate itypes again - in preparation for dividing up the itype stream and doing udt building in parallel 2024-02-22 15:37:50 -08:00
Ryan Fleury 34f500ce27 push unit conversion & src file gathering to background task threads; dont preemptively join initial independent parses until they are necessary 2024-02-22 15:11:13 -08:00
Ryan Fleury 0e352f92df separate per-name-map baking stages from each other, and from top-level name map section build; do them all independently 2024-02-22 14:45:09 -08:00
Ryan Fleury 50f7d53db2 eliminate unnecessary copy in raddbgi string map interner 2024-02-22 14:15:23 -08:00
Ryan Fleury b508489416 clean up old transitionary code 2024-02-22 10:03:26 -08:00
Ryan Fleury d2adf3e067 extend task system with ability to specify per-task arenas, if needed - not necessary in the converter, since it is fire-and-forget, but this will make it more useful for the debugger later 2024-02-22 09:48:19 -08:00
Ryan Fleury a5493d5edb appease the clang gods 2024-02-21 16:48:22 -08:00
Ryan Fleury c7e80ee135 raddbgi_from_pdb: move all top-level baking phases to task system threads. still a lot of improvement to do, these are top-level tasks and there is a lot of work *within* these tasks that is happening serially unnecessarily, but this is a good first step to parallelizing the bake. 2024-02-21 16:27:29 -08:00
Ryan Fleury 6a49672904 raddbgi_from_pdb: idx run baking; raddbg: catch up to new converter interface 2024-02-21 15:23:35 -08:00
Ryan Fleury 2dd4526dd9 raddbgi_from_pdb: path tree & string baking 2024-02-21 15:12:08 -08:00
Ryan Fleury f2cf518231 raddbgi_from_pdb: name map baking, small fixes with new baking strategy 2024-02-21 14:55:50 -08:00
Ryan Fleury 41b1f1c7e3 raddbgi_from_pdb: organize new baking path, which does all independent section list builds separately; do first pass of baked string map building 2024-02-21 14:36:15 -08:00
Ryan Fleury f93b71d8c3 raddbgi_from_pdb: untangle all baking stages - move almost all baking stages to a strictly read-only path of strings, idx runs, and so on. make section layout, given some loose input baking params, completely deterministic & well-defined, such that section list building for each stage of baking can be completely independent 2024-02-21 13:43:56 -08:00
Ryan Fleury 25ef98a98c raddbgi_make: eliminate old bake src files, switch over completely to user-specified src files; enforce nil entries in all tables for all cases 2024-02-21 10:36:22 -08:00
Ryan Fleury 529262d471 begin untangling source file & path tree building in converter/maker/baker; this cannot happen as another implicitly-mutated-context thing that magically happens behing a top-level 'baking' function. instead, this needs to be constructed according to the rules of the user, and passed to baking stages as a batch 2024-02-20 16:32:09 -08:00
Ryan Fleury 7581a6866d raddbgi_from_pdb: overlap link name map building with type info building, since they are independent streams of work 2024-02-20 15:13:22 -08:00
Ryan Fleury 923714c3c9 raddbgi_make: split final blob flattening & encoding from 'baking' phase 2024-02-20 14:07:58 -08:00
Ryan Fleury b8a4aeac39 raddbgi_from_pdb: offload c13 line info parsing to task threads 2024-02-20 13:16:52 -08:00
Ryan Fleury e7ab92e07c raddbgi_from_pdb: move comp unit contributions parsing out to task threads; move per-comp-unit top-level symbol parsing to task threads 2024-02-20 13:09:23 -08:00
Ryan Fleury 53bc258c4a raddbgi_from_pdb: move itype dependency chain building to task threads 2024-02-20 12:58:04 -08:00
Ryan Fleury 7e36c25a31 fix more async fwd map building bugs; move symbol stream conversion to task system 2024-02-20 12:04:57 -08:00
Ryan Fleury 66ef1b3eeb raddbgi_from_pdb: move top-level compilation unit parsing to asynchronous tasks 2024-02-20 11:30:01 -08:00
Ryan Fleury 6b2e4abe81 unify async task kickoff/await mechanism in first pass of 'task system' layer; use in organizing various independent parsing passes of a pdb; also fix busted multithreaded fwd resolution pass 2024-02-20 11:16:54 -08:00
Ryan Fleury 10a0420264 raddbgi_from_pdb: parameterize symbol stream conversion pass with sub-range of symbols; this cannot be applied to unit conversion, since they have cross-sym-record concepts, but it *can* be used for global symbol streams, which are also the most expensive to convert. this majorly speeds up global symbol stream conversion 2024-02-19 16:41:22 -08:00
Ryan Fleury 0b73582b87 raddbgi_from_pdb: multithread initial independent parsing/preparation phases of converter 2024-02-19 15:52:26 -08:00
Ryan Fleury 8369637026 raddbgi_from_pdb: multithread itype forward resolution map building 2024-02-19 15:07:25 -08:00
Ryan Fleury 86ee3cb4b6 raddbgi_from_pdb: multithread per-unit symbol conversion 2024-02-19 14:42:13 -08:00
Ryan Fleury 5cd5503db1 raddbgi_make: adjust baking-phase bucket counts based on estimates from parameters 2024-02-19 12:13:42 -08:00
Ryan Fleury 29c21b43af fix busted vmap section size 2024-02-19 11:52:28 -08:00
Ryan Fleury f7f57a2c7a fix enumerate parsing 2024-02-19 11:18:34 -08:00
Ryan Fleury 694e9d27d6 raddbgi_from_pdb: adjust itype -> type node building strategy; do initial pass of finding dependent itypes from a given itype, since those *must* be built first in order to comply with raddbgi's rule of type nodes only ever referencing earlier type nodes; then do a single itype build pass where you build all itypes by iterating their dependency chains 2024-02-19 11:13:29 -08:00
Ryan Fleury e44128de96 bugfix udt member parsing 2024-02-17 21:26:23 -08:00
Ryan Fleury b93bb5904a more itype generation fixes 2024-02-17 17:14:11 -08:00
Ryan Fleury cfe089de8c eliminate forward reference parsing work in non-forward-reference cases 2024-02-17 12:31:15 -08:00
Ryan Fleury e752eebfc9 fix itype conversion 2024-02-17 10:50:56 -08:00
Ryan Fleury d0fe5b9e04 raddbgi make: export scope voffs section 2024-02-17 10:36:07 -08:00
Ryan Fleury c790ee3de0 fix reversed-order path building 2024-02-17 08:44:55 -08:00
Ryan Fleury 4f9e3bb4f5 clean up / debugging / bugfixes in new converter 2024-02-17 08:41:27 -08:00
Ryan Fleury e9d2cb82b2 eliminate all old raddbgi_make and raddbgi_from_pdb code 2024-02-16 13:46:55 -08:00
Ryan Fleury 5190530417 oops, remember units... 2024-02-16 13:44:42 -08:00
Ryan Fleury 626ad29b91 converge raddbg to new conversion/raddbgi-make layers 2024-02-16 13:39:52 -08:00
Ryan Fleury 178719c479 transfer over idx run baking 2024-02-16 13:35:00 -08:00
Ryan Fleury 9cccabfa21 transfer over string baking 2024-02-16 13:33:45 -08:00
Ryan Fleury 3735e82579 source file baking 2024-02-16 13:31:58 -08:00
Ryan Fleury 75263c5833 path node tree baking 2024-02-16 13:29:26 -08:00
Ryan Fleury c64fba90a1 transfer over name map baking 2024-02-16 13:26:43 -08:00
Ryan Fleury 3fb632c23d raddbgi_make: name maps 2024-02-16 13:11:57 -08:00
Ryan Fleury 7597bccd46 raddbgi from pdb: fix chunk list concats 2024-02-16 12:51:17 -08:00
Ryan Fleury 335f22e00b raddbgi_make & raddbgi_from_pdb: solve multithreaded 'indexing' problem - how do we correllate loose pointer relationships, constructed by various threads, with final indices in the baked file 2024-02-16 11:53:03 -08:00
Ryan Fleury a38241ebe0 raddbgi_make: overrideable profile macros; raddbgi_from_pdb: itype name resolution, link anme resolution 2024-02-16 11:18:48 -08:00
Ryan Fleury 5ae9259253 raddbgi_from_pdb: global variable, thread variable, procedure, scope, local, location info baking 2024-02-16 09:04:15 -08:00
Ryan Fleury 7646487a90 raddbgi_from_pdb: type info baking 2024-02-16 07:28:55 -08:00
Ryan Fleury e8ca548360 transfer over unit vmap baking 2024-02-15 16:11:24 -08:00
Ryan Fleury 5f1ab8fdb4 move over per-source-file line info baking 2024-02-15 15:56:20 -08:00
Ryan Fleury c3c1906d43 first pass over raddbgi make baking phase rewrite/cleanup pass, getting off of old cons API 2024-02-15 15:44:24 -08:00
Ryan Fleury a9c5ec8878 symbol conversion passes in new converter 2024-02-15 12:00:02 -08:00
Ryan Fleury a118ff79cd partial first pass over converter & raddbgi make layer rewrites/optimizations 2024-02-14 13:34:39 -08:00
Ryan Fleury f18e236431 a few more raddbgi, raddbgic -> rdi, rdim notes 2024-02-13 16:06:56 -08:00
Ryan Fleury 816f94ef71 further raddbgi -> rdi naming pass 2024-02-13 15:56:30 -08:00
Ryan Fleury b9f010dff6 raddbgi_ -> rdi_ 2024-02-13 15:52:53 -08:00
Ryan Fleury 30d2dea951 complete raddbgi_cons -> raddbgi_make 2024-02-13 15:38:38 -08:00
Ryan Fleury 87d9d0be05 readme 2024-02-13 15:37:27 -08:00
Ryan Fleury db35e09629 raddbgic -> rdim (rad debug info make) 2024-02-13 15:36:06 -08:00
Ryan Fleury 90dce510cc raddbgi_from_pdb: eliminate unnecessary files 2024-02-13 15:16:42 -08:00
Ryan Fleury fb56951264 collapse raddbgi_convert folder into just being separate from_pdb and from_dwarf layers 2024-02-13 15:12:40 -08:00
Ryan Fleury ecd21d0c1b pdbconv -> p2r 2024-02-13 15:05:46 -08:00
Ryan Fleury 67859f228b fix parse error checks in raddbgi_from_pdb 2024-02-13 14:37:59 -08:00
Ryan Fleury 348034a490 reading/cleanup/organization pass over main symbol conversion pass in raddbgi_from_pdb; automate & table-drive a few pieces via metacode tables 2024-02-13 14:26:01 -08:00
Ryan Fleury 725481fcc7 fix codeview struct 2024-02-13 13:36:15 -08:00
Ryan Fleury 608055e447 metagen: simplify catchall generations; move some codeview enums into metacode; generate enum->string code 2024-02-13 13:27:02 -08:00
Ryan Fleury 66a24a226a adjust contain -> center cursor threshold 2024-02-13 11:42:20 -08:00
Ryan Fleury 9c7fd0a411 metagen: simplify & straighten out table generation further; raddbgi_cons: fix incorrect str8_list_join 2024-02-13 11:38:43 -08:00
Ryan Fleury 348e93162a metagen: simplify & unify error gathering & printing path 2024-02-13 11:26:31 -08:00
Ryan Fleury 1d9dc2b9a9 metagen: simplify data tables 2024-02-13 11:16:45 -08:00
Ryan Fleury 742d2387e2 metagen: simplify metacode structs 2024-02-13 11:00:58 -08:00
Ryan Fleury ea840a71e8 metagen: simplify enum generation; reading/organization pass over raddbgi_from_pdb 2024-02-13 10:55:06 -08:00
Ryan Fleury 4a9e5512f6 fix this_function_name macro 2024-02-13 09:56:46 -08:00
Ryan Fleury ac30c8a84b add codeview/msf/pdb notes to readme 2024-02-13 09:53:52 -08:00
Ryan Fleury 7defce94c7 float codeview, msf, pdb layers up as regular codebase layers, and out of converter-specific code; clangify some builds 2024-02-13 09:51:50 -08:00
Ryan Fleury 017116aee9 formalize codebase's library exports; document in README 2024-02-13 09:27:52 -08:00
Ryan Fleury 8c70b5efc9 raddbgi_cons: get building standalone, without base layer; complete first pass of librarification 2024-02-13 08:58:10 -08:00
Ryan Fleury 4aa2cb655b further progress on raddbgi cons librarification 2024-02-12 21:05:05 -08:00
Ryan Fleury 440dcf21a2 further raddbg_cons librarification 2024-02-12 20:32:20 -08:00
Ryan Fleury 2a85e1d37d raddbgi cons: more overrides work 2024-02-12 19:10:31 -08:00
Ryan Fleury 7022c58018 begin libraryifying raddbgi_cons; switch to raddbgi_format types, or overrideable base-layer-style types; just override & include in codebase-local inclusion sites. next step is to break out this stuff, along with stringization, into a raddbgi helper layer 2024-02-12 16:17:54 -08:00
Ryan Fleury 840e1da5f3 update github workflows to new debug info naming 2024-02-12 15:26:06 -08:00
Ryan Fleury 02825f3b3e move raddbgi stringize into standalone layer 2024-02-12 15:22:41 -08:00
Ryan Fleury cf19b13b78 dump -> raddbgidump 2024-02-12 15:19:20 -08:00
Ryan Fleury ad4003e70d cons -> raddbgic 2024-02-12 15:17:23 -08:00
Ryan Fleury 5c33c410d3 flatten cons api; eliminate private/public distinction 2024-02-12 15:11:20 -08:00
Ryan Fleury d35bdf2128 adjust readme for new debug info naming convention 2024-02-12 15:08:40 -08:00
Ryan Fleury aa2a0948ba raddbg -> raddbgi 2024-02-12 15:03:13 -08:00
Ryan Fleury 4b68967fbe raddbg format stuff -> raddbgi; partial naming/organization over raddbgi_cons 2024-02-12 14:29:24 -08:00
Ryan Fleury cc26a22e40 apply cancel/ok ordering note from jeff 2024-02-12 10:33:04 -08:00
Ryan Fleury 4fde6addc4 raddbg_cons: parameterize bake ctx with bucket sizes; make initial prediction based on symbol count 2024-02-11 13:29:06 -08:00
Ryan Fleury 60b6e2d597 Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-02-11 09:23:37 -08:00
Ryan Fleury e5c35a4035 oops! fix wrong type fwd reference condition 2024-02-11 09:23:16 -08:00
Ryan Fleury 47bb3464e1 oops! 2024-02-11 09:23:06 -08:00
Ryan Fleury 2e8afad5f0 adjust conversion visualization; strip out old profiling markup 2024-02-10 19:40:19 -08:00
Ryan Fleury e7897f302f do some more fine tuning of symbol id hash functions used in pdb -> raddbg path; also eliminate unnecessary per-type work 2024-02-10 18:25:47 -08:00
Ryan Fleury c81ee6d9bc extend id -> handle cons APIs with separate hash channel, so usage code completely controls both unique IDs and how they're hashed; second pass at designing better local variable hashing function 2024-02-10 16:21:55 -08:00
Ryan Fleury 801518ea75 improve local map hash 2024-02-09 18:02:44 -08:00
Ryan Fleury ebfddabd0b raddbg cons: extend u64 -> ptr map api with separate channel for hash, which reduces scan space, independently from unique keys which were previously assumed to be a reasonable hash (which they weren't) 2024-02-09 16:59:42 -08:00
Ryan Fleury 6c872566af raddbg_from_pdb: greatly improve speed of line info combining pass; do not linearly scan for line numbers, use line as hash -> slot key and search only slots 2024-02-09 15:31:24 -08:00
Ryan Fleury 44d9b57eb5 track bucket collision counts, include in table diagnostics dump; finish moving pdb->raddbg conversion tables over to dynamic & heuristically chosen table sizes 2024-02-09 14:55:07 -08:00
Ryan Fleury cdb53ebed0 pdb -> raddbg table diagnostic dumping 2024-02-09 12:59:06 -08:00
Ryan Fleury 2d63234c92 eliminate static, absurdly large table sizes in all cases in pdb->raddbg path; markup & diagnostics of table sizes vs. counts, to begin gathering data for table size prediction path 2024-02-09 11:50:04 -08:00
Ryan Fleury 7f357b264c os_gfx_win32: fix preservation of sign info in x/y lparams for mouse events 2024-02-08 17:05:24 -08:00
Ryan Fleury 11dd5fd21a fix dragging interpretation in ui box -> signal path 2024-02-08 15:10:53 -08:00
Ryan Fleury 77337f9e86 use globals, thread-locals, types, procedures in default panel layout 2024-02-08 10:37:08 -08:00
Ryan Fleury 95a6579f89 expand eval machine interpretation error codes; visualize 2024-02-08 10:28:41 -08:00
Ryan Fleury fed0a13aca eliminate leftover events system, since ui codepaths should now consume as many events as possible within a single frame 2024-02-08 10:09:51 -08:00
Ryan Fleury 6e3242848f wm_mousewheel and wm_mousehwheel report mouse coordinates in screen space, not client space; fix to account fo rthat 2024-02-08 10:05:29 -08:00
Ryan Fleury 2967d8be2a fix double assignment to strtable buckets_min in raddbg_pdb 2024-02-08 04:12:29 -08:00
Ryan Fleury 3a811e5e16 middle click -> close tabs 2024-02-07 16:49:05 -08:00
Ryan Fleury 0bced47404 eliminate old ui box -> signal path 2024-02-07 16:47:21 -08:00
Ryan Fleury c637ad6ede rewrite ui box -> signal path for less lossy event processing & correctness; also extend to use all 3 mouse buttons. eliminate ui signal bitfields, just use flags & helper macros everywhere. 2024-02-07 16:46:57 -08:00
Ryan Fleury b9cec99cd4 ui code -> extend 'active' system to all left/middle/right mouse buttons, rather than just min/max (left/right) 2024-02-07 14:20:21 -08:00
axeldaguerre fb9e890653 fix utf8 encoding missing one bit shift
For Unicode code point in the highest range, 1 bit shift operation on the 4th byte is missing, giving a wrong encoding
2024-02-07 13:54:58 -08:00
Ryan Fleury 2c73c65878 remove debug 2024-02-07 13:35:34 -08:00
Ryan Fleury 390aab2699 raddbg from pdb: correctly parse several c13 files in single c13 subsection, rather than just assuming a single one 2024-02-07 13:35:14 -08:00
Ryan Fleury ccec64750d fix raddbg_dump build 2024-02-07 12:59:56 -08:00
Ryan Fleury e637f7237c straighten out a few key stability issues in eval watch views; editing expressions will no longer eliminate view rules; stale view rules will no longer find their way into inserted expressions 2024-02-07 10:32:24 -08:00
Ryan Fleury c757388bb4 fix serialization/deserialization of top-level watch view rules 2024-02-06 15:38:42 -08:00
Ryan Fleury fb43eb9c72 default to no d3d11 debug features; use command line flag to enable 2024-02-06 14:59:41 -08:00
Ryan Fleury 9ef1b4b021 fix system processes lister fuzzy matching; fix ctrl layer locking modules on detach (demon was not reporting module string!) 2024-02-06 13:59:43 -08:00
Ryan Fleury 7305c12166 reset control context unwind count when submitting all runs 2024-02-06 13:48:05 -08:00
Ryan Fleury e3f18d3b87 fix mutable eval root key stability w.r.t. view rules & so on 2024-02-06 13:28:14 -08:00
Ryan Fleury 86e332f2ef allow compound macro expressions in eval system; poison used macro names, before descending 2024-02-06 11:55:51 -08:00
Ryan Fleury 6296d2bd96 first pass of watch window macros; fix active-but-disabled line edit rendering; other minor fixes 2024-02-06 11:47:52 -08:00
Ryan Fleury c2d96a8df6 pull out eval watch view cursor state; begin prepping for multirow table selection 2024-02-06 09:21:14 -08:00
Ryan Fleury c0cf0bf2da fix small visual issues with hover eval 2024-02-06 08:55:55 -08:00
Ryan Fleury 87ed6a8c62 per-run tls base vaddr cache; cleanup/fixes/improvements on fuzzy filtering of scheduler view 2024-02-06 08:48:09 -08:00
Ryan Fleury 0696eab974 address some jank with query view focuses intermixing with deselection/hover-eval/etc. 2024-02-06 07:35:51 -08:00
Martins Mozeiko 9c02f947c7 show git commit id in window title & fatal exception dialog 2024-02-06 07:30:58 -08:00
Ryan Fleury 816bf195c2 more filtering coverage; fuzzy filtering on search tags as well as entity display string; display a few known frames from callstack in thread entity description buttons 2024-02-05 14:36:33 -08:00
Ryan Fleury 95b8b71322 dedup multiple unwinder paths; just collapse down to using the ctrl one 2024-02-05 14:06:06 -08:00
Ryan Fleury ef317c1ffc procedures view 2024-02-05 13:58:19 -08:00
Ryan Fleury 9504946376 entity view filtering 2024-02-05 12:08:50 -08:00
Ryan Fleury e03e1dd136 eval lexer: same as last 2024-02-05 11:28:29 -08:00
Ryan Fleury 0b6b0947ed eval lexer: allow a few more corner cases of various compiler/linker-inserted identifiers, so that eval works in all cases 2024-02-05 11:26:37 -08:00
Ryan Fleury 38b8bfd6fb fix ordering of event consumption w/ filter box 2024-02-05 11:24:31 -08:00
Ryan Fleury 87e0e9a7e9 bugfix truncated string hover rule 2024-02-05 11:19:34 -08:00
Ryan Fleury 6e874c7449 syschar -> defwindowproc 2024-02-05 11:07:36 -08:00
Ryan Fleury d2d3d14c41 demon/win32: roll back on all hit traps, even if explicit. the previous implementation would silently skip threads past explicit traps that they hit, as a way of implicitly storing the fact that trap exceptions had been reported, and the user could continue past them. this resulted in incorrect instruction pointer display in those circumstances. this change adjusts this, so that after a trap exception of any kind, the instruction pointer is ALWAYS rolled back. to ensure that the trap is not repeatedly hit, if the associated exception has already been reported, to allow the user to e.g. step over traps (this is the behavior of Visual Studio), additional state is stored per-thread-entity, which allows a subsequent demon_os_run to adjust RIPs past their previously reported traps before running again. 2024-02-05 10:47:57 -08:00
Ryan Fleury 2359c82fba extend ctrl process memory cache with waiting mechanism; employ to wait for changes to propagate through process memory cache, when forcibly mutating debuggee process memory 2024-02-05 10:04:00 -08:00
Ryan Fleury f2c74cbcb2 float mousemove detection & ui mouse position rules down to ui core layer 2024-02-05 09:29:50 -08:00
Ryan Fleury f03f3e4421 robustify ctrl memory streaming cache & texture cache layer to unreasonably large sizes/dimensions 2024-02-05 09:24:00 -08:00
Ryan Fleury 95eea70682 fix failure condition in entry point detection 2024-02-05 08:54:45 -08:00
Ryan Fleury 762013899f switch entry point detection/trap strategy to finding *all* possible candidates, and trapping all of them, rather than forcing the ctrl thread to decide on one specific entry point voff 2024-02-05 08:41:18 -08:00
Ryan Fleury 0be4680ec9 os_gfx -> report mouse move events; still allow passive mouse interaction if window is unfocused, but have recently received mousemove events 2024-02-03 18:04:21 -08:00
Ryan Fleury 985a6f37e9 notes 2024-02-03 17:37:39 -08:00
Ryan Fleury f9e2aa99a9 fix padding calculation - prohibit all overlapping members 2024-02-03 09:56:24 -08:00
Ryan Fleury 509089d95d remain robust to busted range queries for ctrl process memory cache 2024-02-03 09:20:31 -08:00
Ryan Fleury 647558b140 fix plural language in singular scenarios 2024-02-02 17:28:22 -08:00
Ryan Fleury cbe842c5ec dont do padding members for unions, oops 2024-02-02 17:15:55 -08:00
Ryan Fleury f796f64c2f process memory read failuer visualization in eval watch view tables 2024-02-02 17:05:55 -08:00
Ryan Fleury 36d749ddb5 slightly stronger padding visualization 2024-02-02 16:46:54 -08:00
Ryan Fleury 7e589e8cd2 padding visualization 2024-02-02 16:42:08 -08:00
Ryan Fleury 708517a668 move fuzzy range match visualization into formal ui rendering path; write dedicated truncated fuzzy match rendering path; fixes some visual bugs & makes all fuzzy range match visualization consistent and not ad-hoc 2024-02-02 15:35:44 -08:00
Ryan Fleury 876d9338fc auto-close universal ctx menus when entities/tabs invalidate; some visual fixes 2024-02-02 14:13:00 -08:00
Ryan Fleury 6897c0bb57 only show mid-row cache line boundaries when unexpanded, since the expansion will show more precise info 2024-02-02 12:53:34 -08:00
Ryan Fleury 15e239a0dc cache line boundary visualization 2024-02-02 12:47:51 -08:00
Ryan Fleury 5d3aa301f0 enum type evaluation visualization - can now use watch windows to inspect all possible enum values 2024-02-02 11:50:21 -08:00
Ryan Fleury 847749337b eval parser: more coverage for c++-compiler-generated & various C++-style identifier names 2024-02-02 11:33:06 -08:00
Ryan Fleury 542753ddcc deduplicate editability/expandability determination path for viz row build 2024-02-02 11:12:20 -08:00
Ryan Fleury 9d8efa3a44 deduplicate common parts of viz row building 2024-02-02 11:03:14 -08:00
Ryan Fleury 410a340a09 oops -> carry over dbgi target with viz block splits 2024-02-02 10:13:39 -08:00
Ryan Fleury 8958b414e2 properly parameterize viz block & viz row building paths based on dbgi table target 2024-02-02 10:09:30 -08:00
Ryan Fleury ac895a85eb eliminate old eval watch view code 2024-02-02 09:30:22 -08:00
Ryan Fleury ad57a0d3e8 stop following expansion nodes at the first non-expanded one, when converting watch view selection coords when ancestor has been collapsed 2024-02-02 09:28:15 -08:00
Ryan Fleury 20ff4acecc simplify/collapse/deduplicate eval viz block building code; correctly build filtered-info-table-sorted expansions for filtered debug info table watches; eliminate special-case empty row in watch views, just feed everything through the viz blocks path 2024-02-01 17:05:08 -08:00
Ryan Fleury be4c52b7ef first part of collapsing globals/types/threadlocals path into being single viz block building path; more filtering ui work 2024-02-01 13:54:34 -08:00
Ryan Fleury 6740520bbe straighten out table coordinates <-> viz block coordinate space mappings, since search-backed tables no longer can assume those two things are the same; clang -> o2; fix clang build 2024-02-01 13:21:07 -08:00
Ryan Fleury 28fdd791ae extend eval viz blocks & windowed row build path with optional member info - use to extend watch type info visualization with size/offset information 2024-02-01 10:59:55 -08:00
Martins Mozeiko d6608adf60 make msvc release build much faster
cl.exe for some reason spends unreasonable amount of time optimizing
df_window_update_and_render function,  we can use pragma to skip
optimization for this function
2024-02-01 09:53:14 -08:00
Ryan Fleury 45b59e4cc4 apply fuzzy filtering correctly to globals/thread-locals/types views 2024-01-31 15:06:20 -08:00
Ryan Fleury 02979ba26c first pass at equipping frontend line edit with fuzzy match range visualization; shift new debug-info-range viz block -> viz row path to using a backing filtered item array to map the abstract index space into the debug info table spaces 2024-01-31 14:54:49 -08:00
Ryan Fleury f3f0e2a697 plug in basic, half-finished filtering functionality to watch/locals/registers/types/globals/threadlocals views 2024-01-31 14:35:14 -08:00
Ryan Fleury 630272ec37 expand dbgi asynchronous fuzzy matching system to allow selection of target table; this allows asynchronous fuzzy matching over types, globals, thread locals, and procedures 2024-01-31 14:22:12 -08:00
Ryan Fleury 41b853b874 simplify fuzzy matching path to a single query 2024-01-31 14:07:16 -08:00
Ryan Fleury 071ff82673 introduce general-purpose filtering path for tabs; control whether or not it is enabled via view spec flags. + feature flags for automatically bring up filtering box when typing 2024-01-31 14:01:53 -08:00
Ryan Fleury 9106190893 first pass at types view 2024-01-31 12:31:09 -08:00
Ryan Fleury 8602e5b23e first pass at thread-locals view 2024-01-31 12:24:57 -08:00
Ryan Fleury c8010b7542 first pass at globals view 2024-01-31 12:17:43 -08:00
Ryan Fleury edb204bc5f eliminate old expand-key-based eval history - ctrl process memory cache offers much better comprehensive replacement. also eliminate per-row and per-block eval views, since we've collapsed all eval views to one per list-of-watch-trees 2024-01-31 11:12:59 -08:00
Ryan Fleury 2bf8179fee eliminate old registers/locals view states 2024-01-31 10:49:47 -08:00
Ryan Fleury 4e9cf2ef89 eliminate old locals view path; dont constantly mutate root expressions, simply query locals & build blocks 2024-01-31 10:48:49 -08:00
Ryan Fleury 14db7dbab4 stub out globals, thread-locals, types views; eliminate unnecssary uniquifier u64 in expand tree hash keys - simplify eval watch views to using a single eval view for the entire view, rather than allocating one per root expression. expand keys are now simply comprised of parent hash * child num 2024-01-31 10:39:18 -08:00
Ryan Fleury 8aac3f7bda escape textual string data before visualizing it in single-line eval visualization 2024-01-31 09:22:47 -08:00
Ryan Fleury 385014adcb raddbg nil tables, autofill empty tables with 1-sized nils; use element-from-idx wrapper to bounds-check and nilify all out-of-bounds raddbg table accesses 2024-01-31 08:43:33 -08:00
Ryan Fleury a6f42502ec symbol lister -> show procedure # in debug info, source location, name in tooltip; busyloop to wait to commit new fuzzy search results if scope touches active; sort fuzzy match results 2024-01-31 07:22:07 -08:00
Ryan Fleury 94d2be1683 some hover eval adjustments 2024-01-31 06:29:25 -08:00
Ryan Fleury 09f2b83603 fix function name breakpoint serialization 2024-01-31 06:20:49 -08:00
Ryan Fleury 00594a841a notes 2024-01-30 14:44:11 -08:00
Ryan Fleury 2731bdac59 extend fuzzy search cache nodes to having 3 buckets - 3rd bucket can be used to abort working copy, and speed an updated query along 2024-01-30 14:19:11 -08:00
Ryan Fleury 6e456424b0 handle thread name events correllated with only TID, without corresponding thread entity - correllate upon thread creation as-needed 2024-01-30 13:50:23 -08:00
Ryan Fleury c700264445 use explicit thread name exception thread ID parameter, when not implicit 2024-01-30 13:11:37 -08:00
Ryan Fleury d9f69cdf14 complete first pass of fuzzy matching symbol lister for go-to-name, and setting function breakpoints 2024-01-30 12:58:24 -08:00
Ryan Fleury 4ef814acb5 fix more tab bar stuff; further sketchout of asynchronous dbgi layer fuzzy searching 2024-01-30 09:57:15 -08:00
Ryan Fleury d139c2874c add optional command spec restriction to cmd param slot -> view spec table; eliminate mouse testing when windows are not focused 2024-01-30 09:14:59 -08:00
Ryan Fleury c61ff1910c split ui view clamp rule into separate x/y flags 2024-01-30 08:02:25 -08:00
Ryan Fleury c9b22acd5a sketch out symbol lister view; float fuzzy matching code into base string layer; bugfix unnecessary ui layer view clamping 2024-01-30 07:59:24 -08:00
Ryan Fleury 38af1a5cab fix bottom tab clipping 2024-01-30 06:52:03 -08:00
Ryan Fleury fe5f38c306 only retry findthread given missing debug info or RIP if ctrl thread is stopped 2024-01-30 06:33:16 -08:00
Ryan Fleury f130f23b3f include jmc line number hacks in line step-over and step-into trap-net 2024-01-30 06:18:02 -08:00
Ryan Fleury aa31afcd24 bump patch version, mule_main -> common link flags 2024-01-29 17:39:20 -08:00
Ryan Fleury 49f7fa9fa3 notes; load user/profile -> open user/profile 2024-01-29 17:31:47 -08:00
Ryan Fleury 9b8c0e32b5 hover eval change visualization 2024-01-29 17:21:25 -08:00
Ryan Fleury 2518eaf57c pass over line info colors, enable source-hover-line-info-viz, a few other visual improvements/tweaks 2024-01-29 16:54:31 -08:00
Ryan Fleury d2bdf512cf in the case of unspecified colors in cfg, default fill them from the preset theme with the most similar background; this will mean that even with totally custom themes, as new color codes are added to the frontend, people will get sensible defaults. if they are just using a preset, then they will get the default new values by default 2024-01-29 16:24:41 -08:00
Ryan Fleury 0ce5239404 prefer serializing theme presets, if applicable 2024-01-29 16:13:08 -08:00
Ryan Fleury 83e8bb8ddd actually still need corner sdf sample with sufficient softness as well 2024-01-29 15:58:15 -08:00
Ryan Fleury afe105da31 eliminate further useless sdf sampling in shaders; eliminate useless borders in ui, eliminating more overdraw; eliminate tab bar clipping issue 2024-01-29 15:52:08 -08:00
Ryan Fleury f6e7db7c3a clean up ui box hierarchy rendering path, to eliminate duplicate node visits, causing a lot of extra dumb overdraw etc. 2024-01-29 15:30:59 -08:00
Ryan Fleury d1fde3c908 fix busted synchronization in non-file-backed txti buffer edits; fix some snapping issues in Output view 2024-01-29 13:57:24 -08:00
Ryan Fleury baca24c037 fix leftover event consumption tautological rule; fix a few small visual issues 2024-01-29 12:53:09 -08:00
Ryan Fleury 57fb21adf7 always allocate byte dirty/unreadable flags in ctrl process memory cache lookup, rather than trusting caller to check 2024-01-29 11:56:34 -08:00
Ryan Fleury 3fd9014c20 feed user-specified strings in cfg serialization/deserialization through escaping/unescaping path -- escape all double-quotes before serialization, de-escape when deserializing 2024-01-29 11:51:12 -08:00
Ryan Fleury 1ade5e44fa do not strip quotations from command line arguments when launching debuggee processes, as otherwise quoted arguments with spaces will be broken apart in inconsistent & unintended ways; fix utf16 decoding with certain ranges of codepoints 2024-01-29 11:28:58 -08:00
Ryan Fleury 28e258b5dc dont assume valid slice from process memory cache grab 2024-01-27 10:46:41 -08:00
Ryan Fleury 967936cef6 pass over rules in picking step-into entry point. right now we don't exactly have a trivial way of checking if an entry point truly was defined by a user. but if line info exists, and the file seems local, and there is a procedure name for an EXE's built-in entry point address, then we can at least guarantee that there is source for the entry point, and thus can serve as an acceptable entry point. this currently does not take into account cases where the OBJ path is not local, but the user overrides the file paths to have source. if the entry point is determined to be non-user-defined, then everything falls back to the usual paths - try WinMain, WinMainCRTStartup, etc., and then override with explicit custom entry points if needed. not great, currently, w.r.t. detecting if the entry point is in user code. maybe can check more info in the unit later... 2024-01-26 20:37:36 -08:00
Ryan Fleury 04b5b362bc fix deadlock in launch_and_init - don't hold dbgi scopes open too aggressively, as we may need to eliminate dbgi which they refer to. 2024-01-26 19:04:30 -08:00
Ryan Fleury f047a0beac slight logo tweaks 2024-01-26 17:37:15 -08:00
Ryan Fleury 7355389e19 ohhhh my godd pt 2 2024-01-26 14:25:46 -08:00
Ryan Fleury 5f8ec62b4c ohhhh myyy gooood 2024-01-26 14:23:54 -08:00
Ryan Fleury 207e46c8e8 prefer exe header's default entry point if it doesn't match expected defaults 2024-01-26 13:59:17 -08:00
Ryan Fleury b76a8b9854 oops - do not ring_write in reader path... also fix silly shader thing 2024-01-26 13:51:57 -08:00
Ryan Fleury 6b7588b4b3 oops;git status 2024-01-26 13:51:33 -08:00
Ryan Fleury 455dac958c first pass at asynchronous file streaming -> hash store layer; fix non-windowed memory access in watch window when doing change visualization, causing major performance regression with large arrays; fix some extra jank with truncated-string-hover & help labels 2024-01-26 11:47:25 -08:00
Ryan Fleury 0974337450 oops, fix function pointer display 2024-01-26 09:50:03 -08:00
Ryan Fleury fea74aedd8 visualize global variable symbol pointers after addresses only on void*s (keep function symbol visualization for function pointer types); otherwise there is real content to visualize 2024-01-26 09:24:35 -08:00
Ryan Fleury 89af8124c7 ui truncated string hovering -> display full string as a tooltip 2024-01-26 09:04:29 -08:00
Ryan Fleury 33f5d4f5b1 default animation rate tweaks 2024-01-26 07:59:04 -08:00
Ryan Fleury 88a218e36e visual jank-fix/polish pass 2024-01-26 07:43:40 -08:00
Ryan Fleury f69176ee4e dbgi layer: treat <header-sized raddbg files as out-of-date 2024-01-26 06:14:02 -08:00
Ryan Fleury 8c0708d2ab remove unnecessary idx run iterator assertion in converter; 'twas asserting that no nodes remained in the bake phase when reaching the end of the idx run section, but this does not hold in all cases (e.g. in the case where there is an empty idx run added last) 2024-01-26 06:08:12 -08:00
Ryan Fleury 21deaace66 fix focus visualization seam given new shaders 2024-01-25 14:20:11 -08:00
Ryan Fleury 3aa602eca7 fix satval picker rendering, with new shader performance improvements 2024-01-25 14:15:24 -08:00
Ryan Fleury 1319a23f98 raddbg_from_pdb: cv struct2/class2 paths 2024-01-25 13:23:50 -08:00
Ryan Fleury c8c5da4f4a improve flow around multi-target debugging: prefer one-target-only in default path; only enable command line specified target if present; explicit commands for enabling/disabling targets, as well as mutually-exclusive selection of targets; make default clicking path in UI go through mutually exclusive selection, whereas ctrl+clicks will do multi-target selection 2024-01-25 11:49:05 -08:00
Ryan Fleury dd38822a4c Merge branch 'dev' 2024-01-25 11:22:06 -08:00
Martins Mozeiko 644a94d5ef fixing clang build 2024-01-25 11:19:30 -08:00
Martins Mozeiko fc9449a2d5 make sure github action fails on error 2024-01-25 11:19:30 -08:00
Ryan Fleury 168f66cc99 further progress on new process memory cache; first pass at visualizing changed watch window rows, based on ctrl process memory cache history 2024-01-25 11:17:16 -08:00
Ryan Fleury 38b113f1d0 simplify & consolidate ctrl layer process memory caching mechanisms - move all non-necessarily-synchronous caching to background memory streaming thread cache 2024-01-25 10:04:03 -08:00
Ryan Fleury b14b9f0344 strip out ctrl process memory cache fresh flags & hash history, since both will be replaced by hash store layer's capabilities 2024-01-25 09:09:36 -08:00
Ryan Fleury d0c3d9dc21 extend ctrl process memory cache reads with freshness info - it is a bit too coarse grained at page granularity, that should've been easy to predict... in any case, to start addressing that, start keeping >1 hash key hash history in hash store layer, such that history may be preserved for a bit longer & diff'd with new key hashes 2024-01-25 09:06:03 -08:00
Ryan Fleury 76b2facbf4 restrict menu bar keyboard shortcuts to being modifierless 2024-01-25 07:47:11 -08:00
Ryan Fleury 813554fa62 detect alt-held character inputs; short-circuit menu bar shenanigans on chars-with-alt 2024-01-25 07:29:55 -08:00
Ryan Fleury 7cf0854178 reimplement run-to-line and run-to-address with temporary user breakpoints which die-on-stop, which provides the desired flow for e.g. run-to-line while nothing runs 2024-01-25 07:07:22 -08:00
Ryan Fleury ed7d31d7ea support C++ style scope resolution in txti buffer * point -> expression range path 2024-01-25 06:18:47 -08:00
Ryan Fleury 66b56789c6 eval: support for multiple namespacified fallback token lookups, to account for the several possibilities of namespaces & nested namespaces & static class members nested inside of namespaces & namespaces within namespaces within classes within namespaces & wow C++ is very bad; also ui: temporarily disable space-to-click, as it conflicts with typing and this case is not yet well supported 2024-01-25 06:15:28 -08:00
Ryan Fleury 96b0dd0783 note on bilinear sampling requirement (e.g. not interpolating per-vertex coordinates) for specific UI 2024-01-24 16:10:11 -08:00
Ryan Fleury 2dbcc26cdb switch local dev debugger to using local user/profile files, to explicitly separate from stable build 2024-01-24 15:26:12 -08:00
Ryan Fleury 56332b729f dont feed forward scroll events either 2024-01-24 14:07:25 -08:00
Ryan Fleury 55e06d0652 eliminate unnecessary waits in empty disassembly view 2024-01-24 14:03:37 -08:00
Ryan Fleury 0d1ccd7264 switch to partner file command - quick way to switch from .h to .c, or similar 2024-01-24 13:59:31 -08:00
Ryan Fleury 4ddb4d0fed consume menu bar events properly 2024-01-24 13:38:37 -08:00
Ryan Fleury 26b8603a59 when building locals map given a raddbg*voff, capture locals from previously-exited scopes 2024-01-24 13:00:17 -08:00
Ryan Fleury 8789e763fd equip os events with timestamp; re-enable leftover event feed-forward but add timeout 2024-01-24 12:38:19 -08:00
Ryan Fleury f30d9ceaa9 name match against later-added global variable symbols, since apparently PDBs can be produced to keep stale global symbols around to 2024-01-24 12:25:53 -08:00
Ryan Fleury f3ca6ff9b3 temporarily disable leftover event piping... 2024-01-24 12:14:33 -08:00
Ryan Fleury d98a04ad22 correct animation response to new events 2024-01-24 12:02:36 -08:00
Ryan Fleury 69f77456b8 dbgi: fix incorrect grab of raddbg header; raddbg_from_pdb: fix unsigned interpretation of offsets in defrange symbols; fix incorrect byte position/size encoding ordering in some location info cases 2024-01-24 11:57:17 -08:00
Ryan Fleury 3edc67e19e only equip views with entities if their spec dictates that they're parameterized by entities 2024-01-24 11:19:18 -08:00
Ryan Fleury d07ae91cb4 add version encoding difference detection in dbgi layer when deciding whether or not to re-convert; this will allow using the raddbg encoding version as a 'generation number', as the encoding changes, to prevent cases where the debugger loads old versions & treats them as new unknowingly 2024-01-24 10:41:55 -08:00
Ryan Fleury 77190c4aa0 improve rules for choosing file alternatives -> try to seek upward src/dst paths, and map only at the first non-matching node; this should map matching directories etc. 2024-01-24 09:29:02 -08:00
Ryan Fleury 959550151a preserve per-event mouse coordinates; prefer in ui signal producing codepath 2024-01-23 20:17:50 -08:00
Ryan Fleury be252406bd if both snap-destination src & disasm for a find-code-location both occupy the same panel, prefer src if src was selected, but prefer disasm if disasm was selected 2024-01-23 19:57:39 -08:00
Ryan Fleury 2b265e7ced also consume window close events 2024-01-23 18:59:27 -08:00
Ryan Fleury 00ee0e58db oops! consume text input events... 2024-01-23 18:56:55 -08:00
Ryan Fleury fd0feefcf2 pipe through left-over OS events to subsequent frames; do not drop them 2024-01-23 16:44:57 -08:00
Ryan Fleury 04def874eb also don't assume we even have the PE exception data directory 2024-01-23 15:49:56 -08:00
Ryan Fleury 94b1888073 dont assume in-bounds intel pdata ranges 2024-01-23 15:45:21 -08:00
Ryan Fleury 140c8a3fee Merge branch 'master' into dev 2024-01-23 15:34:27 -08:00
Ryan Fleury e3651c1ef4 communicate ctrl -> df start/stop events on launch (as well as normal runs) - prohibit demoting high-level step operations into launches if targets are running, but no process creation events have been identified yet 2024-01-23 15:31:40 -08:00
Martins Mozeiko 1da1239c7c doing blur shader without alpha blending 2024-01-23 15:31:40 -08:00
Martins Mozeiko 44fa806334 bugfix when calculating kernel weights for smaller than 1px blur size 2024-01-23 15:31:40 -08:00
Ryan Fleury d4474b5a31 introduce extra query selection state, to allow mouse-driven controls for deselecting a window's query ui, then reselecting it (e.g. to copy things from source view) 2024-01-23 15:31:40 -08:00
Ryan Fleury 74fa729a58 do not assume the presence of a module when forming an eval parse ctx; it must be based on process*vaddr, not module*voff, because you might be evaluating from code without a module 2024-01-23 15:31:40 -08:00
Ryan Fleury 02aa04f242 also allow space for keyboard clicks 2024-01-23 15:31:40 -08:00
Ryan Fleury 0e1869e6c9 eliminate assumptions of module presence in unwinding codepaths, & callstack UI; fixes callstacks for JIT'd code 2024-01-23 15:31:40 -08:00
Ryan Fleury ca9d9791d3 fix output view keyboard navigation/focus 2024-01-23 15:31:40 -08:00
Ryan Fleury 56df75cc20 separation of file-only, folder-only and file-or-folder selection paths, slight tweaks to filesystem lister behavior for each; other small visual tweaks/fixes 2024-01-23 15:31:40 -08:00
Ryan Fleury fa981597ea add support in ui layer for re-rooting keyboard focus stack, which short-circuits the focus-off search through the focus stack 2024-01-23 15:31:40 -08:00
Ryan Fleury 87cd790f70 dedicated command for picking folders & improved flow when doing directory-only selection 2024-01-23 15:31:40 -08:00
Ryan Fleury 4e561b1b38 fix flipped y transform application in upgraded shader 2024-01-23 15:31:40 -08:00
Ryan Fleury 37a0d9e148 allow (u)char eval commits in integer committing path 2024-01-23 15:31:40 -08:00
Ryan Fleury bac2e99f12 invalidate memory view local cache via memgen idx, not run idx, to invalidate on all memory changes 2024-01-23 15:31:40 -08:00
Martins Mozeiko d5e0054a13 blut shader improvements, use bilinear sampling for 2x fewer samples 2024-01-23 15:31:40 -08:00
Martins Mozeiko 3b86b6f7a0 rect shader improvements, moved calculations from pixel to vertex shader 2024-01-23 15:31:40 -08:00
Ryan Fleury a514ec1ac7 dont submit draws for any empty glyphs 2024-01-23 15:31:40 -08:00
Ryan Fleury 68eacca361 dont render entire atlas region for font run pieces; render more minimal rasterization size 2024-01-23 15:31:40 -08:00
Ryan Fleury bb97c185bd correctly adjust version-remapped binding strings 2024-01-23 15:31:40 -08:00
Mohit Sethi 40fc63ca06 Disable fail-fast strategy and add .md files to be ignored for triggering workflow. 2024-01-23 15:31:13 -08:00
Ryan Fleury 2c8e17be3b communicate ctrl -> df start/stop events on launch (as well as normal runs) - prohibit demoting high-level step operations into launches if targets are running, but no process creation events have been identified yet 2024-01-23 15:23:51 -08:00
Martins Mozeiko bae91cd40c doing blur shader without alpha blending 2024-01-23 15:05:33 -08:00
Martins Mozeiko 82f86d654f bugfix when calculating kernel weights for smaller than 1px blur size 2024-01-23 15:05:33 -08:00
Ryan Fleury e56eb077d0 introduce extra query selection state, to allow mouse-driven controls for deselecting a window's query ui, then reselecting it (e.g. to copy things from source view) 2024-01-23 15:00:42 -08:00
Ryan Fleury abb2dd713e do not assume the presence of a module when forming an eval parse ctx; it must be based on process*vaddr, not module*voff, because you might be evaluating from code without a module 2024-01-23 14:44:39 -08:00
Ryan Fleury f50ffd17aa also allow space for keyboard clicks 2024-01-23 14:31:44 -08:00
Ryan Fleury 804a8406b9 eliminate assumptions of module presence in unwinding codepaths, & callstack UI; fixes callstacks for JIT'd code 2024-01-23 14:26:43 -08:00
Ryan Fleury 8bf8112edd fix output view keyboard navigation/focus 2024-01-23 13:52:09 -08:00
Ryan Fleury 0c674066e0 separation of file-only, folder-only and file-or-folder selection paths, slight tweaks to filesystem lister behavior for each; other small visual tweaks/fixes 2024-01-23 13:47:14 -08:00
Ryan Fleury 7c3de4fe5b add support in ui layer for re-rooting keyboard focus stack, which short-circuits the focus-off search through the focus stack 2024-01-23 13:08:00 -08:00
Ryan Fleury a975bf5412 dedicated command for picking folders & improved flow when doing directory-only selection 2024-01-23 13:03:21 -08:00
Mohit Sethi 1d225703ca Disable fail-fast strategy and add .md files to be ignored for triggering workflow. 2024-01-23 12:54:24 -08:00
Ryan Fleury 6e5f518cf3 fix flipped y transform application in upgraded shader 2024-01-23 12:50:26 -08:00
Ryan Fleury 6a91505317 allow (u)char eval commits in integer committing path 2024-01-23 11:16:44 -08:00
Ryan Fleury e222996b19 invalidate memory view local cache via memgen idx, not run idx, to invalidate on all memory changes 2024-01-23 11:13:00 -08:00
Martins Mozeiko 1705fdd421 blut shader improvements, use bilinear sampling for 2x fewer samples 2024-01-23 08:38:53 -08:00
Martins Mozeiko a77d457f51 rect shader improvements, moved calculations from pixel to vertex shader 2024-01-23 08:38:53 -08:00
Ryan Fleury 9a2ae21b89 dont submit draws for any empty glyphs 2024-01-22 15:18:42 -08:00
Ryan Fleury 834f4f7d20 dont render entire atlas region for font run pieces; render more minimal rasterization size 2024-01-22 15:07:20 -08:00
Ryan Fleury 90e1443627 correctly adjust version-remapped binding strings 2024-01-22 13:53:02 -08:00
Ryan Fleury ebac4ce636 Merge branch 'master' into dev 2024-01-21 22:42:23 -08:00
Ryan Fleury e92119ebf3 properly handle keep-old-input & select-old-input command query behaviors 2024-01-21 22:39:32 -08:00
Ryan Fleury aade379dce properly handle keep-old-input & select-old-input command query behaviors 2024-01-21 22:39:11 -08:00
Ryan Fleury bc16710904 raddbg icon building/embedding/loading 2024-01-21 22:22:08 -08:00
Ryan Fleury 27deda390f raddbg icon building/embedding/loading 2024-01-21 22:21:41 -08:00
Jeff Roberts (Bellevue) 89c5d22f7f Error on missing app, and 32-bit apps 2024-01-21 21:08:14 -08:00
Ryan Fleury 7e5a80c560 Update builds.yml 2024-01-21 21:08:14 -08:00
Ryan Fleury 4870d066b2 exit paths for build.bat 2024-01-21 21:08:13 -08:00
Ryan Fleury f4ec1e2d77 i am once again asking my GitHub actions script to call vcvarsall.bat correctly 2024-01-21 21:08:13 -08:00
Ryan Fleury e354dc3fc7 attempt to fix vcvarsall.bat paths in github actions workflow 2024-01-21 21:08:13 -08:00
Ryan Fleury a9e17c42d7 initial pass over builds.yml for auto-running build permutations 2024-01-21 21:08:13 -08:00
Ryan Fleury c018ffa317 major simplification pass over command query system; eliminate per-window query views, just collapse down to a single query view stack per-window (way simpler and honestly just what everyone does anyways); simplify/dejankify ui focus system 2024-01-21 21:07:45 -08:00
Ryan Fleury 9c6e20b391 notes for next ui pass 2024-01-21 21:07:45 -08:00
Ryan Fleury 3e413e1a2e dont omit txti edits from failed-load buffers; this prohibits the case of debugger-constructed buffers, like the output log 2024-01-21 21:07:45 -08:00
Ryan Fleury 6488a13a2e move most eval paths onto unwrapped-direct path, when needing to rely on the actual shape of the type info & when modifiers are irrelevant 2024-01-21 21:07:45 -08:00
Ryan Fleury cc5ebcc756 enable type evaluation in eval system & watch views 2024-01-21 21:07:45 -08:00
Ryan Fleury 6979d03f09 eval compiler: read through type modifiers in member access path 2024-01-21 21:07:45 -08:00
Ryan Fleury d079c679f8 always clamp cursor in memory view 2024-01-21 21:07:45 -08:00
Ryan Fleury b16453d7b0 feed lref/rrefs into the same member access path as pointers 2024-01-21 21:07:44 -08:00
Ryan Fleury a94e1b1928 major simplification pass over command query system; eliminate per-window query views, just collapse down to a single query view stack per-window (way simpler and honestly just what everyone does anyways); simplify/dejankify ui focus system 2024-01-21 21:07:04 -08:00
Ryan Fleury 58a0084024 notes for next ui pass 2024-01-21 21:07:04 -08:00
Jeff Roberts (Bellevue) c02e033499 Error on missing app, and 32-bit apps 2024-01-21 08:16:46 -08:00
Ryan Fleury fb7db06671 dont omit txti edits from failed-load buffers; this prohibits the case of debugger-constructed buffers, like the output log 2024-01-21 08:08:24 -08:00
Ryan Fleury dc108d72c1 Update builds.yml 2024-01-20 12:06:21 -08:00
Ryan Fleury b283225d03 exit paths for build.bat 2024-01-20 12:04:41 -08:00
Ryan Fleury 014074e3ce i am once again asking my GitHub actions script to call vcvarsall.bat correctly 2024-01-20 11:59:46 -08:00
Ryan Fleury 2a27b5af51 move most eval paths onto unwrapped-direct path, when needing to rely on the actual shape of the type info & when modifiers are irrelevant 2024-01-20 10:57:59 -08:00
Ryan Fleury 921b555346 enable type evaluation in eval system & watch views 2024-01-20 10:49:23 -08:00
Ryan Fleury f75ee24a2b eval compiler: read through type modifiers in member access path 2024-01-20 10:14:48 -08:00
Ryan Fleury 862ae81b0e always clamp cursor in memory view 2024-01-20 10:06:52 -08:00
Ryan Fleury f11b128a07 feed lref/rrefs into the same member access path as pointers 2024-01-20 09:40:43 -08:00
Ryan Fleury d172b3a059 attempt to fix vcvarsall.bat paths in github actions workflow 2024-01-20 09:10:11 -08:00
Ryan Fleury c9944d23cc initial pass over builds.yml for auto-running build permutations 2024-01-20 09:06:21 -08:00
Ryan Fleury f3db75a05b fix decimal enum value display 2024-01-19 22:13:04 -08:00
Ryan Fleury 0bc96a086a bugfix member cache invalidation tautology; group eval string2num strings onto arena along with table & nodes 2024-01-19 20:36:04 -08:00
Ryan Fleury e7046cb9d7 build fix for msvc 2017 2024-01-19 19:14:55 -08:00
Ryan Fleury 616897c8d6 version tick 2024-01-19 18:46:58 -08:00
Ryan Fleury 6a7dd334ff d3d11 debug layer exceptions; decimal enum displays; local time display in filesystem lister 2024-01-19 18:42:05 -08:00
Ryan Fleury f48d8431c0 allow implicit namespacification of identifier mapping path in eval parser, based on namespace of the procedure (if any) that the instruction pointer is currently within 2024-01-19 18:29:11 -08:00
Ryan Fleury d88000ddeb if exe-embedded pdb path doesn't work, fall back on attempting to treat that same path as relative to the executable 2024-01-19 18:14:39 -08:00
Ryan Fleury 42993b3fb0 silently filter access violations in asan's shadow address space 2024-01-19 17:47:56 -08:00
Ryan Fleury 123c3104a5 tweak build script to allow clang builds of mule_main; fix clang build 2024-01-19 13:02:33 -08:00
Ryan Fleury f15bc3de73 fix accidentally mistaking missing files for not missing, given new implementation of os_properties_from_file_path 2024-01-19 12:39:18 -08:00
Ryan Fleury c2d315d896 register value committing; eliminate manual 'invalidation' controls for frontend caches, rely on memgen/reggen/run idxs from ctrl thread, which can be incremented solely at the ctrl thread's discretion 2024-01-19 12:17:42 -08:00
Ryan Fleury 25ef507201 eliminate some old win32 timer code; use LLD in clang builds; eliminate unnecessary Clang architecture flags; eliminate /MP from builds, since mostly unnecessary 2024-01-19 10:37:27 -08:00
Martins Mozeiko f7897aecea fix build warnings for clang 2024-01-19 10:27:33 -08:00
Martins Mozeiko b1e2ca0ff8 show dialog with call stack in crash handler 2024-01-19 10:27:33 -08:00
Ryan Fleury c4242cf162 non-helper os_properties_from_file_path - can use accelerated path here which just looks at path for properties, rather than having to open a handle; also tweak txti layer to gracefully fail if a write happened between its load of file data 2024-01-19 10:00:53 -08:00
Ryan Fleury b5e604e6c8 source view bottom bar -> warn if file timestamp is newer than currently-used debug info 2024-01-18 16:53:30 -08:00
Ryan Fleury 23572ca63f notes 2024-01-18 12:11:01 -08:00
Ryan Fleury cb4cc5a4f7 differentiate between commands whose fastpaths select entire initial input vs. ones who don't; use it in case of text searching 2024-01-18 11:05:24 -08:00
Ryan Fleury 279daaa84a when beginning a query with old input, select entire query string, to easily replace it if needed 2024-01-18 11:01:47 -08:00
Ryan Fleury ac521a8f60 do not use graphical error reporting in auto-launched conversion instances of the debugger; will fix repeated debug info conversion fatal error exception message boxes 2024-01-18 10:36:15 -08:00
Ryan Fleury 3567e6c53d txti layer -> open files in write-shared mode, to prevent locking file from e.g. an editor which is writing; also only enable change detection when ui is actively updating 2024-01-18 10:04:00 -08:00
Ryan Fleury d2d72bd7ab ctrl: eliminate possibility of threads getting stuck at spoof address at the event-pump layer - if we report other events first, the step is already cancelled anyways 2024-01-17 20:58:55 -08:00
Ryan Fleury 268ca9ab53 trap net building & stepping algorithm overview 2024-01-17 19:52:36 -08:00
Ryan Fleury dea5e88906 also look for wmainCRTStartup 2024-01-17 17:07:16 -08:00
Ryan Fleury 25c31b0d77 look for mainCRTStartup as one additional possibility of a default entry point 2024-01-17 17:01:25 -08:00
Ryan Fleury ea2066063a do the same for omit/only 2024-01-17 16:34:02 -08:00
Ryan Fleury bdecb6d522 disable hook-based list view rule, since it is currently unimplemented and visualization engine hooks need to mature before it is formally implemented in them 2024-01-17 16:31:26 -08:00
Tony L 739d0977b6 Disable hover if view is scrolling
Also set the first frame index to current index so that the hover popup
doesn't instantly appear once the scroll has ended.
2024-01-17 14:49:29 -08:00
Ryan Fleury 717572c202 non-virtual-inheritance case in mule_main 2024-01-17 13:56:54 -08:00
Ryan Fleury d3931fd3e2 base class -> derived class autocast in eval system; completion of first pass 2024-01-17 13:28:03 -08:00
Ryan Fleury a0a6fc0988 raddbg_from_pdb -> dont skip all members of struct simply because we currently do nothing with vfunctab 2024-01-17 10:36:23 -08:00
Ryan Fleury 7d8f0d478e checkpoint #2 of same... 2024-01-17 09:16:33 -08:00
Ryan Fleury d849b83acb checkpoint in implementing dynamic type resolution in the eval system, for taking a base-class-ptr & by-default patching in the appropriate debug-info-determined derived type 2024-01-16 17:33:17 -08:00
Ryan Fleury adbe42c907 add non-pure dynamic inheritance case 2024-01-16 17:12:51 -08:00
Martins Mozeiko 99b2d9d6d0 minor d3d11 code improvements
1) automatically tries WARP driver if HW creation fails
2) HRESULT checks for swap chain creation or Present call (can fail if GPU driver crashes)
3) checks HRESULT of D3DCompile functions instead of using shader pointer as error condition
4) releases shader blob memory when not needed anymore
2024-01-16 17:09:07 -08:00
Ryan Fleury 5c179adb68 extend binary * voff -> symbol name lookup to include global variable vmap if scope vmap turns up short; extend address visualization rules to more ambitiously visualize what is being pointed at 2024-01-16 15:29:50 -08:00
Ryan Fleury de6c94ce8f set up nil udt in raddbg conversion - used for empty udt info for e.g. pure virtual structs 2024-01-16 15:05:06 -08:00
Ryan Fleury 743984c318 eliminate stray zero byte in output logs 2024-01-16 14:48:29 -08:00
Ryan Fleury a026ae41f1 import example of user-defined type node which does NOT have a udt entry - this is the cause of the virtual interface display bugs 2024-01-16 14:13:34 -08:00
Ryan Fleury 114dd96e50 data member offset sorting -> take into account base offset, when doing inheritance graph search; visualize inheritance chain for inherited members; use contextual base color in code labels, do not assume default code color implicitly 2024-01-16 14:01:37 -08:00
Ryan Fleury e2e1382508 use same type key -> members path in eval compiler as in eval visualization paths 2024-01-16 12:03:24 -08:00
Ryan Fleury 1c40afc067 import notes from email bugs; add non-virtual-but-still-multiple-inheritance example to mule_main; slightly increase loudness of exception/trap-caused stop ctrl events 2024-01-16 11:59:44 -08:00
Ryan Fleury 79677875c4 fix 64-bit address/value visualization in memory view bottom bar 2024-01-16 11:21:19 -08:00
Ryan Fleury c2e90225b9 type graph data member gathering -> follow single-inheritance base class members + sort members by offset 2024-01-16 11:12:08 -08:00
Ryan Fleury 057a6f3e8e eliminate duplicate binary dbgi parsing requests 2024-01-15 21:33:59 -08:00
Ryan Fleury a9ec1a05b1 notes 2024-01-15 20:30:11 -08:00
Ryan Fleury 2454d426ed eliminate dbgi layer evictor thread - exe and debug info eviction needs to be synchronous with control thread, to allow for HMH-style hotloading. this change moves all dbgi layer binary releasing to the caller thread of the refcount -> 0 dbgi_binary_close. 2024-01-15 20:13:49 -08:00
Ryan Fleury cf58137b0f todo notes 2024-01-15 15:38:12 -08:00
Ryan Fleury c40d0b3acc hot reloading mule 2024-01-15 13:04:25 -08:00
Ryan Fleury dd433c89ff fix ordering of local itypes within itype blocks in type name map; latter added itypes need to come *first* 2024-01-15 08:21:50 -08:00
Ryan Fleury d2ec1d6a3a interpret & visualize __fastfail events correctly 2024-01-14 21:36:39 -08:00
Ryan Fleury f736533933 further mule_main coverage 2024-01-14 20:28:15 -08:00
Ryan Fleury 8d82accc26 complete application of hash adjustment table in pdb -> raddbg converter 2024-01-14 18:12:45 -08:00
Ryan Fleury f61688fff5 checkpoint in implementing pdb hash adjustment table parsing & application 2024-01-14 17:20:35 -08:00
Ryan Fleury c88f715ac2 fix horizontal scroll in text containers causing repeated hidden animation 2024-01-14 14:53:45 -08:00
Ryan Fleury cac911fbf5 add info on converter to readme roadmap section 2024-01-14 11:34:18 -08:00
Ryan Fleury 1261aa55b0 include project short-to-medium-term roadmap in readme 2024-01-14 11:28:15 -08:00
Ryan Fleury 5fe3f56d33 line step into -> if call redirects to a function dispatch unconditional jump table, move stopper trap in trap net to unconditional jump destination, and skip the jump table entirely 2024-01-14 07:02:30 -08:00
Ryan Fleury 0c497abba6 only supply config defaults when doing user config application 2024-01-14 06:42:49 -08:00
Ryan Fleury 625e197bc1 eval parser -> prefer later type name matches to earlier 2024-01-13 21:14:58 -08:00
Ryan Fleury d40c9edb90 type graph -> fix edge case of last-incrementally-changed type's members being considered out-of-bounds of member info 2024-01-13 21:13:29 -08:00
Ryan Fleury a6a6eed091 accept enter for confirm acceptance 2024-01-13 20:06:19 -08:00
Ryan Fleury 032df717d8 if loading completely black theme from config, reset to default theme, for cases of busted config files 2024-01-13 17:21:38 -08:00
Ryan Fleury bcdc2f3026 more mule_module coverage; bugfix edge-case memory view range calculation causing flipped min/max 2024-01-13 16:37:34 -08:00
Jack Punter 3917218a4e Fix horizontal chunk movement
The current horizontal chunk motion (ctrl + left/right arrow by default) does not work like most other editors, subverting the users expectation. The behaviour of most editors from my experience is as follows:
1. Skip any leading whitespace in the motion
2. If the next char is:
    - Alphanumeric or `_`, move up until the next symbol that isn't one of those
    - not one of the above move either up until: the next whitespace character or the same rules as above if an alphanumeric or `_` is encountered before whitespace.

e.g. Assume the current cursor position and string `... |mystruct.member ...`
The current code will move to the end of the whole struct accessor: `... mystruct.member| ...`
Most other editors would move to the end of the struct name: `... mystruct|.member ...`
In this case the current behaviour may not seem _that_ agregious, but in other cases its much more annoying
especially if you're looking to copy into a watch window or something as in this case:
`|ui_nav_scanned_column_from_column(String8 string, ...)`
the cursor will move to: `ui_nav_scanned_column_from_column(String8| string, ...)`
which is almost certainly not what the user wanted.

This behaviour means that if you want to copy a symbol, you can consistantly achieve this by chunk moving to one end, pressing shift, then chunk moving to the other end without ever getting extra symbols/whitespace. This is currently not possible with existing chunk motions.
2024-01-13 15:33:07 -08:00
Ryan Fleury c0322437d6 arresting confirmation ui - use in exit-while-debugging 2024-01-13 14:48:02 -08:00
Ryan Fleury 096d85168a display d3d11 device creation error code if fail 2024-01-13 11:10:37 -08:00
Ryan Fleury 735f817b0b more texture format coverage in renderer/view-rules 2024-01-13 10:21:50 -08:00
Ryan Fleury e30c6553a4 Merge branch 'dev' of https://github.com/EpicGames/raddebugger into dev 2024-01-13 08:31:08 -08:00
Ryan Fleury f9ab53c0c4 further clangification - ignore unknown warning disabling, to keep build script reasonable for older versions of clang 2024-01-13 08:24:49 -08:00
Ryan Fleury d382053500 prevent bubble-up panel deletion case from assuming non-nil grandparent; also prevent from trampling over focus fallback path 2024-01-13 07:13:42 -08:00
Ryan Fleury b932e6236a os gfx stub backend 2024-01-12 20:30:38 -08:00
Ryan Fleury b9a7b64280 stub render backend for tests; hoist out raddbg code/entry points from build target file, to be called into by sanity tests 2024-01-12 20:06:38 -08:00
Ryan Fleury 2078af15f9 mc -> mdesk; I do not know what Monkey C is 2024-01-12 19:22:11 -08:00
Ryan Fleury 5410fac38e oops... fix first-time config initialization disaster! 2024-01-12 15:44:11 -08:00
Ryan Fleury ca8727c4af pipe parsed command line through render layer initialization; add new command line flags for render layer - (a) to disable API calls which require debug SDKs, and (b) to force software warp driver type 2024-01-12 14:42:24 -08:00
Ryan Fleury 6304ad6955 fix mule_main build 2024-01-12 13:56:21 -08:00
Ryan Fleury 1b4c188770 re-clangify build script 2024-01-12 13:52:19 -08:00
Ryan Fleury e40c980d83 re-ensure codebase c compatibility 2024-01-12 13:29:50 -08:00
564 changed files with 324446 additions and 158263 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
*.sh text=auto eol=lf
+32
View File
@@ -0,0 +1,32 @@
name: builds
on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
build-windows-2022:
runs-on: windows-2022
strategy:
fail-fast: false
steps:
- name: checkout
uses: actions/checkout@v2
- name: build (vs 2022)
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
call build raddbg msvc debug || exit /b 1
call build rdi_from_pdb msvc debug || exit /b 1
call build rdi_from_dwarf msvc debug || exit /b 1
call build rdi_dump msvc debug || exit /b 1
call build raddbg clang debug || exit /b 1
call build rdi_from_pdb clang debug || exit /b 1
call build rdi_from_dwarf clang debug || exit /b 1
call build rdi_dump clang debug || exit /b 1
call build radlink msvc debug || exit /b 1
call build radlink clang debug || exit /b 1
+3 -3
View File
@@ -1,3 +1,3 @@
/build/ /build/
/local/ /local/
*~ *~
+19 -19
View File
@@ -1,19 +1,19 @@
Copyright (c) 2024 Epic Games Tools Copyright (c) 2024 Epic Games Tools
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions: so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
+392 -255
View File
@@ -1,255 +1,392 @@
# The RAD Debugger Project # The RAD Debugger Project
The RAD Debugger is a native, user-mode, multi-process, graphical debugger. It _**Note:** This README does not document usage instructions and tips for the
currently only supports local-machine Windows x64 debugging with PDBs, with debugger itself, and is intended as a technical overview of the project. The
plans to expand and port in the future. In the future we'll expand to also debugger's README, which includes usage instructions and tips, can be found
support native Linux debugging and DWARF debug info. packaged along with debugger releases, or within the `build` folder after a
local copy has been built._
The RAD Debugger is currently in *ALPHA*. In order to get the debugger bullet-
proof, it'd greatly help out if you submitted the issues you find here, along The RAD Debugger is a native, user-mode, multi-process, graphical debugger. It
with any information you can gather, like dump files (along with the build you currently only supports local-machine Windows x64 debugging with PDBs, with
used), instructions to reproduce, test executables, and so on. plans to expand and port in the future. In the future we'll expand to also
support native Linux debugging and DWARF debug info.
You can download pre-built binaries for the debugger
[here](https://github.com/EpicGames/raddebugger/releases). The RAD Debugger is currently in *ALPHA*. In order to get the debugger bullet-
proof, it'd greatly help out if you submitted the issues you find here, along
The RAD Debugger project aims to simplify the debugger by simplifying and with any information you can gather, like dump files (along with the build you
unifying the underlying debug info format. In that pursuit we've built used), instructions to reproduce, test executables, and so on.
the RADDBG debug info format, which is what the debugger parses and uses. To
work with existing toolchains, we convert PDB (and eventually PE/ELF files You can download pre-built binaries for the debugger
with embedded DWARF) into the RADDBG format on-demand. This conversion process [here](https://github.com/EpicGamesExt/raddebugger/releases).
is currently an unoptimized reference version. Nevertheless it's still quite
fast for smaller PDB files (in many cases faster than many other programs The RAD Debugger project aims to simplify the debugger by simplifying and
simply deserialize the PDBs). It is much slower for much larger projects at the unifying the underlying debug info format. In that pursuit we've built the RAD
moment, but we expect this will vastly improve overtime. Debug Info (RDI) format, which is what the debugger parses and uses. To work
with existing toolchains, we convert PDB (and eventually PE/ELF files with
The RADDBG format is currently specified in code, in the files within the embedded DWARF) into the RDI format on-demand.
`src/raddbg_format` folder. The other relevant folders for working with the
format are: The RDI format is currently specified in code, in the files within the
`src/lib_rdi_format` folder. The other relevant folders for working with the
- `raddbg_cons`: The RADDBG construction layer, for constructing RADDBG files. format are:
- `raddbg_convert`: Our implementation of PDB-to-RADDBG (and an in-progress
implementation of a DWARF-to-RADDBG) conversion. - `lib_rdi_make`: The "RAD Debug Info Make" library, for making RDI debug info.
- `raddbg_dump`: Code for textually dumping information from RADDBG files. - `rdi_from_pdb`: Our PDB-to-RDI converter. Can be used as a helper codebase
layer, or built as an executable with a command line interface frontend.
## Development Setup Instructions - `rdi_from_dwarf`: Our in-progress DWARF-to-RDI converter.
- `rdi_dump`: Our RDI textual dumping utility.
**Note: Currently, only x64 Windows development is supported.**
## Development Setup Instructions
### 1. Installing the Required Tools (MSVC & Windows SDK)
**Note: Currently, only x64 Windows development is supported.**
In order to work with the codebase, you'll need the [Microsoft C/C++ Build Tools
v15 (2017) or later](https://aka.ms/vs/17/release/vs_BuildTools.exe), for both ### 1. Installing the Required Tools (MSVC & Windows SDK)
the Windows SDK and the MSVC compiler and linker.
In order to work with the codebase, you'll need the [Microsoft C/C++ Build Tools
If the Windows SDK is installed (e.g. via installation of the Microsoft C/C++ v15 (2017) or later](https://aka.ms/vs/17/release/vs_BuildTools.exe), for both
Build Tools), you may also build with [Clang](https://releases.llvm.org/). the Windows SDK and the MSVC compiler and linker.
### 2. Build Environment Setup If the Windows SDK is installed (e.g. via installation of the Microsoft C/C++
Build Tools), you may also build with [Clang](https://releases.llvm.org/).
Building the codebase can be done in a terminal which is equipped with the
ability to call either MSVC or Clang from command line. ### 2. Build Environment Setup
This is generally done by calling `vcvarsall.bat x64`, which is included in the Building the codebase can be done in a terminal which is equipped with the
Microsoft C/C++ Build Tools. This script is automatically called by the `x64 ability to call either MSVC or Clang from command line.
Native Tools Command Prompt for VS <year>` variant of the vanilla `cmd.exe`. If
you've installed the build tools, this command prompt may be easily located by This is generally done by calling `vcvarsall.bat x64`, which is included in the
searching for `Native` from the Windows Start Menu search. Microsoft C/C++ Build Tools. This script is automatically called by the `x64
Native Tools Command Prompt for VS <year>` variant of the vanilla `cmd.exe`. If
You can ensure that the MSVC compiler is accessible from your command line by you've installed the build tools, this command prompt may be easily located by
running: searching for `Native` from the Windows Start Menu search.
``` You can ensure that the MSVC compiler is accessible from your command line by
cl running:
```
```
If everything is set up correctly, you should have output very similar to the cl
following: ```
``` If everything is set up correctly, you should have output very similar to the
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30151 for x64 following:
Copyright (C) Microsoft Corporation. All rights reserved.
```
usage: cl [ option... ] filename... [ /link linkoption... ] Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30151 for x64
``` Copyright (C) Microsoft Corporation. All rights reserved.
### 3. Building usage: cl [ option... ] filename... [ /link linkoption... ]
```
Within this terminal, `cd` to the root directory of the codebase, and just run
the `build.bat` script: ### 3. Building
``` Within this terminal, `cd` to the root directory of the codebase, and just run
build the `build.bat` script:
```
```
You should see the following output: build
```
```
[debug mode] You should see the following output:
[msvc compile]
[default mode, assuming `raddbg` build] ```
metagen_main.c [debug mode]
searching C:\devel\raddebugger/src... 299 files found [msvc compile]
parsing metadesk... 12 metadesk files parsed metagen_main.c
gathering tables... 37 tables found searching C:\devel\raddebugger/src... 309 files found
generating layer code... parsing metadesk... 15 metadesk files parsed
raddbg.cpp gathering tables... 96 tables found
``` generating layer code...
raddbg_main.c
If everything worked correctly, there will be a `build` folder in the root ```
level of the codebase, and it will contain a freshly-built `raddbg.exe`.
If everything worked correctly, there will be a `build` folder in the root
## Top-Level Directory Descriptions level of the codebase, and it will contain a freshly-built `raddbg.exe`.
- `data`: Small binary files which are used when building, either to embed ## Short-To-Medium-Term Roadmap
within build artifacts, or to package with them.
- `src`: All source code. ### The Initial Alpha Battle-Testing Phase
After setting up the codebase and building, the following directories will The first priority for the project is to ensure that the most crucial debugger
also exist: components are functioning extremely reliably for local, x64, Windows
debugging. This would include parts like debug info conversion, debug info
- `build`: All build artifacts. Not checked in to version control. loading, process control, stepping, evaluation (correct usage of both location
- `local`: Local files, used for local build configuration input files. info and type info), and a robust frontend which ensures the lower level parts
are usable.
## Codebase Introduction
We feel that the debugger has already come a long way in all of these respects,
The codebase is organized into *layers*. Layers are separated either to isolate but given the massive set of possible combinations of languages, build
certain problems, and to allow inclusion into various builds without needing to settings, toolchains, used language features, and patterns of generated code,
pull everything in the codebase into a build. Layers correspond with folders there are still cases where the debugger has not been tested, and so there are
inside of the `src` directory. Sometimes, one folder inside of the `src` still issues. So, we feel that the top priority is eliminating these issues,
directory will include multiple sub-layers, but the structure is intended to be such that the debugging experience is rock solid.
fairly flat.
### Local x64 Linux Debugging Phase
Layers correspond roughly 1-to-1 with *namespaces*. The term "namespaces" in
this context does not refer to specific namespace language features, but rather The next priority for the project is to take the rock solid x64 Windows
a naming convention for C-style namespaces, which are written in the codebase as debugging experience, and port all of the relevant pieces to support local x64
a short prefix, usually 1-3 characters, followed by an underscore. These Linux debugging also.
namespaces are used such that the layer to which certain code belongs may be
quickly understood by glancing at code. The namespaces are generally quite short The debugger has been written to abstract over the parts that need to differ on
to ensure that they aren't much of a hassle to write. Sometimes, multiple sub- either Linux or Windows, and this is mainly going to be a task in building out
layers will share a namespace. A few layers do not have a namespace, but most different backends for those abstraction layers.
do. Namespaces are either all-caps or lowercase depending on the context in
which they're used. For types, enum values, and some macros, they are The major parts of this phase are:
capitalized. For functions and global variables, they are lowercase.
- Porting the `src/demon` layer to implement the Demon local process control
Layers depend on other layers, but circular dependencies would break the abstraction API.
separability and isolation utility of layers (in effect, forming one big layer), - Implementing an x64 ELF Linux unwinder in the `src/ctrl` layer.
so in other words, layers are arranged into a directed acyclic graph. - Creating a DWARF-to-RDI converter (in the same way that we've built a
PDB-to-RDI converter). A partial implementation of this is in
A list of the layers in the codebase and their associated namespaces is below: `src/rdi_from_dwarf`.
- `base` (no namespace): Universal, codebase-wide constructs. Strings, math, - Porting the `src/render` layer to implement all of the rendering features the
memory allocators, helper macros, command-line parsing, and so on. Depends frontend needs on a Linux-compatible API (the backend used on Windows is D3D11).
on no other codebase layers. - Porting the `src/font_provider` layer to a Linux-compatible font
- `coff` (`COFF_`): Code for parsing and/or writing the COFF (Common Object File rasterization backend, like FreeType (the backend used on Windows is
Format) file format. DirectWrite).
- `ctrl` (`CTRL_`): The debugger's "control system" layer. Implements - Porting the `src/os` layers to Linux. This includes core operating system
asynchronous process control, stepping, and breakpoints for all attached abstraction (virtual memory allocation, threading and synchronization
processes. Runs in lockstep with attached processes. When it runs, attached primitives, and so on), and graphical operating system abstraction (windows,
processes are halted. When attached processes are running, it is halted. input events, and so on).
Driven by a debugger frontend on another thread.
- `dasm` (`DASM_`): An asynchronous disassembly decoder and cache. Users ask for Once the above list is complete, and once every part is rock solid, the Windows
disassembly for a particular virtual address range in a process, and threads debugging experience we'll have worked diligently to create will also be
implemented in this layer decode and cache the disassembly for that range. available natively on Linux machines.
- `dbgi` (`DBGI_`): An asynchronous debug info loader and cache. Loads debug
info stored in the RADDBG format. Users ask for debug info for a particular ### And Beyond!
executable, and on separate threads, this layer loads the associated debug
info file. If necessary, it will launch a separate conversion process to There are several directions we might take after these two major phases,
convert original debug info into the RADDBG format. like remote debugging, porting to different architectures, further improving
- `demon` (`DEMON_`): An abstraction layer for local-machine, low-level process the debugger's features (like improving the visualization engine), and so on.
control. The abstraction is used to provide a common interface for process But for now, we're mostly focused on those first two phases.
control on target platforms. Used to implement part of `ctrl`.
- `df/core` (`DF_`): The debugger's non-graphical frontend. Implements a ---
debugger "entity cache" (where "entities" include processes, threads, modules,
breakpoints, source files, targets, and so on). Implements a command loop # The RAD Linker
for driving process control, which is used to implement stepping commands and
user breakpoints. Implements extractors and caches for various entity-related The RAD Linker is a new performance linker for generating x64 PE/COFF binaries. It is designed to be very fast when creating gigantic executables. It generates standard PDB files for debugging, but it can also optionally create RAD Debugger debug info too (useful for huge executables that otherwise create broken PDBs that overflow internal 32-bit tables).
data, like full thread unwinds and local variable maps. Also implements core
building blocks for evaluation and evaluation visualization. The RAD Linker is primarily optimized to handle huge linking projects - in our test cases (where debug info is multiple gigabytes), we see 50% faster link times.
- `df/gfx` (`DF_`): The debugger's graphical frontend. Builds on top of
`df/core` to provide all graphical features, including windows, panels, all The command line syntax is fully compatible with MSVC and you can get a full list of implemented switches from `/help`.
of the various debugger interfaces, and evaluation visualization.
- `draw` (`D_`): Implements a high-level graphics drawing API for the debugger's Our current designed-for use case for the linker is to help with the compile-debug cycle of huge projects. We don't yet have support for dead-code-elimination or link-time-optimizations, but these features are on the road map.
purposes, using the underlying `render` abstraction layer. Provides high-level
APIs for various draw commands, but takes care of batching them, and so on. By default, the RAD linker spawns as many threads as there are cores, so if you plan to run multiple linkers in parallel, you can limit the number of thread workers via `/rad_workers`.
- `eval` (`EVAL_`): Implements a compiler for an expression language built for
evaluation of variables, registers, and so on from debugger-attached processes We also have support for large memory pages, which, when enabled, reduce link time by
and/or debug info. Broken into several phases mostly corresponding to another 25%. To link with large pages, you need to explicitly request them via `/rad_large_pages`. Large pages are off by default, since Windows support for large pages is a bit buggy - we recommend they only be used in Docker or VM images where the environment is reset after each link. In a standard Windows environment, using large pages otherwise will fragment memory quickly forcing a reboot. We are working on a Linux port of the linker that will be able to build with large pages robustly.
traditional compiler phases - lexer, parser, type-checker, IR generation, and
IR evaluation. ## Short Term Roadmap
- `font_cache` (`F_`): Implements a cache of rasterized font data, both in CPU- - Porting linker to Linux (for Windows executables, just running on Linux).
side data for text shaping, and in GPU texture atlases for rasterized glyphs. - Debug info features
All cache information is sourced from the `font_provider` abstraction layer. - Get DWARF debug info converter up-and-running.
- `font_provider` (`FP_`): An abstraction layer for various font file decoding - Smooth out rough edges in RADDBGI builder.
and font rasterization backends. - Improve build speed further (especially for tiny and mid sizes projects).
- `geo_cache` (`GEO_`): Implements an asynchronously-filled cache for GPU - Other features to come
geometry data, filled by data sourced in the `hash_store` layer's cache. Used - Dead-code-elimination via `/opt:ref`.
for asynchronously preparing data for memory visualization in the debugger. - Link Time Optimizations with the help of clang (we won't support LTCG from MSVC compiler since it is undocumented).
- `hash_store` (`HS_`): Implements a cache for general data blobs, keyed by a
128-bit hash of the data. Used as a general data store by other layers. ## To build the RAD Linker
- `metagen` (`MG_`): A metaprogram which is used to generate primarily code and - Setup development environment, [see](#Development-Setup-Instructions)
data tables. Consumes Metadesk files, stored with the extension `.mc`, and - Run `build radlink release` or if you have clang installed `build radlink release clang`. We favor latter option for better code generation.
generates C code which is then included by hand-written C code. Currently, it
does not analyze the codebase's hand-written C code, but in principle this is If build was successful linker executable is placed in `build` folder under `radlink.exe`.
possible. This allows easier & less-error-prone management of large data
tables, which are then used to produce e.g. C `enum`s and a number of ## Benchmarks
associated data tables. There are also a number of other generation features,
like embedding binary files or complex multi-line strings into source code. ![AMD Ryzen Threadripper PRO 3995WX 64-Cores, 256 GiB RAM (Windows x64)](https://github.com/user-attachments/assets/a95b382a-76b4-4a4c-b809-b61fe25e667a)
This layer cannot depend on any other layer in the codebase directly,
including `base`, because it may be used to generate code for those layers. To ---
still use `base` and `os` layer features in the `metagen` program, a separate,
duplicate version of `base` and `os` are included in this layer. They are ## Top-Level Directory Descriptions
updated manually, as needed. This is to ensure the stability of the
metaprogram. - `data`: Small binary files which are used when building, either to embed
- `mule` (no namespace): Test executables for battle testing debugger within build artifacts, or to package with them.
functionality. - `src`: All source code.
- `natvis` (no namespace): NatVis files for type visualization of the codebase's
types in other debuggers. After setting up the codebase and building, the following directories will
- `os/core` (`OS_`): An abstraction layer providing core, non-graphical also exist:
functionality from the operating system under an abstract API, which is
implemented per-target-operating-system. - `build`: All build artifacts. Not checked in to version control.
- `os/gfx` (`OS_`): An abstraction layer, building on `os/core`, providing - `local`: Local files, used for local build configuration input files. Not
graphical operating system features under an abstract API, which is checked in to version control.
implemented per-target-operating-system.
- `os/socket` (`OS_`): An abstraction layer, building on `os/core`, providing ## Codebase Introduction
networking operating system features under an abstract API, which is
implemented per-target-operating-system. The codebase is organized into *layers*. Layers are separated either to isolate
- `pe` (`PE_`): Code for parsing and/or writing the PE (Portable Executable) certain problems, and to allow inclusion into various builds without needing to
file format. pull everything in the codebase into a build. Layers correspond with folders
- `raddbg` (no namespace): The layer which ties everything together for the main inside of the `src` directory. Sometimes, one folder inside of the `src`
graphical debugger. Not much "meat", just drives `df`, implements command line directory will include multiple sub-layers, but the structure is intended to be
options, and so on. fairly flat.
- `raddbg_cons` (`CONS_`): Implements an API for constructing files of the
RADDBG debug info file format. Layers correspond roughly 1-to-1 with *namespaces*. The term "namespaces" in
- `raddbg_dump` (`DUMP_`): A dumper utility program for dumping textualizations this context does not refer to specific namespace language features, but rather
of RADDBG debug info files. a naming convention for C-style namespaces, which are written in the codebase as
- `raddbg_format` (`RADDBG_`): Standalone types and helper functions for the a short prefix, usually 1-3 characters, followed by an underscore. These
RADDBG debug info file format. Does not depend on `base`. namespaces are used such that the layer to which certain code belongs may be
- `raddbg_markup` (`RADDBG_`): Standalone header file for marking up user quickly understood by glancing at code. The namespaces are generally quite short
programs to work with various features in the `raddbg` debugger. Does not to ensure that they aren't much of a hassle to write. Sometimes, multiple sub-
depend on `base`. layers will share a namespace. A few layers do not have a namespace, but most
- `regs` (`REGS_`): Types, helper functions, and metadata for registers on do. Namespaces are either all-caps or lowercase depending on the context in
supported architectures. Used in reading/writing registers in `demon`, or in which they're used. For types, enum values, and some macros, they are
looking up register metadata. capitalized. For functions and global variables, they are lowercase.
- `render` (`R_`): An abstraction layer providing an abstract API for rendering
using various GPU APIs under a common interface. Does not implement a high Layers depend on other layers, but circular dependencies would break the
level drawing API - this layer is strictly for minimally abstracting on an separability and isolation utility of layers (in effect, forming one big layer),
as-needed basis. Higher level drawing features are implemented in the `draw` so in other words, layers are arranged into a directed acyclic graph.
layer.
- `scratch` (no namespace): Scratch space for small and transient test or sample A few layers are built to be used completely independently from the rest of the
programs. codebase, as libraries in other codebases and projects. As such, these layers do
- `texture_cache` (`TEX_`): Implements an asynchronously-filled cache for GPU not depend on any other layers in the codebase. The folders which contain these
texture data, filled by data sourced in the `hash_store` layer's cache. Used layers are prefixed with `lib_`, like `lib_rdi_format`.
for asynchronously preparing data for memory visualization in the debugger.
- `txti` (`TXTI_`): Machinery for asynchronously-loaded, asynchronously hot- A list of the layers in the codebase and their associated namespaces is below:
reloaded, asynchronously parsed, and asynchronously mutated source code files. - `async` (`ASYNC_`): Implements a system for asynchronous work to be queued
Used by the debugger to visualize source code files. Users ask for text lines, and executed on a thread pool.
tokens, and metadata, and it is prepared on background threads. - `base` (no namespace): Universal, codebase-wide constructs. Strings, math,
- `type_graph` (`TG_`): Code for analyzing and navigating type structures from memory allocators, helper macros, command-line parsing, and so on. Depends
RADDBG debug info files, with the additional capability of constructing on no other codebase layers.
synthetic types *not* found in debug info. Used in `eval` and for various - `codeview` (`CV_`): Code for parsing and/or writing the CodeView format.
visualization features. - `coff` (`COFF_`): Code for parsing and/or writing the COFF (Common Object File
- `ui` (`UI_`): Machinery for building graphical user interfaces. Provides a Format) file format.
core immediate mode hierarchical user interface data structure building - `ctrl` (`CTRL_`): The debugger's "control system" layer. Implements
API, and has helper layers for building some higher-level widgets. asynchronous process control, stepping, and breakpoints for all attached
- `unwind` (`UNW_`): Code for generating unwind information from threads, for processes. Runs in lockstep with attached processes. When it runs, attached
supported operating systems and architectures. processes are halted. When attached processes are running, it is halted.
Driven by a debugger frontend on another thread.
- `dasm_cache` (`DASM_`): An asynchronous disassembly decoder and cache. Users
ask for disassembly for some data, with a particular architecture, and other
various parameters, and threads implemented in this layer decode and cache the
disassembly for that data with those parameters.
- `dbgi` (`DI_`): An asynchronous debug info loader and cache. Loads debug info
stored in the RDI format. Users ask for debug info for a particular path, and
on separate threads, this layer loads the associated debug info file. If
necessary, it will launch a separate conversion process to convert original
debug info into the RDI format.
- `dbg_engine` (`D_`): Implements the core debugger system, without any
graphical components. This contains top-level logic for things like stepping,
launching, freezing threads, mid-run breakpoint addition, some caching layers,
and so on.
- `demon` (`DMN_`): An abstraction layer for local-machine, low-level process
control. The abstraction is used to provide a common interface for process
control on target platforms. Used to implement part of `ctrl`.
- `draw` (`DR_`): Implements a high-level graphics drawing API for the
debugger's purposes, using the underlying `render` abstraction layer. Provides
high-level APIs for various draw commands, but takes care of batching them,
and so on.
- `eval` (`E_`): Implements a compiler for an expression language built for
evaluation of variables, registers, types, and more, from debugger-attached
processes, debug info, debugger state, and files. Broken into several phases
mostly corresponding to traditional compiler phases - lexer, parser,
type-checker, IR generation, and IR evaluation.
- `eval_visualization` (`EV_`): Implements the core non-graphical evaluation
visualization engine, which can be used to visualize evaluations (provided by
the `eval` layer) in a number of ways. Implements core data structures and
transforms for the `Watch` view.
- `file_stream` (`FS_`): Provides asynchronous file loading, storing the
artifacts inside of the cache implemented by the `hash_store` layer, and
hot-reloading the contents of files when they change. Allows callers to map
file paths to data hashes, which can then be used to obtain the file's data.
- `font_cache` (`FNT_`): Implements a cache of rasterized font data, both in
CPU-side data for text shaping, and in GPU texture atlases for rasterized
glyphs. All cache information is sourced from the `font_provider` abstraction
layer.
- `font_provider` (`FP_`): An abstraction layer for various font file decoding
and font rasterization backends.
- `fuzzy_search` (`FZY_`): Provides a fuzzy searching engine for doing
large, asynchronous fuzzy searches. Used by the debugger for implementing
things like the symbol lister or the `Procedures` view, which search across
all loaded debug info records, using fuzzy matching rules.
- `geo_cache` (`GEO_`): Implements an asynchronously-filled cache for GPU
geometry data, filled by data sourced in the `hash_store` layer's cache. Used
for asynchronously preparing data for visualization.
- `hash_store` (`HS_`): Implements a cache for general data blobs, keyed by a
128-bit hash of the data. Also implements a 128-bit key cache on top, where
the keys refer to a unique identity, associated with a 128-bit hash, where the
hash may change across time. Used as a general data store by other layers.
- `lib_raddbg_markup` (`RADDBG_`): Standalone library for marking up user
programs to work with various features in the debugger. Does not depend on
`base`, and can be independently relocated to other codebases.
- `lib_rdi_format` (`RDI_`): Standalone library which defines the core RDI types
and helper functions for reading and writing the RDI debug info file format.
Does not depend on `base`, and can be independently relocated to other
codebases.
- `lib_rdi_make` (`RDIM_`): Standalone library for constructing RDI debug info
data. Does not depend on `base`, and can be independently relocated
to other codebases.
- `mdesk` (`MD_`): Code for parsing Metadesk files (stored as `.mdesk`), which
is the JSON-like (technically a JSON superset) text format used for the
debugger's user and project configuration files, view rules, and metacode,
which is parsed and used to generate code with the `metagen` layer.
- `metagen` (`MG_`): A metaprogram which is used to generate primarily code and
data tables. Consumes Metadesk files, stored with the extension `.mdesk`, and
generates C code which is then included by hand-written C code. Currently, it
does not analyze the codebase's hand-written C code, but in principle this is
possible. This allows easier & less-error-prone management of large data
tables, which are then used to produce e.g. C `enum`s and a number of
associated data tables. There are also a number of other generation features,
like embedding binary files or complex multi-line strings into source code.
This layer cannot depend on any other layer in the codebase directly,
including `base`, because it may be used to generate code for those layers. To
still use `base` and `os` layer features in the `metagen` program, a separate,
duplicate version of `base` and `os` are included in this layer. They are
updated manually, as needed. This is to ensure the stability of the
metaprogram.
- `msf` (`MSF_`): Code for parsing and/or writing the MSF file format.
- `mule` (no namespace): Test executables for battle testing debugger
functionality.
- `mutable_text` (`MTX_`): Implements an asynchronously-filled-and-mutated
cache for text buffers which are mutated across time. In the debugger, this is
used to implement the `Output` view.
- `natvis` (no namespace): NatVis files for type visualization of the codebase's
types in other debuggers.
- `os/core` (`OS_`): An abstraction layer providing core, non-graphical
functionality from the operating system under an abstract API, which is
implemented per-target-operating-system.
- `os/gfx` (`OS_`): An abstraction layer, building on `os/core`, providing
graphical operating system features under an abstract API, which is
implemented per-target-operating-system.
- `path` (`PATH_`): Small helpers for manipulating file path strings.
- `pdb` (`PDB_`): Code for parsing and/or writing the PDB file format.
- `pe` (`PE_`): Code for parsing and/or writing the PE (Portable Executable)
file format.
- `raddbg` (`RD_`): The layer which ties everything together for the main
graphical debugger. Implements the debugger's graphical frontend, all of the
debugger-specific UI, the debugger executable's command line interface, and
all of the built-in visualizers.
- `rdi_breakpad_from_pdb` (`P2B_`): Our implementation, using the codebase's RDI
technology, for extracting information from PDBs and generating Breakpad text
dumps.
- `rdi_dump` (no namespace): A dumper utility program for dumping
textualizations of RDI debug info files.
- `rdi_format` (no namespace): A layer which includes the `lib_rdi_format` layer
and bundles it with codebase-specific helpers, to easily include the library
in codebase programs, and have it be integrated with codebase constructs.
- `rdi_from_dwarf` (`D2R_`): Our in-progress implementation of DWARF-to-RDI
conversion.
- `rdi_from_pdb` (`P2R_`): Our implementation of PDB-to-RDI conversion.
- `rdi_make` (no namespace): A layer which includes the `lib_rdi_make` layer and
bundles it with codebase-specific helpers, to easily include the library in
codebase programs, and have it be integrated with codebase constructs.
- `regs` (`REGS_`): Types, helper functions, and metadata for registers on
supported architectures. Used in reading/writing registers in `demon`, or in
looking up register metadata.
- `render` (`R_`): An abstraction layer providing an abstract API for rendering
using various GPU APIs under a common interface. Does not implement a high
level drawing API - this layer is strictly for minimally abstracting on an
as-needed basis. Higher level drawing features are implemented in the `draw`
layer.
- `scratch` (no namespace): Scratch space for small and transient test programs.
- `texture_cache` (`TEX_`): Implements an asynchronously-filled cache for GPU
texture data, filled by data sourced in the `hash_store` layer's cache. Used
for asynchronously preparing data for visualization.
- `text_cache` (`TXT_`): Implements an asynchronously-filled cache for textual
analysis data (tokens, line ranges, and so on), filled by data sourced in the
`hash_store` layer's cache. Used for asynchronously preparing data for
visualization (like for the source code viewer).
- `third_party` (no namespace): External code from other projects, which some
layers in the codebase depend on. All external code is included and built
directly within the codebase.
- `ui` (`UI_`): Machinery for building graphical user interfaces. Provides a
core immediate mode hierarchical user interface data structure building
API, and has helper layers for building some higher-level widgets.
+144 -105
View File
@@ -1,105 +1,144 @@
@echo off @echo off
setlocal setlocal enabledelayedexpansion
cd /D "%~dp0" cd /D "%~dp0"
:: --- Usage Notes (2024/1/10) ------------------------------------------------ :: --- Usage Notes (2024/1/10) ------------------------------------------------
:: ::
:: This is a central build script for the RAD Debugger project. It takes a list :: This is a central build script for the RAD Debugger project, for use in
:: of simple alphanumeric-only arguments which control (a) what is built, (b) :: Windows development environments. It takes a list of simple alphanumeric-
:: which compiler & linker are used, and (c) extra high-level build options. By :: only arguments which control (a) what is built, (b) which compiler & linker
:: default, if no options are passed, then the main "raddbg" graphical debugger :: are used, and (c) extra high-level build options. By default, if no options
:: is built. :: are passed, then the main "raddbg" graphical debugger is built.
:: ::
:: Below is a non-exhaustive list of possible ways to use the script: :: Below is a non-exhaustive list of possible ways to use the script:
:: `build raddbg` :: `build raddbg`
:: `build raddbg clang` :: `build raddbg clang`
:: `build raddbg release` :: `build raddbg release`
:: `build raddbg asan telemetry` :: `build raddbg asan telemetry`
:: `build raddbg_from_pdb` :: `build rdi_from_pdb`
:: ::
:: For a full list of possible build targets and their build command lines, :: For a full list of possible build targets and their build command lines,
:: search for @build_targets in this file. :: search for @build_targets in this file.
:: ::
:: Below is a list of all possible non-target command line options: :: Below is a list of all possible non-target command line options:
:: ::
:: - `asan`: enable address sanitizer :: - `asan`: enable address sanitizer
:: - `telemetry`: enable RAD telemetry profiling support :: - `telemetry`: enable RAD telemetry profiling support
:: --- Unpack Arguments ------------------------------------------------------- :: --- Unpack Arguments -------------------------------------------------------
for %%a in (%*) do set "%%a=1" for %%a in (%*) do set "%%a=1"
if not "%msvc%"=="1" if not "%clang%"=="1" set msvc=1 if not "%msvc%"=="1" if not "%clang%"=="1" set msvc=1
if not "%release%"=="1" set debug=1 if not "%release%"=="1" set debug=1
if "%debug%"=="1" set release=0 && echo [debug mode] if "%debug%"=="1" set release=0 && echo [debug mode]
if "%release%"=="1" set debug=0 && echo [release mode] if "%release%"=="1" set debug=0 && echo [release mode]
if "%msvc%"=="1" set clang=0 && echo [msvc compile] if "%msvc%"=="1" set clang=0 && echo [msvc compile]
if "%clang%"=="1" set msvc=0 && echo [clang compile] if "%clang%"=="1" set msvc=0 && echo [clang compile]
if "%~1"=="" echo [default mode, assuming `raddbg` build] && set raddbg=1 if "%~1"=="" echo [default mode, assuming `raddbg` build] && set raddbg=1
if "%~1"=="release" if "%~2"=="" echo [default mode, assuming `raddbg` build] && set raddbg=1
:: --- Unpack Command Line Build Arguments ------------------------------------
set auto_compile_flags= :: --- Unpack Command Line Build Arguments ------------------------------------
if "%telemetry%"=="1" set auto_compile_flags=%auto_compile_flags% -DPROFILE_TELEMETRY=1 && echo [telemetry profiling enabled] set auto_compile_flags=
if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=address && echo [asan enabled] if "%telemetry%"=="1" set auto_compile_flags=%auto_compile_flags% -DPROFILE_TELEMETRY=1 && echo [telemetry profiling enabled]
if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=address && echo [asan enabled]
:: --- Compile/Link Line Definitions ------------------------------------------
set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7 /MP :: --- Compile/Link Line Definitions ------------------------------------------
set clang_common= -I..\src\ -I..\local\ -maes -mssse3 -msse4 -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7
set cl_debug= call cl /Od /D_DEBUG %cl_common% set clang_common= -I..\src\ -I..\local\ -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-unknown-warning-option -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -ferror-limit=10000
set cl_release= call cl /O2 /DNDEBUG %cl_common% set cl_debug= call cl /Od /Ob1 /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags%
set clang_debug= call clang -g -O0 /D_DEBUG %clang_common% set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common% %auto_compile_flags%
set clang_release= call clang -g -O3 /DNDEBUG %clang_common% set clang_debug= call clang -g -O0 -DBUILD_DEBUG=1 %clang_common% %auto_compile_flags%
set cl_link= /link /natvis:"%~dp0\src\natvis\base.natvis" set clang_release= call clang -g -O2 -DBUILD_DEBUG=0 %clang_common% %auto_compile_flags%
set clang_link= -Xlinker /natvis:"%~dp0\src\natvis\base.natvis" set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO /pdbaltpath:%%%%_PDB%%%%
set cl_out= /out: set clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker /pdbaltpath:%%%%_PDB%%%%
set clang_out= -o set cl_out= /out:
set clang_out= -o
:: --- Per-Build Settings -----------------------------------------------------
set gfx=-DOS_FEATURE_GRAPHICAL=1 :: --- NATVIS -----------------------------------------------------------------
set net=-DOS_FEATURE_SOCKET=1 set natvis= /NATVIS:"%~dp0\src\natvis\base.natvis"
set link_dll=-DLL if "%radlink%"=="1" set natvis= %natvis% /NATVIS:"%~dp0\src\linker\linker.natvis"
:: --- Choose Compile/Link Lines ---------------------------------------------- if "%clang%"=="1" (
if "%msvc%"=="1" set compile_debug=%cl_debug% set result=
if "%msvc%"=="1" set compile_release=%cl_release% for %%n in (%natvis%) do set result= !result! -Xlinker %%n
if "%msvc%"=="1" set compile_link=%cl_link% set natvis= !result!
if "%msvc%"=="1" set out=%cl_out% )
if "%clang%"=="1" set compile_debug=%clang_debug%
if "%clang%"=="1" set compile_release=%clang_release% :: --- Per-Build Settings -----------------------------------------------------
if "%clang%"=="1" set compile_link=%clang_link% set link_dll=-DLL
if "%clang%"=="1" set out=%clang_out% set link_icon=logo.res
if "%debug%"=="1" set compile=%compile_debug% if "%msvc%"=="1" set only_compile=/c
if "%release%"=="1" set compile=%compile_release% if "%clang%"=="1" set only_compile=-c
set compile=%compile% %auto_compile_flags% if "%msvc%"=="1" set EHsc=/EHsc
if "%clang%"=="1" set EHsc=
:: --- Prep Directories ------------------------------------------------------- if "%msvc%"=="1" set no_aslr=/DYNAMICBASE:NO
if not exist build mkdir build if "%clang%"=="1" set no_aslr=-Wl,/DYNAMICBASE:NO
if not exist local mkdir local if "%msvc%"=="1" set rc=call rc
if "%clang%"=="1" set rc=call llvm-rc
:: --- Build & Run Metaprogram ------------------------------------------------
if "%no_meta%"=="1" echo [skipping metagen] :: --- Choose Compile/Link Lines ----------------------------------------------
if not "%no_meta%"=="1" ( if "%msvc%"=="1" set compile_debug=%cl_debug%
pushd build if "%msvc%"=="1" set compile_release=%cl_release%
%compile_debug% ..\src\metagen\metagen_main.c %compile_link% %out%metagen.exe if "%msvc%"=="1" set compile_link=%cl_link%
metagen.exe if "%msvc%"=="1" set out=%cl_out%
popd if "%clang%"=="1" set compile_debug=%clang_debug%
) if "%clang%"=="1" set compile_release=%clang_release%
if "%clang%"=="1" set compile_link=%clang_link%
:: --- Build Everything (@build_targets) -------------------------------------- if "%clang%"=="1" set out=%clang_out%
pushd build if "%debug%"=="1" set compile=%compile_debug%
if "%raddbg%"=="1" %compile% %gfx% ..\src\raddbg\raddbg.cpp %compile_link% %out%raddbg.exe if "%release%"=="1" set compile=%compile_release%
if "%raddbg_from_pdb%"=="1" %compile% ..\src\raddbg_convert\pdb\raddbg_from_pdb_main.c %compile_link% %out%raddbg_from_pdb.exe
if "%raddbg_from_dwarf%"=="1" %compile% ..\src\raddbg_convert\dwarf\raddbg_from_dwarf.c %compile_link% %out%raddbg_from_dwarf.exe :: --- Append NATVIS to link line ---------------------------------------------
if "%raddbg_dump%"=="1" %compile% ..\src\raddbg_dump\raddbg_dump.c %compile_link% %out%raddbg_dump.exe set compile_link= %compile_link% %natvis%
if "%ryan_scratch%"=="1" %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe
if "%look_at_raddbg%"=="1" %compile% ..\src\scratch\look_at_raddbg.c %compile_link% %out%look_at_raddbg.exe :: --- Prep Directories -------------------------------------------------------
if "%mule_main%"=="1" del vc*.pdb mule*.pdb && %cl_release% /c ..\src\mule\mule_inline.cpp && %cl_release% /c ..\src\mule\mule_o2.cpp && %cl_debug% /EHsc ..\src\mule\mule_main.cpp mule\mule_c.c mule_inline.obj mule_o2.obj if not exist build mkdir build
if "%mule_module%"=="1" %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll if not exist local mkdir local
popd
:: --- Produce Logo Icon File -------------------------------------------------
:: --- Unset ------------------------------------------------------------------ pushd build
for %%a in (%*) do set "%%a=0" %rc% /nologo /fo logo.res ..\data\logo.rc || exit /b 1
set raddbg= popd
set compile=
set compile_link= :: --- Get Current Git Commit Id ----------------------------------------------
set out= for /f %%i in ('call git describe --always --dirty') do set compile=%compile% -DBUILD_GIT_HASH=\"%%i\"
set msvc= for /f %%i in ('call git rev-parse HEAD') do set compile=%compile% -DBUILD_GIT_HASH_FULL=\"%%i\"
set debug=
:: --- Build & Run Metaprogram ------------------------------------------------
if "%no_meta%"=="1" echo [skipping metagen]
if not "%no_meta%"=="1" (
pushd build
%compile_debug% ..\src\metagen\metagen_main.c %compile_link% %out%metagen.exe || exit /b 1
metagen.exe || exit /b 1
popd
)
:: --- Build Everything (@build_targets) --------------------------------------
pushd build
if "%raddbg%"=="1" set didbuild=1 && %compile% ..\src\raddbg\raddbg_main.c %compile_link% %link_icon% %out%raddbg.exe || exit /b 1
if "%radlink%"=="1" set didbuild=1 && %compile% ..\src\linker\lnk.c %compile_link% %out%radlink.exe || exit /b 1
if "%rdi_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_from_pdb\rdi_from_pdb_main.c %compile_link% %out%rdi_from_pdb.exe || exit /b 1
if "%rdi_from_dwarf%"=="1" set didbuild=1 && %compile% ..\src\rdi_from_dwarf\rdi_from_dwarf.c %compile_link% %out%rdi_from_dwarf.exe || exit /b 1
if "%rdi_dump%"=="1" set didbuild=1 && %compile% ..\src\rdi_dump\rdi_dump_main.c %compile_link% %out%rdi_dump.exe || exit /b 1
if "%rdi_breakpad_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_breakpad_from_pdb\rdi_breakpad_from_pdb_main.c %compile_link% %out%rdi_breakpad_from_pdb.exe || exit /b 1
if "%tester%"=="1" set didbuild=1 && %compile% ..\src\tester\tester_main.c %compile_link% %out%tester.exe || exit /b 1
if "%ryan_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe || exit /b 1
if "%textperf%"=="1" set didbuild=1 && %compile% ..\src\scratch\textperf.c %compile_link% %out%textperf.exe || exit /b 1
if "%parse_inline_sites%"=="1" set didbuild=1 && %compile% ..\src\scratch\parse_inline_sites.c %compile_link% %out%parse_inline_sites.exe || exit /b 1
if "%mule_main%"=="1" set didbuild=1 && del vc*.pdb mule*.pdb && %compile_release% %only_compile% ..\src\mule\mule_inline.cpp && %compile_release% %only_compile% ..\src\mule\mule_o2.cpp && %compile_debug% %EHsc% ..\src\mule\mule_main.cpp ..\src\mule\mule_c.c mule_inline.obj mule_o2.obj %compile_link% %no_aslr% %out%mule_main.exe || exit /b 1
if "%mule_module%"=="1" set didbuild=1 && %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll || exit /b 1
if "%mule_hotload%"=="1" set didbuild=1 && %compile% ..\src\mule\mule_hotload_main.c %compile_link% %out%mule_hotload.exe & %compile% ..\src\mule\mule_hotload_module_main.c %compile_link% %link_dll% %out%mule_hotload_module.dll || exit /b 1
if "%mule_peb_trample%"=="1" (
set didbuild=1
if exist mule_peb_trample.exe move mule_peb_trample.exe mule_peb_trample_old_%random%.exe
if exist mule_peb_trample_new.pdb move mule_peb_trample_new.pdb mule_peb_trample_old_%random%.pdb
if exist mule_peb_trample_new.rdi move mule_peb_trample_new.rdi mule_peb_trample_old_%random%.rdi
%compile% ..\src\mule\mule_peb_trample.c %compile_link% %out%mule_peb_trample_new.exe || exit /b 1
move mule_peb_trample_new.exe mule_peb_trample.exe
)
popd
:: --- Warn On No Builds ------------------------------------------------------
if "%didbuild%"=="" (
echo [WARNING] no valid build target specified; must use build target names as arguments to this script, like `build raddbg` or `build rdi_from_pdb`.
exit /b 1
)
+79
View File
@@ -0,0 +1,79 @@
#!/bin/bash
set -eu
cd "$(dirname "$0")"
# --- Unpack Arguments --------------------------------------------------------
for arg in "$@"; do declare $arg='1'; done
if [ ! -v gcc ]; then clang=1; fi
if [ ! -v release ]; then debug=1; fi
if [ -v debug ]; then echo "[debug mode]"; fi
if [ -v release ]; then echo "[release mode]"; fi
if [ -v clang ]; then compiler="${CC:-clang}"; echo "[clang compile]"; fi
if [ -v gcc ]; then compiler="${CC:-gcc}"; echo "[gcc compile]"; fi
# --- Unpack Command Line Build Arguments -------------------------------------
auto_compile_flags=''
# --- Get Current Git Commit Id -----------------------------------------------
git_hash=$(git rev-parse HEAD)
git_hash_full=$(git rev-parse HEAD)
# --- Compile/Link Line Definitions -------------------------------------------
clang_common="-I../src/ -I../local/ -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"
clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}"
clang_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${clang_common} ${auto_compile_flags}"
clang_link="-lpthread -lm -lrt -ldl"
clang_out="-o"
gcc_common="-I../src/ -I../local/ -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"
gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common} ${auto_compile_flags}"
gcc_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${gcc_common} ${auto_compile_flags}"
gcc_link="-lpthread -lm -lrt -ldl"
gcc_out="-o"
# --- Per-Build Settings ------------------------------------------------------
link_dll="-fPIC"
link_os_gfx="-lX11 -lXext"
# --- Choose Compile/Link Lines -----------------------------------------------
if [ -v gcc ]; then compile_debug="$gcc_debug"; fi
if [ -v gcc ]; then compile_release="$gcc_release"; fi
if [ -v gcc ]; then compile_link="$gcc_link"; fi
if [ -v gcc ]; then out="$gcc_out"; fi
if [ -v clang ]; then compile_debug="$clang_debug"; fi
if [ -v clang ]; then compile_release="$clang_release"; fi
if [ -v clang ]; then compile_link="$clang_link"; fi
if [ -v clang ]; then out="$clang_out"; fi
if [ -v debug ]; then compile="$compile_debug"; fi
if [ -v release ]; then compile="$compile_release"; fi
# --- Prep Directories --------------------------------------------------------
mkdir -p build
mkdir -p local
# --- Build & Run Metaprogram -------------------------------------------------
if [ -v no_meta ]; then echo "[skipping metagen]"; fi
if [ ! -v no_meta ]
then
cd build
$compile_debug ../src/metagen/metagen_main.c $compile_link $out metagen
./metagen
cd ..
fi
# --- Build Everything (@build_targets) ---------------------------------------
cd build
if [ -v raddbg ]; then didbuild=1 && $compile ../src/raddbg/raddbg_main.c $compile_link $link_os_gfx $out raddbg; fi
if [ -v radlink ]; then didbuild=1 && $compile ../src/linker/lnk.c $compile_link $out radlink; fi
if [ -v rdi_from_pdb ]; then didbuild=1 && $compile ../src/rdi_from_pdb/rdi_from_pdb_main.c $compile_link $out rdi_from_pdb; fi
if [ -v rdi_from_dwarf ]; then didbuild=1 && $compile ../src/rdi_from_dwarf/rdi_from_dwarf.c $compile_link $out rdi_from_dwarf; fi
if [ -v rdi_dump ]; then didbuild=1 && $compile ../src/rdi_dump/rdi_dump_main.c $compile_link $out rdi_dump; fi
if [ -v rdi_breakpad_from_pdb ]; then didbuild=1 && $compile ../src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c $compile_link $out rdi_breakpad_from_pdb; fi
if [ -v ryan_scratch ]; then didbuild=1 && $compile ../src/scratch/ryan_scratch.c $compile_link $link_os_gfx $out ryan_scratch; fi
cd ..
# --- Warn On No Builds -------------------------------------------------------
if [ ! -v didbuild ]
then
echo "[WARNING] no valid build target specified; must use build target names as arguments to this script, like \`./build.sh raddbg\` or \`./build.sh rdi_from_pdb\`."
exit 1
fi
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

+1
View File
@@ -0,0 +1 @@
1 ICON DISCARDABLE "logo.ico"
+98 -118
View File
@@ -1,118 +1,98 @@
version(2); version(2);
project_name = "The RAD Debugger"; project_name = "The RAD Debugger";
indent_width = "2"; indent_width = "2";
default_tab_width = "2"; default_tab_width = "2";
patterns = patterns =
{ {
"*.c", "*.c",
"*.cpp", "*.cpp",
"*.h", "*.h",
"*.inc", "*.inc",
"*.hpp", "*.hpp",
"*.bat", "*.bat",
"*.sh", "*.sh",
"*.4coder", "*.4coder",
"*.glsl", "*.glsl",
"*.bfs", "*.bfs",
"*.html", "*.html",
"*.txt", "*.txt",
"*.ds", "*.md",
"*.md", "*.mdesk",
"*.mc", "*.asm",
"*.asm", };
};
blacklist_patterns =
blacklist_patterns = {
{ ".*",
".*", "metagen_base_*",
"metagen_base_*", "metagen_os_*",
"metagen_os_*", };
};
paths =
paths = {
{ { .path = ".", .recursive = false, .relative = true, },
{ .path = ".", .recursive = false, .relative = true, }, { .path = "src", .recursive = true , .relative = true, },
{ .path = "src", .recursive = true , .relative = true, }, { .path = "local", .recursive = true , .relative = true, },
{ .path = "local", .recursive = true , .relative = true, }, };
};
load_paths =
load_paths = {
{ .win = paths,
.win = paths, .linux = paths,
.linux = paths, };
};
commands =
commands = {
{ //- rjf: fkey command slots (change locally but do not commit)
.rjf_f1 = .f1 = { .win = "build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
{ .f2 = { .win = "build rdi_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.win = "build raddbg telemetry", .f3 = { .win = "pushd build && raddbg.exe --user:local_dev.raddbg_user --project:local_dev.raddbg_project --xuto_run && popd",.linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.linux = "", // .f1 = { .win = "build textperf release telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.out = "*compilation*", // .f3 = { .win = "pushd build && textperf.exe --capture && popd",.linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.footer_panel = true,
.save_dirty_files = true, //- rjf: local target builds
.cursor_at_end = false, .build_raddbg = { .win = "build raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
}, .build_rdi_from_pdb = { .win = "build rdi_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.rjf_f3 = .build_rdi_from_dwarf = { .win = "build rdi_from_dwarf", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
{ .build_rdi_dump = { .win = "build rdi_dump", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.win = "pushd build && raddbg.exe && popd", .build_rdi_breakpad_from_pdb = { .win = "build rdi_breakpad_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.linux = "", .build_ryan_scratch = { .win = "build ryan_scratch", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.out = "*compilation*", .build_mule_main = { .win = "build mule_main", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.footer_panel = true, .build_mule_module = { .win = "build mule_module", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.save_dirty_files = true, .build_mule_hotload = { .win = "build mule_hotload", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.cursor_at_end = false, .build_mule_peb_trample = { .win = "build mule_peb_trample", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
},
.build_raddbg = //- rjf: wsl target builds
{ .build_raddbg_wsl = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.win = "build raddbg", .build_rdi_from_pdb_wsl = { .win = "wsl ./build.sh rdi_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.linux = "", .build_rdi_from_dwarf_wsl = { .win = "wsl ./build.sh rdi_from_dwarf", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.out = "*compilation*", .build_rdi_dump_wsl = { .win = "wsl ./build.sh rdi_dump", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.footer_panel = true, .build_rdi_breakpad_from_pdb_wsl = { .win = "wsl ./build.sh rdi_breakpad_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.save_dirty_files = true, .build_ryan_scratch_wsl = { .win = "wsl ./build.sh ryan_scratch", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.cursor_at_end = false, .build_mule_main_wsl = { .win = "wsl ./build.sh mule_main", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
}, .build_mule_module_wsl = { .win = "wsl ./build.sh mule_module", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.build_raddbg_from_pdb = .build_mule_hotload_wsl = { .win = "wsl ./build.sh mule_hotload", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
{ .build_mule_peb_trample_wsl = { .win = "wsl ./build.sh mule_peb_trample", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.win = "build raddbg_from_pdb",
.linux = "", //- rjf: local target runs
.out = "*compilation*", .run_raddbg = { .win = "pushd build && raddbg.exe && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.footer_panel = true, };
.save_dirty_files = true,
.cursor_at_end = false, fkey_command =
}, {
.build_mule_main = .F1 = "f1",
{ .F2 = "f2",
.win = "build mule_main", .F3 = "f3",
.linux = "", };
.out = "*compilation*",
.footer_panel = true, fkey_command_override =
.save_dirty_files = true, {
.cursor_at_end = false, .rjf =
}, {
.run_raddbg = .F1 = "f1",
{ .F2 = "f2",
.win = "pushd build && raddbg.exe && popd", .F3 = "f3",
.linux = "", },
.out = "*compilation*", };
.footer_panel = true,
.save_dirty_files = true,
.cursor_at_end = false,
},
};
fkey_command =
{
.F1 = "build_raddbg",
.F3 = "run_raddbg",
};
fkey_command_override =
{
.rjf =
{
.F1 = "rjf_f1",
.F3 = "rjf_f3",
},
};
+21
View File
@@ -0,0 +1,21 @@
@echo off
setlocal
cd /D "%~dp0"
echo --- getting test data folder path ---------------------------------------------
if not exist .\local\test_data_path.txt (
echo error: You must first store the full path of your test data folder inside of `local/test_data_path.txt`.
goto :EOF
)
set /p test_data_folder=<.\local\test_data_path.txt
echo test data path: %test_data_folder%
echo:
echo --- building all testing executables ------------------------------------------
call build rdi_from_pdb rdi_dump raddbg radlink tester
echo:
echo --- running tests -------------------------------------------------------------
pushd build
call tester.exe --test_data:%test_data_folder%
popd
+240
View File
@@ -0,0 +1,240 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Top-Level Layer Initialization
internal void
async_init(void)
{
Arena *arena = arena_alloc();
async_shared = push_array(arena, ASYNC_Shared, 1);
async_shared->arena = arena;
for EachEnumVal(ASYNC_Priority, p)
{
ASYNC_Ring *ring = &async_shared->rings[p];
ring->ring_size = MB(8);
ring->ring_base = push_array_no_zero(arena, U8, ring->ring_size);
ring->ring_mutex = os_mutex_alloc();
ring->ring_cv = os_condition_variable_alloc();
}
async_shared->ring_mutex = os_mutex_alloc();
async_shared->ring_cv = os_condition_variable_alloc();
async_shared->work_threads_count = Max(1, os_get_system_info()->logical_processor_count-1);
async_shared->work_threads = push_array(arena, OS_Handle, async_shared->work_threads_count);
for EachIndex(idx, async_shared->work_threads_count)
{
async_shared->work_threads[idx] = os_thread_launch(async_work_thread__entry_point, (void *)idx, 0);
}
}
////////////////////////////////
//~ rjf: Top-Level Accessors
internal U64
async_thread_count(void)
{
return async_shared->work_threads_count;
}
////////////////////////////////
//~ rjf: Work Kickoffs
internal B32
async_push_work_(ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params)
{
// rjf: choose ring
ASYNC_Ring *ring = &async_shared->rings[params->priority];
// rjf: build work package
ASYNC_Work work = {0};
work.work_function = work_function;
work.input = params->input;
work.output = params->output;
work.semaphore = params->semaphore;
work.completion_counter = params->completion_counter;
// rjf: loop; try to write into user -> writer ring buffer. if we're on a
// worker thread, determine if we need to execute this task locally on this
// thread, and skip ring buffer if so.
B32 queued_in_ring_buffer = 0;
B32 need_to_execute_on_this_thread = 0;
OS_MutexScope(ring->ring_mutex) for(;;)
{
U64 num_available_work_threads = (async_shared->work_threads_count - ins_atomic_u64_eval(&async_shared->work_threads_live_count));
if(num_available_work_threads == 0 && async_work_thread_depth > 0)
{
need_to_execute_on_this_thread = 1;
break;
}
U64 unconsumed_size = ring->ring_write_pos - ring->ring_read_pos;
U64 available_size = ring->ring_size - unconsumed_size;
if(available_size >= sizeof(work))
{
queued_in_ring_buffer = 1;
if(!os_handle_match(params->semaphore, os_handle_zero()))
{
os_semaphore_take(params->semaphore, max_U64);
}
ring->ring_write_pos += ring_write_struct(ring->ring_base, ring->ring_size, ring->ring_write_pos, &work);
break;
}
if(os_now_microseconds() >= params->endt_us)
{
break;
}
os_condition_variable_wait(ring->ring_cv, ring->ring_mutex, params->endt_us);
}
// rjf: broadcast ring buffer cv if we wrote successfully
if(queued_in_ring_buffer)
{
os_condition_variable_broadcast(ring->ring_cv);
os_condition_variable_broadcast(async_shared->ring_cv);
}
// rjf: if we did not queue successfully, and we have determined that
// we need to execute this work on the current thread, then execute the
// work before returning
if(need_to_execute_on_this_thread)
{
async_execute_work(work);
}
// rjf: return success signal
B32 result = (queued_in_ring_buffer || need_to_execute_on_this_thread);
return result;
}
////////////////////////////////
//~ rjf: Task-Based Work Helper
internal void
async_task_list_push(Arena *arena, ASYNC_TaskList *list, ASYNC_Task *t)
{
ASYNC_TaskNode *n = push_array(arena, ASYNC_TaskNode, 1);
SLLQueuePush(list->first, list->last, n);
n->v = t;
list->count += 1;
}
internal ASYNC_Task *
async_task_launch_(Arena *arena, ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params)
{
ASYNC_Task *task = push_array(arena, ASYNC_Task, 1);
task->semaphore = os_semaphore_alloc(1, 1, str8_zero());
ASYNC_WorkParams params_refined = {0};
MemoryCopyStruct(&params_refined, params);
params_refined.endt_us = max_U64;
params_refined.semaphore = task->semaphore;
if(params_refined.output == 0)
{
params_refined.output = &task->output;
}
async_push_work_(work_function, &params_refined);
return task;
}
internal void *
async_task_join(ASYNC_Task *task)
{
void *result = 0;
if(task != 0 && !os_handle_match(task->semaphore, os_handle_zero()))
{
os_semaphore_take(task->semaphore, max_U64);
os_semaphore_release(task->semaphore);
MemoryZeroStruct(&task->semaphore);
result = (void *)ins_atomic_u64_eval(&task->output);
}
return result;
}
////////////////////////////////
//~ rjf: Work Execution
internal ASYNC_Work
async_pop_work(void)
{
ProfBeginFunction();
ASYNC_Work work = {0};
B32 done = 0;
ASYNC_Priority taken_priority = ASYNC_Priority_Low;
OS_MutexScope(async_shared->ring_mutex) for(;!done;)
{
for(ASYNC_Priority priority = ASYNC_Priority_High;; priority = (ASYNC_Priority)(priority - 1))
{
ASYNC_Ring *ring = &async_shared->rings[priority];
OS_MutexScope(ring->ring_mutex)
{
U64 unconsumed_size = ring->ring_write_pos - ring->ring_read_pos;
if(unconsumed_size >= sizeof(work))
{
ring->ring_read_pos += ring_read_struct(ring->ring_base, ring->ring_size, ring->ring_read_pos, &work);
done = 1;
taken_priority = priority;
}
}
if(done)
{
break;
}
if(priority == ASYNC_Priority_Low)
{
break;
}
}
if(!done)
{
os_condition_variable_wait(async_shared->ring_cv, async_shared->ring_mutex, max_U64);
}
}
os_condition_variable_broadcast(async_shared->ring_cv);
os_condition_variable_broadcast(async_shared->rings[taken_priority].ring_cv);
ProfEnd();
return work;
}
internal void
async_execute_work(ASYNC_Work work)
{
//- rjf: run work
async_work_thread_depth += 1;
void *work_out = work.work_function(async_work_thread_idx, work.input);
async_work_thread_depth -= 1;
//- rjf: store output
if(work.output != 0)
{
ins_atomic_u64_eval_assign((U64 *)work.output, (U64)work_out);
}
//- rjf: release semaphore
if(!os_handle_match(work.semaphore, os_handle_zero()))
{
os_semaphore_drop(work.semaphore);
}
//- rjf: increment completion counter
if(work.completion_counter != 0)
{
ins_atomic_u64_inc_eval(work.completion_counter);
}
}
////////////////////////////////
//~ rjf: Work Thread Entry Point
internal void
async_work_thread__entry_point(void *p)
{
U64 thread_idx = (U64)p;
ThreadNameF("[async] work thread #%I64u", thread_idx);
async_work_thread_idx = thread_idx;
for(;;)
{
ASYNC_Work work = async_pop_work();
ins_atomic_u64_inc_eval(&async_shared->work_threads_live_count);
async_execute_work(work);
ins_atomic_u64_dec_eval(&async_shared->work_threads_live_count);
}
}
+144
View File
@@ -0,0 +1,144 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef ASYNC_H
#define ASYNC_H
////////////////////////////////
//~ rjf: Work Function Type
#define ASYNC_WORK_SIG(name) void *name(U64 thread_idx, void *input)
#define ASYNC_WORK_DEF(name) internal ASYNC_WORK_SIG(name)
typedef ASYNC_WORK_SIG(ASYNC_WorkFunctionType);
////////////////////////////////
//~ rjf: Work Types
typedef enum ASYNC_Priority
{
ASYNC_Priority_Low,
ASYNC_Priority_High,
ASYNC_Priority_COUNT
}
ASYNC_Priority;
typedef struct ASYNC_WorkParams ASYNC_WorkParams;
struct ASYNC_WorkParams
{
void *input;
void **output;
OS_Handle semaphore;
U64 *completion_counter;
U64 endt_us;
ASYNC_Priority priority;
};
typedef struct ASYNC_Work ASYNC_Work;
struct ASYNC_Work
{
ASYNC_WorkFunctionType *work_function;
void *input;
void **output;
OS_Handle semaphore;
U64 *completion_counter;
};
////////////////////////////////
//~ rjf: Task-Based Work Types
typedef struct ASYNC_Task ASYNC_Task;
struct ASYNC_Task
{
OS_Handle semaphore;
void *output;
};
typedef struct ASYNC_TaskNode ASYNC_TaskNode;
struct ASYNC_TaskNode
{
ASYNC_TaskNode *next;
ASYNC_Task *v;
};
typedef struct ASYNC_TaskList ASYNC_TaskList;
struct ASYNC_TaskList
{
ASYNC_TaskNode *first;
ASYNC_TaskNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Shared State Bundle
typedef struct ASYNC_Ring ASYNC_Ring;
struct ASYNC_Ring
{
U64 ring_size;
U8 *ring_base;
U64 ring_write_pos;
U64 ring_read_pos;
OS_Handle ring_mutex;
OS_Handle ring_cv;
};
typedef struct ASYNC_Shared ASYNC_Shared;
struct ASYNC_Shared
{
Arena *arena;
// rjf: user -> work thread ring buffers
ASYNC_Ring rings[ASYNC_Priority_COUNT];
OS_Handle ring_mutex;
OS_Handle ring_cv;
// rjf: work threads
OS_Handle *work_threads;
U64 work_threads_count;
U64 work_threads_live_count;
};
////////////////////////////////
//~ rjf: Globals
thread_static B32 async_work_thread_depth = 0;
thread_static U64 async_work_thread_idx = 0;
global ASYNC_Shared *async_shared = 0;
////////////////////////////////
//~ rjf: Top-Level Layer Initialization
internal void async_init(void);
////////////////////////////////
//~ rjf: Top-Level Accessors
internal U64 async_thread_count(void);
////////////////////////////////
//~ rjf: Work Kickoffs
internal B32 async_push_work_(ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params);
#define async_push_work(function, ...) async_push_work_((function), &(ASYNC_WorkParams){.endt_us = max_U64, .priority = ASYNC_Priority_High, __VA_ARGS__})
////////////////////////////////
//~ rjf: Task-Based Work Helper
internal void async_task_list_push(Arena *arena, ASYNC_TaskList *list, ASYNC_Task *t);
internal ASYNC_Task *async_task_launch_(Arena *arena, ASYNC_WorkFunctionType *work_function, ASYNC_WorkParams *params);
#define async_task_launch(arena, work_function, ...) async_task_launch_((arena), (work_function), &(ASYNC_WorkParams){.endt_us = max_U64, __VA_ARGS__})
internal void *async_task_join(ASYNC_Task *task);
#define async_task_join_struct(task, T) (T *)async_task_join(task)
////////////////////////////////
//~ rjf: Work Execution
internal ASYNC_Work async_pop_work(void);
internal void async_execute_work(ASYNC_Work work);
////////////////////////////////
//~ rjf: Work Thread Entry Point
internal void async_work_thread__entry_point(void *p);
#endif // ASYNC_H
+248 -316
View File
@@ -1,316 +1,248 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
// Implementation //~ rjf: Arena Functions
internal Arena * //- rjf: arena creation/destruction
arena_alloc__sized(U64 init_res, U64 init_cmt)
{ internal Arena *
ProfBeginFunction(); arena_alloc_(ArenaParams *params)
Assert(ARENA_HEADER_SIZE < init_cmt && init_cmt <= init_res); {
// rjf: round up reserve/commit sizes
void *memory; U64 reserve_size = params->reserve_size;
U64 res; U64 commit_size = params->commit_size;
U64 cmt; if(params->flags & ArenaFlag_LargePages)
{
B32 large_pages = os_large_pages_enabled(); reserve_size = AlignPow2(reserve_size, os_get_system_info()->large_page_size);
if (large_pages) { commit_size = AlignPow2(commit_size, os_get_system_info()->large_page_size);
U64 page_size = os_large_page_size(); }
res = AlignPow2(init_res, page_size); else
{
#if OS_WINDOWS reserve_size = AlignPow2(reserve_size, os_get_system_info()->page_size);
cmt = res; commit_size = AlignPow2(commit_size, os_get_system_info()->page_size);
#else }
cmt AlignPow2(init_cmt, page_size);
#endif // rjf: reserve/commit initial block
void *base = params->optional_backing_buffer;
memory = os_reserve_large(res); if(base == 0)
if (!os_commit_large(memory, cmt)) { {
memory = 0; if(params->flags & ArenaFlag_LargePages)
os_release(memory, res); {
} base = os_reserve_large(reserve_size);
} else { os_commit_large(base, commit_size);
U64 page_size = os_page_size(); }
res = AlignPow2(init_res, page_size); else
cmt = AlignPow2(init_cmt, page_size); {
base = os_reserve(reserve_size);
memory = os_reserve(res); os_commit(base, commit_size);
if (!os_commit(memory, cmt)) { }
memory = 0; }
os_release(memory, res);
} // rjf: panic on arena creation failure
} #if OS_FEATURE_GRAPHICAL
Assert(memory); if(Unlikely(base == 0))
{
AsanPoisonMemoryRegion(memory, cmt); os_graphical_message(1, str8_lit("Fatal Allocation Failure"), str8_lit("Unexpected memory allocation failure."));
AsanUnpoisonMemoryRegion(memory, ARENA_HEADER_SIZE); os_abort(1);
}
Arena *arena = (Arena*)memory; #endif
if (arena) {
arena->prev = 0; // rjf: extract arena header & fill
arena->current = arena; Arena *arena = (Arena *)base;
arena->base_pos = 0; arena->current = arena;
arena->pos = ARENA_HEADER_SIZE; arena->flags = params->flags;
arena->cmt = cmt; arena->cmt_size = params->commit_size;
arena->res = res; arena->res_size = params->reserve_size;
arena->align = 8; arena->base_pos = 0;
#if ENABLE_DEV arena->pos = ARENA_HEADER_SIZE;
arena->dev = 0; arena->cmt = commit_size;
#endif arena->res = reserve_size;
arena->grow = 1; #if ARENA_FREE_LIST
arena->large_pages = large_pages; arena->free_size = 0;
} arena->free_last = 0;
#endif
ProfEnd(); AsanPoisonMemoryRegion(base, commit_size);
return arena; AsanUnpoisonMemoryRegion(base, ARENA_HEADER_SIZE);
} return arena;
}
internal Arena *
arena_alloc(void) internal void
{ arena_release(Arena *arena)
ProfBeginFunction(); {
for(Arena *n = arena->current, *prev = 0; n != 0; n = prev)
U64 init_res, init_cmt; {
if (os_large_pages_enabled()) { prev = n->prev;
init_res = ARENA_RESERVE_SIZE_LARGE_PAGES; os_release(n, n->res);
init_cmt = ARENA_COMMIT_SIZE_LARGE_PAGES; }
} else { }
init_res = ARENA_RESERVE_SIZE;
init_cmt = ARENA_COMMIT_SIZE; //- rjf: arena push/pop core functions
}
internal void *
Arena *arena = arena_alloc__sized(init_res, init_cmt); arena_push(Arena *arena, U64 size, U64 align)
{
ProfEnd(); Arena *current = arena->current;
return arena; U64 pos_pre = AlignPow2(current->pos, align);
} U64 pos_pst = pos_pre + size;
internal void // rjf: chain, if needed
arena_release(Arena *arena) if(current->res < pos_pst && !(arena->flags & ArenaFlag_NoChain))
{ {
for (Arena *node = arena->current, *prev = 0; node != 0; node = prev) { Arena *new_block = 0;
prev = node->prev;
os_release(node, node->res); #if ARENA_FREE_LIST
} Arena *prev_block;
} for(new_block = arena->free_last, prev_block = 0; new_block != 0; prev_block = new_block, new_block = new_block->prev)
{
internal U64 if(new_block->res >= AlignPow2(size, align))
arena_huge_push_threshold(void) {
{ if(prev_block)
U64 reserve_size = os_large_pages_enabled() ? ARENA_RESERVE_SIZE_LARGE_PAGES : ARENA_RESERVE_SIZE; {
U64 threshold = (reserve_size - ARENA_HEADER_SIZE) / 2 + 1; prev_block->prev = new_block->prev;
return threshold; }
} else
{
internal void * arena->free_last = new_block->prev;
arena_push__impl(Arena *arena, U64 size) }
{ arena->free_size -= new_block->res_size;
Arena *current = arena->current; AsanUnpoisonMemoryRegion((U8*)new_block + ARENA_HEADER_SIZE, new_block->res_size - ARENA_HEADER_SIZE);
U64 pos_mem = AlignPow2(current->pos, arena->align); break;
U64 pos_new = pos_mem + size; }
}
if (current->res < pos_new && arena->grow) { #endif
Arena *new_block;
if(new_block == 0)
// normal growth path {
if (size < arena_huge_push_threshold()) { U64 res_size = current->res_size;
new_block = arena_alloc(); U64 cmt_size = current->cmt_size;
} if(size + ARENA_HEADER_SIZE > res_size)
// huge growth path {
else { res_size = AlignPow2(size + ARENA_HEADER_SIZE, align);
U64 new_block_size = size + ARENA_HEADER_SIZE; cmt_size = AlignPow2(size + ARENA_HEADER_SIZE, align);
new_block = arena_alloc__sized(new_block_size, new_block_size); }
} new_block = arena_alloc(.reserve_size = res_size,
.commit_size = cmt_size,
if (new_block) { .flags = current->flags);
new_block->base_pos = current->base_pos + current->res; }
SLLStackPush_N(arena->current, new_block, prev);
new_block->base_pos = current->base_pos + current->res;
current = new_block; SLLStackPush_N(arena->current, new_block, prev);
pos_mem = AlignPow2(current->pos, current->align);
pos_new = pos_mem + size; current = new_block;
} pos_pre = AlignPow2(current->pos, align);
} pos_pst = pos_pre + size;
}
if (current->cmt < pos_new) {
U64 cmt_new_aligned, cmt_new_clamped, cmt_new_size; // rjf: commit new pages, if needed
B32 is_cmt_ok; if(current->cmt < pos_pst)
{
if (current->large_pages) { U64 cmt_pst_aligned = pos_pst + current->cmt_size-1;
cmt_new_aligned = AlignPow2(pos_new, ARENA_COMMIT_SIZE_LARGE_PAGES); cmt_pst_aligned -= cmt_pst_aligned%current->cmt_size;
cmt_new_clamped = ClampTop(cmt_new_aligned, current->res); U64 cmt_pst_clamped = ClampTop(cmt_pst_aligned, current->res);
cmt_new_size = cmt_new_clamped - current->cmt; U64 cmt_size = cmt_pst_clamped - current->cmt;
is_cmt_ok = os_commit_large((U8*)current + current->cmt, cmt_new_size); U8 *cmt_ptr = (U8 *)current + current->cmt;
} else { if(current->flags & ArenaFlag_LargePages)
cmt_new_aligned = AlignPow2(pos_new, ARENA_COMMIT_SIZE); {
cmt_new_clamped = ClampTop(cmt_new_aligned, current->res); os_commit_large(cmt_ptr, cmt_size);
cmt_new_size = cmt_new_clamped - current->cmt; }
is_cmt_ok = os_commit((U8*)current + current->cmt, cmt_new_size); else
} {
Assert(is_cmt_ok); os_commit(cmt_ptr, cmt_size);
}
if (is_cmt_ok) { current->cmt = cmt_pst_clamped;
current->cmt = cmt_new_clamped; }
}
} // rjf: push onto current block
void *result = 0;
void *memory = 0; if(current->cmt >= pos_pst)
{
if (current->cmt >= pos_new) { result = (U8 *)current+pos_pre;
memory = (U8*)current + pos_mem; current->pos = pos_pst;
current->pos = pos_new; AsanUnpoisonMemoryRegion(result, size);
AsanUnpoisonMemoryRegion(memory, size); }
}
// rjf: panic on failure
#if OS_FEATURE_GRAPHICAL #if OS_FEATURE_GRAPHICAL
if(Unlikely(memory == 0)) if(Unlikely(result == 0))
{ {
os_graphical_message(1, str8_lit("Fatal Allocation Failure"), str8_lit("Unexpected memory allocation failure.")); os_graphical_message(1, str8_lit("Fatal Allocation Failure"), str8_lit("Unexpected memory allocation failure."));
os_exit_process(1); os_abort(1);
} }
#endif #endif
return memory; return result;
} }
internal U64 internal U64
arena_pos(Arena *arena) arena_pos(Arena *arena)
{ {
Arena *current = arena->current; Arena *current = arena->current;
U64 pos = current->base_pos + current->pos; U64 pos = current->base_pos + current->pos;
return pos; return pos;
} }
internal void internal void
arena_pop_to(Arena *arena, U64 big_pos_unclamped) arena_pop_to(Arena *arena, U64 pos)
{ {
U64 big_pos = ClampBot(ARENA_HEADER_SIZE, big_pos_unclamped); U64 big_pos = ClampBot(ARENA_HEADER_SIZE, pos);
Arena *current = arena->current;
// unroll the chain
Arena *current = arena->current; #if ARENA_FREE_LIST
for (Arena *prev = 0; current->base_pos >= big_pos; current = prev) { for(Arena *prev = 0; current->base_pos >= big_pos; current = prev)
prev = current->prev; {
os_release(current, current->res); prev = current->prev;
} current->pos = ARENA_HEADER_SIZE;
AssertAlways(current); arena->free_size += current->res_size;
arena->current = current; SLLStackPush_N(arena->free_last, current, prev);
AsanPoisonMemoryRegion((U8*)current + ARENA_HEADER_SIZE, current->res_size - ARENA_HEADER_SIZE);
// compute arena-relative position }
U64 new_pos = big_pos - current->base_pos; #else
AssertAlways(new_pos <= current->pos); for(Arena *prev = 0; current->base_pos >= big_pos; current = prev)
{
// poison popped memory block prev = current->prev;
AsanPoisonMemoryRegion((U8*)current + new_pos, (current->pos - new_pos)); os_release(current, current->res);
}
// update position #endif
current->pos = new_pos; arena->current = current;
} U64 new_pos = big_pos - current->base_pos;
AssertAlways(new_pos <= current->pos);
internal void AsanPoisonMemoryRegion((U8*)current + new_pos, (current->pos - new_pos));
arena_absorb(Arena *arena, Arena *sub) current->pos = new_pos;
{ }
#if ENABLE_DEV
arena_annotate_absorb__dev(arena, sub); //- rjf: arena push/pop helpers
#endif
internal void
// base adjustment arena_clear(Arena *arena)
Arena *current = arena->current; {
U64 base_adjust = current->base_pos + current->res; arena_pop_to(arena, 0);
for (Arena *node = sub->current; node != 0; node = node->prev) { }
node->base_pos += base_adjust;
} internal void
arena_pop(Arena *arena, U64 amt)
// attach sub to arena {
sub->prev = arena->current; U64 pos_old = arena_pos(arena);
arena->current = sub->current; U64 pos_new = pos_old;
sub->current = sub; if(amt < pos_old)
} {
pos_new = pos_old - amt;
//////////////////////////////// }
// Wrappers arena_pop_to(arena, pos_new);
}
internal void *
arena_push(Arena *arena, U64 size) //- rjf: temporary arena scopes
{
void *memory = arena_push__impl(arena, size); internal Temp
#if ENABLE_DEV temp_begin(Arena *arena)
arena_annotate_push__dev(arena, size, memory); {
#endif U64 pos = arena_pos(arena);
return memory; Temp temp = {arena, pos};
} return temp;
}
internal void *
arena_push_contiguous(Arena *arena, U64 size) internal void
{ temp_end(Temp temp)
B32 restore = arena->grow; {
arena->grow = 0; arena_pop_to(temp.arena, temp.pos);
void *memory = arena_push(arena, size); }
arena->grow = restore;
#if ENABLE_DEV
arena_annotate_push__dev(arena, size, memory);
#endif
return memory;
}
internal void
arena_push_align(Arena *arena, U64 align)
{
Assert(IsPow2(align));
U64 amt = AlignPadPow2(arena->pos, align);
void *ptr = arena_push(arena, amt);
MemoryZero(ptr, amt);
}
internal void
arena_put_back(Arena *arena, U64 amt)
{
U64 pos_old = arena_pos(arena);
U64 pos_new = pos_old;
if (amt < pos_old) {
pos_new = pos_old - amt;
}
arena_pop_to(arena, pos_new);
}
internal void
arena_clear(Arena *arena)
{
arena_pop_to(arena, 0);
}
internal Temp
temp_begin(Arena *arena)
{
U64 pos = arena_pos(arena);
Temp temp = {arena, pos};
return temp;
}
internal void
temp_end(Temp temp)
{
arena_pop_to(temp.arena, temp.pos);
}
////////////////////////////////
//~ NOTE(allen): "Mini-Arena" Helper
internal B32
ensure_commit(void **cmtptr, void *pos, U64 cmt_block_size){
B32 result = 0;
U8 *cmt = (U8*)*cmtptr;
if (cmt < (U8*)pos){
U64 cmt_size_raw = (U8*)pos - cmt;
U64 cmt_size = AlignPow2(cmt_size_raw, cmt_block_size);
if (os_commit(cmt, cmt_size)){
*cmtptr = cmt + cmt_size;
result = 1;
}
}
else{
result = 1;
}
return(result);
}
+91 -94
View File
@@ -1,94 +1,91 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_ARENA_H #ifndef BASE_ARENA_H
#define BASE_ARENA_H #define BASE_ARENA_H
//////////////////////////////// ////////////////////////////////
//~ rjf: Constants //~ rjf: Constants
#define ARENA_HEADER_SIZE 128 #define ARENA_HEADER_SIZE 128
#ifndef ARENA_RESERVE_SIZE ////////////////////////////////
# define ARENA_RESERVE_SIZE MB(64) //~ rjf: Types
#endif
#ifndef ARENA_COMMIT_SIZE typedef U64 ArenaFlags;
# define ARENA_COMMIT_SIZE KB(64) enum
#endif {
ArenaFlag_NoChain = (1<<0),
#ifndef ARENA_RESERVE_SIZE_LARGE_PAGES ArenaFlag_LargePages = (1<<1),
# define ARENA_RESERVE_SIZE_LARGE_PAGES MB(8) };
#endif
#ifndef ARENA_COMMIT_SIZE_LARGE_PAGES typedef struct ArenaParams ArenaParams;
# define ARENA_COMMIT_SIZE_LARGE_PAGES MB(2) struct ArenaParams
#endif {
ArenaFlags flags;
//////////////////////////////// U64 reserve_size;
//~ rjf: Arena Types U64 commit_size;
void *optional_backing_buffer;
typedef struct Arena Arena; };
struct Arena
{ typedef struct Arena Arena;
struct Arena *prev; struct Arena
struct Arena *current; {
U64 base_pos; Arena *prev; // previous arena in chain
U64 pos; Arena *current; // current arena in chain
U64 cmt; ArenaFlags flags;
U64 res; U64 cmt_size;
U64 align; U64 res_size;
struct ArenaDev *dev; U64 base_pos;
B8 grow; U64 pos;
B8 large_pages; U64 cmt;
}; U64 res;
#if ARENA_FREE_LIST
typedef struct Temp Temp; U64 free_size;
struct Temp Arena *free_last;
{ #endif
Arena *arena; };
U64 pos; StaticAssert(sizeof(Arena) <= ARENA_HEADER_SIZE, arena_header_size_check);
};
typedef struct Temp Temp;
//////////////////////////////// struct Temp
// Implementation {
Arena *arena;
internal Arena* arena_alloc__sized(U64 init_res, U64 init_cmt); U64 pos;
};
internal Arena* arena_alloc(void);
internal void arena_release(Arena *arena); ////////////////////////////////
//~ rjf: Global Defaults
internal void* arena_push__impl(Arena *arena, U64 size);
internal U64 arena_pos(Arena *arena); global U64 arena_default_reserve_size = MB(64);
internal void arena_pop_to(Arena *arena, U64 pos); global U64 arena_default_commit_size = KB(64);
global ArenaFlags arena_default_flags = 0;
internal void arena_absorb(Arena *arena, Arena *sub);
////////////////////////////////
//////////////////////////////// //~ rjf: Arena Functions
// Wrappers
//- rjf: arena creation/destruction
internal void* arena_push(Arena *arena, U64 size); internal Arena *arena_alloc_(ArenaParams *params);
internal void* arena_push_contiguous(Arena *arena, U64 size); #define arena_alloc(...) arena_alloc_(&(ArenaParams){.reserve_size = arena_default_reserve_size, .commit_size = arena_default_commit_size, .flags = arena_default_flags, __VA_ARGS__})
internal void arena_clear(Arena *arena); internal void arena_release(Arena *arena);
internal void arena_push_align(Arena *arena, U64 align);
internal void arena_put_back(Arena *arena, U64 amt); //- rjf: arena push/pop/pos core functions
internal void *arena_push(Arena *arena, U64 size, U64 align);
internal Temp temp_begin(Arena *arena); internal U64 arena_pos(Arena *arena);
internal void temp_end(Temp temp); internal void arena_pop_to(Arena *arena, U64 pos);
//////////////////////////////// //- rjf: arena push/pop helpers
//~ NOTE(allen): "Mini-Arena" Helper internal void arena_clear(Arena *arena);
internal void arena_pop(Arena *arena, U64 amt);
internal B32 ensure_commit(void **cmt, void *pos, U64 cmt_block_size);
//- rjf: temporary arena scopes
//////////////////////////////// internal Temp temp_begin(Arena *arena);
//~ NOTE(allen): Main API Macros internal void temp_end(Temp temp);
#if !ENABLE_DEV //- rjf: push helper macros
# define push_array_no_zero(a,T,c) (T*)arena_push((a), sizeof(T)*(c)) #define push_array_no_zero_aligned(a, T, c, align) (T *)arena_push((a), sizeof(T)*(c), (align))
#else #define push_array_aligned(a, T, c, align) (T *)MemoryZero(push_array_no_zero_aligned(a, T, c, align), sizeof(T)*(c))
# define push_array_no_zero(a,T,c) (tctx_write_this_srcloc(), (T*)arena_push((a), sizeof(T)*(c))) #define push_array_no_zero(a, T, c) push_array_no_zero_aligned(a, T, c, Max(8, AlignOf(T)))
#endif #define push_array(a, T, c) push_array_aligned(a, T, c, Max(8, AlignOf(T)))
#define push_array_no_zero__no_annotation(a,T,c) (T*)arena_push__impl((a), sizeof(T)*(c))
#endif // BASE_ARENA_H
#define push_array(a,T,c) (T*)MemoryZero(push_array_no_zero(a,T,c), sizeof(T)*(c))
#endif // BASE_ARENA_H
-197
View File
@@ -1,197 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
// NOTE(allen): Dev Arena
#if ENABLE_DEV
internal void
arena_annotate_push__dev(Arena *arena, U64 size, void *ptr){
ArenaDev *dev = arena->dev;
if (dev != 0 && ptr != 0){
//- read location
char *file_name = 0;
U64 line_number = 0;
tctx_read_srcloc(&file_name, &line_number);
tctx_write_srcloc(0, 0);
//- profile
ArenaProf *prof = dev->prof;
if (prof != 0){
// c string -> string
String8 file_name_str = str8_lit("(null)");
if (file_name != 0){
file_name_str = str8_cstring(file_name);
}
// record
arena_prof_inc_counters__dev(dev->arena, prof, file_name_str, line_number, size, 1);
}
}
}
internal void
arena_annotate_absorb__dev(Arena *arena, Arena *sub){
ArenaDev *dev = arena->dev;
ArenaDev *sub_dev = sub->dev;
if (dev != 0 && sub_dev != 0){
//- merge profiles
ArenaProf *prof = dev->prof;
ArenaProf *sub_prof = sub_dev->prof;
if (prof != 0 && sub_prof != 0){
for (ArenaProfNode *sub_node = sub_prof->first;
sub_node != 0;
sub_node = sub_node->next){
arena_prof_inc_counters__dev(dev->arena, prof, sub_node->file_name, sub_node->line,
sub_node->size, sub_node->count);
}
}
}
//- release the sub dev memory
if (sub_dev != 0){
arena_release(sub_dev->arena);
}
}
internal ArenaDev*
arena_equip__dev(Arena *arena){
ArenaDev *result = arena->dev;
if (result == 0){
Arena *dev_arena = arena_alloc();
ArenaDev *dev = (ArenaDev*)arena_push__impl(dev_arena, sizeof(ArenaDev));
MemoryZeroStruct(dev);
dev->arena = dev_arena;
arena->dev = dev;
result = dev;
}
return(result);
}
internal void
arena_equip_profile__dev(Arena *arena){
ArenaDev *dev = arena_equip__dev(arena);
if (dev->prof == 0){
dev->prof = (ArenaProf*)arena_push__impl(dev->arena, sizeof(ArenaProf));
MemoryZeroStruct(dev->prof);
}
}
internal void
arena_print_profile__dev(Arena *arena, Arena *out_arena, String8List *out){
Assert(arena != out_arena);
//- get dev & disable
ArenaDev *dev = arena->dev;
arena->dev = 0;
//- get prof
ArenaProf *prof = (dev != 0)?dev->prof:0;
//- not equipped with prof
if (prof == 0){
str8_list_push(out_arena, out, str8_lit("not equipped with a memory profile\n"));
}
//- print prof
if (prof != 0){
Temp scratch = temp_begin(dev->arena);
//- make flat array
U64 note_count = prof->count;
ArenaProfNode **notes = push_array_no_zero__no_annotation(scratch.arena, ArenaProfNode*, note_count);
{
ArenaProfNode **note_ptr = notes;
for (ArenaProfNode *node = prof->first;
node != 0;
node = node->next, note_ptr += 1){
*note_ptr = node;
}
}
//- file name size
U64 max_file_name_size = 0;
{
ArenaProfNode **note_ptr = notes;
for (U64 i = 0; i < note_count; i += 1, note_ptr += 1){
max_file_name_size = Max(max_file_name_size, (**note_ptr).file_name.size);
}
}
//- sort (> size, < [address])
for (U64 i = 0; i < note_count; i += 1){
ArenaProfNode **i_note = notes + i;
ArenaProfNode **min_note = i_note;
for (U64 j = i + 1; j < note_count; j += 1){
ArenaProfNode **j_note = notes + j;
if ((**j_note).size > (**min_note).size ||
((**j_note).size == (**min_note).size && *j_note < *min_note)){
min_note = j_note;
}
}
if (min_note != i_note){
ArenaProfNode *t = *i_note;
*i_note = *min_note;
*min_note = t;
}
}
//- total size
U64 total_size = 0;
{
ArenaProfNode **note_ptr = notes;
for (U64 i = 0; i < note_count; i += 1, note_ptr += 1){
ArenaProfNode *note = *note_ptr;
total_size += note->size;
}
}
//- print
{
str8_list_pushf(out_arena, out, "memory total: %llu\n", total_size);
ArenaProfNode **note_ptr = notes;
for (U64 i = 0; i < note_count; i += 1, note_ptr += 1){
ArenaProfNode *note = *note_ptr;
String8 location = push_str8f(scratch.arena, "%S:%5llu:",
note->file_name, note->line);
F32 percent = 100.f*((F32)note->size)/total_size;
str8_list_pushf(out_arena, out, "%*.*s %12llu %5.2f%% [%5llu]\n",
max_file_name_size + 7, str8_varg(location),
note->size, percent, note->count);
}
}
temp_end(scratch);
}
//- restore dev
arena->dev = dev;
}
internal void
arena_prof_inc_counters__dev(Arena *dev_arena, ArenaProf *prof, String8 file_name, U64 line,
U64 size, U64 count){
// find existing profile node
ArenaProfNode *prof_node = 0;
for (ArenaProfNode *node = prof->first;
node != 0;
node = node->next){
if (node->line == line && str8_match(file_name, node->file_name, 0)){
prof_node = node;
break;
}
}
// make new histogram node if necessary
if (prof_node == 0){
prof_node = (ArenaProfNode*)arena_push(dev_arena, sizeof(*prof_node));
SLLQueuePush(prof->first, prof->last, prof_node);
prof->count += 1;
prof_node->file_name = file_name;
prof_node->line = line;
}
// record this allocation
prof_node->size += size;
prof_node->count += count;
}
#endif
-47
View File
@@ -1,47 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_ARENA_DEV_H
#define BASE_ARENA_DEV_H
////////////////////////////////
//~ NOTE(allen): Dev Arena Types
typedef struct ArenaDev ArenaDev;
struct ArenaDev
{
Arena *arena;
struct ArenaProf *prof;
};
typedef struct ArenaProf ArenaProf;
struct ArenaProf
{
struct ArenaProfNode *first;
struct ArenaProfNode *last;
U64 count;
};
typedef struct ArenaProfNode ArenaProfNode;
struct ArenaProfNode
{
ArenaProfNode *next;
String8 file_name;
U64 line;
U64 size;
U64 count;
};
////////////////////////////////
//~ NOTE(allen): Dev Arena Functions
#if ENABLE_DEV
internal void arena_annotate_push__dev(Arena *arena, U64 size, void *ptr);
internal void arena_annotate_absorb__dev(Arena *arena, Arena *sub);
internal ArenaDev* arena_equip__dev(Arena *arena);
internal void arena_equip_profile__dev(Arena *arena);
internal void arena_print_profile__dev(Arena *arena, Arena *out_arena, String8List *out);
internal void arena_prof_inc_counters__dev(Arena *dev_arena, ArenaProf *prof, String8 file_name, U64 line, U64 size, U64 count);
#endif
#endif // BASE_ARENA_DEV_H
-103
View File
@@ -1,103 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#if COMPILER_CL || (COMPILER_CLANG && OS_WINDOWS)
internal U64
count_bits_set16(U16 val)
{
return __popcnt16(val);
}
internal U64
count_bits_set32(U32 val)
{
return __popcnt(val);
}
internal U64
count_bits_set64(U64 val)
{
return __popcnt64(val);
}
internal U64
ctz32(U32 mask)
{
unsigned long idx;
_BitScanForward(&idx, mask);
return idx;
}
internal U64
ctz64(U64 mask)
{
unsigned long idx;
_BitScanForward64(&idx, mask);
return idx;
}
internal U64
clz32(U32 mask)
{
unsigned long idx;
_BitScanReverse(&idx, mask);
return 31 - idx;
}
internal U64
clz64(U64 mask)
{
unsigned long idx;
_BitScanReverse64(&idx, mask);
return 63 - idx;
}
#elif COMPILER_CLANG || COMPILER_GCC
internal U64
count_bits_set16(U16 val)
{
NotImplemented;
return 0;
}
internal U64
count_bits_set32(U32 val)
{
NotImplemented;
return 0;
}
internal U64
count_bits_set64(U64 val)
{
NotImplemented;
return 0;
}
internal U64
ctz32(U32 val)
{
NotImplemented;
return 0;
}
internal U64
clz32(U32 val)
{
NotImplemented;
return 0;
}
internal U64
clz64(U64 val)
{
NotImplemented;
return 0;
}
#else
# error "bits not defined for this target"
#endif
-18
View File
@@ -1,18 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_BITS_H
#define BASE_BITS_H
#define ExtractBit(word, idx) (((word) >> (idx)) & 1)
internal U64 count_bits_set16(U16 val);
internal U64 count_bits_set32(U32 val);
internal U64 count_bits_set64(U64 val);
internal U64 ctz32(U32 val);
internal U64 ctz64(U64 val);
internal U64 clz32(U32 val);
internal U64 clz64(U64 val);
#endif // BASE_BITS_H
+250 -229
View File
@@ -1,229 +1,250 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
//~ NOTE(rjf): Command Line Option Parsing //~ NOTE(rjf): Command Line Option Parsing
internal U64 internal U64
cmd_line_hash_from_string(String8 string) cmd_line_hash_from_string(String8 string)
{ {
U64 result = 5381; U64 result = 5381;
for(U64 i = 0; i < string.size; i += 1) for(U64 i = 0; i < string.size; i += 1)
{ {
result = ((result << 5) + result) + string.str[i]; result = ((result << 5) + result) + string.str[i];
} }
return result; return result;
} }
internal CmdLineOpt ** internal CmdLineOpt **
cmd_line_slot_from_string(CmdLine *cmd_line, String8 string) cmd_line_slot_from_string(CmdLine *cmd_line, String8 string)
{ {
CmdLineOpt **slot = 0; CmdLineOpt **slot = 0;
if(cmd_line->option_table_size != 0) if(cmd_line->option_table_size != 0)
{ {
U64 hash = cmd_line_hash_from_string(string); U64 hash = cmd_line_hash_from_string(string);
U64 bucket = hash % cmd_line->option_table_size; U64 bucket = hash % cmd_line->option_table_size;
slot = &cmd_line->option_table[bucket]; slot = &cmd_line->option_table[bucket];
} }
return slot; return slot;
} }
internal CmdLineOpt * internal CmdLineOpt *
cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string) cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string)
{ {
CmdLineOpt *result = 0; CmdLineOpt *result = 0;
for(CmdLineOpt *var = *slot; var; var = var->hash_next) for(CmdLineOpt *var = *slot; var; var = var->hash_next)
{ {
if(str8_match(string, var->string, 0)) if(str8_match(string, var->string, 0))
{ {
result = var; result = var;
break; break;
} }
} }
return result; return result;
} }
internal void internal void
cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var) cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var)
{ {
SLLQueuePush(list->first, list->last, var); SLLQueuePush(list->first, list->last, var);
list->count += 1; list->count += 1;
} }
internal CmdLineOpt * internal CmdLineOpt *
cmd_line_insert_opt(Arena *arena, CmdLine *cmd_line, String8 string, String8List values) cmd_line_insert_opt(Arena *arena, CmdLine *cmd_line, String8 string, String8List values)
{ {
CmdLineOpt *var = 0; CmdLineOpt *var = 0;
CmdLineOpt **slot = cmd_line_slot_from_string(cmd_line, string); CmdLineOpt **slot = cmd_line_slot_from_string(cmd_line, string);
CmdLineOpt *existing_var = cmd_line_opt_from_slot(slot, string); CmdLineOpt *existing_var = cmd_line_opt_from_slot(slot, string);
if(existing_var != 0) if(existing_var != 0)
{ {
var = existing_var; var = existing_var;
} }
else else
{ {
var = push_array(arena, CmdLineOpt, 1); var = push_array(arena, CmdLineOpt, 1);
var->hash_next = *slot; var->hash_next = *slot;
var->hash = cmd_line_hash_from_string(string); var->hash = cmd_line_hash_from_string(string);
var->string = push_str8_copy(arena, string); var->string = push_str8_copy(arena, string);
var->value_strings = values; var->value_strings = values;
StringJoin join = {0}; StringJoin join = {0};
join.pre = str8_lit(""); join.pre = str8_lit("");
join.sep = str8_lit(","); join.sep = str8_lit(",");
join.post = str8_lit(""); join.post = str8_lit("");
var->value_string = str8_list_join(arena, &var->value_strings, &join); var->value_string = str8_list_join(arena, &var->value_strings, &join);
*slot = var; *slot = var;
cmd_line_push_opt(&cmd_line->options, var); cmd_line_push_opt(&cmd_line->options, var);
} }
return var; return var;
} }
internal CmdLine internal CmdLine
cmd_line_from_string_list(Arena *arena, String8List command_line) cmd_line_from_string_list(Arena *arena, String8List command_line)
{ {
CmdLine parsed = {0}; CmdLine parsed = {0};
parsed.exe_name = command_line.first->string;
// NOTE(rjf): Set up config option table.
{ // NOTE(rjf): Set up config option table.
parsed.option_table_size = 4096; {
parsed.option_table = push_array(arena, CmdLineOpt *, parsed.option_table_size); parsed.option_table_size = 4096;
} parsed.option_table = push_array(arena, CmdLineOpt *, parsed.option_table_size);
}
// NOTE(rjf): Parse command line.
B32 after_passthrough_option = 0; // NOTE(rjf): Parse command line.
for(String8Node *node = command_line.first->next, *next = 0; node != 0; node = next) B32 after_passthrough_option = 0;
{ B32 first_passthrough = 1;
next = node->next; for(String8Node *node = command_line.first->next, *next = 0; node != 0; node = next)
String8 option_name = node->string; {
next = node->next;
// NOTE(rjf): Look at -- or - at the start of an argument to determine if it's String8 option_name = node->string;
// a flag option. All arguments after a single "--" (with no trailing string
// on the command line will be considered as input files. // NOTE(rjf): Look at --, -, or / (only on Windows) at the start of an
B32 is_option = 1; // argument to determine if it's a flag option. All arguments after a
if(after_passthrough_option == 0) // single "--" (with no trailing string on the command line will be
{ // considered as input files.
if(str8_match(node->string, str8_lit("--"), 0)) B32 is_option = 1;
{ if(after_passthrough_option == 0)
after_passthrough_option = 1; {
is_option = 0; if(str8_match(node->string, str8_lit("--"), 0))
} {
else if(str8_match(str8_prefix(node->string, 2), str8_lit("--"), 0)) after_passthrough_option = 1;
{ is_option = 0;
option_name = str8_skip(option_name, 2); }
} else if(str8_match(str8_prefix(node->string, 2), str8_lit("--"), 0))
else if(str8_match(str8_prefix(node->string, 1), str8_lit("-"), 0)) {
{ option_name = str8_skip(option_name, 2);
option_name = str8_skip(option_name, 1); }
} else if(str8_match(str8_prefix(node->string, 1), str8_lit("-"), 0))
else {
{ option_name = str8_skip(option_name, 1);
is_option = 0; }
} else if(operating_system_from_context() == OperatingSystem_Windows &&
} str8_match(str8_prefix(node->string, 1), str8_lit("/"), 0))
else {
{ option_name = str8_skip(option_name, 1);
is_option = 0; }
} else
{
// NOTE(rjf): This string is an option. is_option = 0;
if(is_option) }
{ }
B32 has_arguments = 0; else
U64 arg_signifier_position1 = str8_find_needle(option_name, 0, str8_lit(":"), 0); {
U64 arg_signifier_position2 = str8_find_needle(option_name, 0, str8_lit("="), 0); is_option = 0;
U64 arg_signifier_position = Min(arg_signifier_position1, arg_signifier_position2); }
String8 arg_portion_this_string = str8_skip(option_name, arg_signifier_position+1);
if(arg_signifier_position < option_name.size) // NOTE(rjf): This string is an option.
{ if(is_option)
has_arguments = 1; {
} B32 has_arguments = 0;
option_name = str8_prefix(option_name, arg_signifier_position); U64 arg_signifier_position1 = str8_find_needle(option_name, 0, str8_lit(":"), 0);
U64 arg_signifier_position2 = str8_find_needle(option_name, 0, str8_lit("="), 0);
String8List arguments = {0}; U64 arg_signifier_position = Min(arg_signifier_position1, arg_signifier_position2);
String8 arg_portion_this_string = str8_skip(option_name, arg_signifier_position+1);
// NOTE(rjf): Parse arguments. if(arg_signifier_position < option_name.size)
if(has_arguments) {
{ has_arguments = 1;
for(String8Node *n = node; n; n = n->next) }
{ option_name = str8_prefix(option_name, arg_signifier_position);
next = n->next;
String8List arguments = {0};
String8 string = n->string;
if(n == node) // NOTE(rjf): Parse arguments.
{ if(has_arguments)
string = arg_portion_this_string; {
} for(String8Node *n = node; n; n = n->next)
{
U8 splits[] = { ',' }; next = n->next;
String8List args_in_this_string = str8_split(arena, string, splits, ArrayCount(splits), 0);
for(String8Node *sub_arg = args_in_this_string.first; sub_arg; sub_arg = sub_arg->next) String8 string = n->string;
{ if(n == node)
str8_list_push(arena, &arguments, sub_arg->string); {
} string = arg_portion_this_string;
if(!str8_match(str8_postfix(n->string, 1), str8_lit(","), 0) && }
(n != node || arg_portion_this_string.size != 0))
{ U8 splits[] = { ',' };
break; String8List args_in_this_string = str8_split(arena, string, splits, ArrayCount(splits), 0);
} for(String8Node *sub_arg = args_in_this_string.first; sub_arg; sub_arg = sub_arg->next)
} {
} str8_list_push(arena, &arguments, sub_arg->string);
}
// NOTE(rjf): Register config variable. if(!str8_match(str8_postfix(n->string, 1), str8_lit(","), 0) &&
cmd_line_insert_opt(arena, &parsed, option_name, arguments); (n != node || arg_portion_this_string.size != 0))
} {
break;
// NOTE(rjf): Default path, treat as a passthrough config option to be }
// handled by tool-specific code. }
else if(!str8_match(node->string, str8_lit("--"), 0)) }
{
str8_list_push(arena, &parsed.inputs, node->string); // NOTE(rjf): Register config variable.
after_passthrough_option = 1; cmd_line_insert_opt(arena, &parsed, option_name, arguments);
} }
}
// NOTE(rjf): Default path, treat as a passthrough config option to be
return parsed; // handled by tool-specific code.
} else if(!str8_match(node->string, str8_lit("--"), 0) || !first_passthrough)
{
internal CmdLineOpt * str8_list_push(arena, &parsed.inputs, node->string);
cmd_line_opt_from_string(CmdLine *cmd_line, String8 name) after_passthrough_option = 1;
{ first_passthrough = 0;
return cmd_line_opt_from_slot(cmd_line_slot_from_string(cmd_line, name), name); }
} }
internal String8List // rjf: fill argc/argv
cmd_line_strings(CmdLine *cmd_line, String8 name) parsed.argc = command_line.node_count;
{ parsed.argv = push_array(arena, char *, parsed.argc);
String8List result = {0}; {
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); U64 idx = 0;
if(var != 0) for(String8Node *n = command_line.first; n != 0; n = n->next)
{ {
result = var->value_strings; parsed.argv[idx] = (char *)push_str8_copy(arena, n->string).str;
} idx += 1;
return result; }
} }
internal String8 return parsed;
cmd_line_string(CmdLine *cmd_line, String8 name) }
{
String8 result = {0}; internal CmdLineOpt *
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); cmd_line_opt_from_string(CmdLine *cmd_line, String8 name)
if(var != 0) {
{ return cmd_line_opt_from_slot(cmd_line_slot_from_string(cmd_line, name), name);
result = var->value_string; }
}
return result; internal String8List
} cmd_line_strings(CmdLine *cmd_line, String8 name)
{
internal B32 String8List result = {0};
cmd_line_has_flag(CmdLine *cmd_line, String8 name) CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
{ if(var != 0)
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); {
return(var != 0); result = var->value_strings;
} }
return result;
internal B32 }
cmd_line_has_argument(CmdLine *cmd_line, String8 name)
{ internal String8
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); cmd_line_string(CmdLine *cmd_line, String8 name)
return(var != 0 && var->value_strings.node_count > 0); {
} String8 result = {0};
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
if(var != 0)
{
result = var->value_string;
}
return result;
}
internal B32
cmd_line_has_flag(CmdLine *cmd_line, String8 name)
{
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
return(var != 0);
}
internal B32
cmd_line_has_argument(CmdLine *cmd_line, String8 name)
{
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
return(var != 0 && var->value_strings.node_count > 0);
}
+56 -53
View File
@@ -1,53 +1,56 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_COMMAND_LINE_H #ifndef BASE_COMMAND_LINE_H
#define BASE_COMMAND_LINE_H #define BASE_COMMAND_LINE_H
//////////////////////////////// ////////////////////////////////
//~ rjf: Parsed Command Line Types //~ rjf: Parsed Command Line Types
typedef struct CmdLineOpt CmdLineOpt; typedef struct CmdLineOpt CmdLineOpt;
struct CmdLineOpt struct CmdLineOpt
{ {
CmdLineOpt *next; CmdLineOpt *next;
CmdLineOpt *hash_next; CmdLineOpt *hash_next;
U64 hash; U64 hash;
String8 string; String8 string;
String8List value_strings; String8List value_strings;
String8 value_string; String8 value_string;
}; };
typedef struct CmdLineOptList CmdLineOptList; typedef struct CmdLineOptList CmdLineOptList;
struct CmdLineOptList struct CmdLineOptList
{ {
U64 count; U64 count;
CmdLineOpt *first; CmdLineOpt *first;
CmdLineOpt *last; CmdLineOpt *last;
}; };
typedef struct CmdLine CmdLine; typedef struct CmdLine CmdLine;
struct CmdLine struct CmdLine
{ {
CmdLineOptList options; String8 exe_name;
String8List inputs; CmdLineOptList options;
U64 option_table_size; String8List inputs;
CmdLineOpt **option_table; U64 option_table_size;
}; CmdLineOpt **option_table;
U64 argc;
//////////////////////////////// char **argv;
//~ NOTE(rjf): Command Line Option Parsing };
internal U64 cmd_line_hash_from_string(String8 string); ////////////////////////////////
internal CmdLineOpt** cmd_line_slot_from_string(CmdLine *cmd_line, String8 string); //~ NOTE(rjf): Command Line Option Parsing
internal CmdLineOpt* cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string);
internal void cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var); internal U64 cmd_line_hash_from_string(String8 string);
internal CmdLineOpt* cmd_line_insert_opt(Arena *arena, CmdLine *cmd_line, String8 string, String8List values); internal CmdLineOpt** cmd_line_slot_from_string(CmdLine *cmd_line, String8 string);
internal CmdLine cmd_line_from_string_list(Arena *arena, String8List arguments); internal CmdLineOpt* cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string);
internal CmdLineOpt* cmd_line_opt_from_string(CmdLine *cmd_line, String8 name); internal void cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var);
internal String8List cmd_line_strings(CmdLine *cmd_line, String8 name); internal CmdLineOpt* cmd_line_insert_opt(Arena *arena, CmdLine *cmd_line, String8 string, String8List values);
internal String8 cmd_line_string(CmdLine *cmd_line, String8 name); internal CmdLine cmd_line_from_string_list(Arena *arena, String8List arguments);
internal B32 cmd_line_has_flag(CmdLine *cmd_line, String8 name); internal CmdLineOpt* cmd_line_opt_from_string(CmdLine *cmd_line, String8 name);
internal B32 cmd_line_has_argument(CmdLine *cmd_line, String8 name); internal String8List cmd_line_strings(CmdLine *cmd_line, String8 name);
internal String8 cmd_line_string(CmdLine *cmd_line, String8 name);
#endif // BASE_COMMAND_LINE_H internal B32 cmd_line_has_flag(CmdLine *cmd_line, String8 name);
internal B32 cmd_line_has_argument(CmdLine *cmd_line, String8 name);
#endif // BASE_COMMAND_LINE_H
+247 -144
View File
@@ -1,144 +1,247 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_CONTEXT_CRACKING_H #ifndef BASE_CONTEXT_CRACKING_H
#define BASE_CONTEXT_CRACKING_H #define BASE_CONTEXT_CRACKING_H
#if defined(__clang__) ////////////////////////////////
//~ rjf: Clang OS/Arch Cracking
# define COMPILER_CLANG 1
#if defined(__clang__)
# if defined(_WIN32)
# define OS_WINDOWS 1 # define COMPILER_CLANG 1
# elif defined(__gnu_linux__) || defined(__linux__)
# define OS_LINUX 1 # if defined(_WIN32)
# elif defined(__APPLE__) && defined(__MACH__) # define OS_WINDOWS 1
# define OS_MAC 1 # elif defined(__gnu_linux__) || defined(__linux__)
# else # define OS_LINUX 1
# error This compiler/platform combo is not supported yet # elif defined(__APPLE__) && defined(__MACH__)
# endif # define OS_MAC 1
# else
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) # error This compiler/OS combo is not supported.
# define ARCH_X64 1 # endif
# elif defined(i386) || defined(__i386) || defined(__i386__)
# define ARCH_X86 1 # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
# elif defined(__aarch64__) # define ARCH_X64 1
# define ARCH_ARM64 1 # elif defined(i386) || defined(__i386) || defined(__i386__)
# elif defined(__arm__) # define ARCH_X86 1
# define ARCH_ARM32 1 # elif defined(__aarch64__)
# else # define ARCH_ARM64 1
# error architecture not supported yet # elif defined(__arm__)
# endif # define ARCH_ARM32 1
# else
#elif defined(_MSC_VER) # error Architecture not supported.
# endif
# define COMPILER_CL 1
////////////////////////////////
# if defined(_WIN32) //~ rjf: MSVC OS/Arch Cracking
# define OS_WINDOWS 1
# else #elif defined(_MSC_VER)
# error This compiler/platform combo is not supported yet
# endif # define COMPILER_MSVC 1
# if defined(_M_AMD64) # if _MSC_VER >= 1920
# define ARCH_X64 1 # define COMPILER_MSVC_YEAR 2019
# elif defined(_M_IX86) # elif _MSC_VER >= 1910
# define ARCH_X86 1 # define COMPILER_MSVC_YEAR 2017
# elif defined(_M_ARM64) # elif _MSC_VER >= 1900
# define ARCH_ARM64 1 # define COMPILER_MSVC_YEAR 2015
# elif defined(_M_ARM) # elif _MSC_VER >= 1800
# define ARCH_ARM32 1 # define COMPILER_MSVC_YEAR 2013
# else # elif _MSC_VER >= 1700
# error architecture not supported yet # define COMPILER_MSVC_YEAR 2012
# endif # elif _MSC_VER >= 1600
# define COMPILER_MSVC_YEAR 2010
#elif defined(__GNUC__) || defined(__GNUG__) # elif _MSC_VER >= 1500
# define COMPILER_MSVC_YEAR 2008
# define COMPILER_GCC 1 # elif _MSC_VER >= 1400
# define COMPILER_MSVC_YEAR 2005
# if defined(__gnu_linux__) || defined(__linux__) # else
# define OS_LINUX 1 # define COMPILER_MSVC_YEAR 0
# else # endif
# error This compiler/platform combo is not supported yet
# endif # if defined(_WIN32)
# define OS_WINDOWS 1
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) # else
# define ARCH_X64 1 # error This compiler/OS combo is not supported.
# elif defined(i386) || defined(__i386) || defined(__i386__) # endif
# define ARCH_X86 1
# elif defined(__aarch64__) # if defined(_M_AMD64)
# define ARCH_ARM64 1 # define ARCH_X64 1
# elif defined(__arm__) # elif defined(_M_IX86)
# define ARCH_ARM32 1 # define ARCH_X86 1
# else # elif defined(_M_ARM64)
# error architecture not supported yet # define ARCH_ARM64 1
# endif # elif defined(_M_ARM)
# define ARCH_ARM32 1
#else # else
# error This compiler is not supported yet # error Architecture not supported.
#endif # endif
#if defined(ARCH_X64) ////////////////////////////////
# define ARCH_64BIT 1 //~ rjf: GCC OS/Arch Cracking
#elif defined(ARCH_X86)
# define ARCH_32BIT 1 #elif defined(__GNUC__) || defined(__GNUG__)
#endif
# define COMPILER_GCC 1
#if defined(__cplusplus)
# define LANG_CPP 1 # if defined(__gnu_linux__) || defined(__linux__)
#else # define OS_LINUX 1
# define LANG_C 1 # else
#endif # error This compiler/OS combo is not supported.
# endif
// zeroify
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
#if !defined(ARCH_32BIT) # define ARCH_X64 1
# define ARCH_32BIT 0 # elif defined(i386) || defined(__i386) || defined(__i386__)
#endif # define ARCH_X86 1
#if !defined(ARCH_64BIT) # elif defined(__aarch64__)
# define ARCH_64BIT 0 # define ARCH_ARM64 1
#endif # elif defined(__arm__)
#if !defined(ARCH_X64) # define ARCH_ARM32 1
# define ARCH_X64 0 # else
#endif # error Architecture not supported.
#if !defined(ARCH_X86) # endif
# define ARCH_X86 0
#endif #else
#if !defined(ARCH_ARM64) # error Compiler not supported.
# define ARCH_ARM64 0 #endif
#endif
#if !defined(ARCH_ARM32) ////////////////////////////////
# define ARCH_ARM32 0 //~ rjf: Arch Cracking
#endif
#if !defined(COMPILER_CL) #if defined(ARCH_X64)
# define COMPILER_CL 0 # define ARCH_64BIT 1
#endif #elif defined(ARCH_X86)
#if !defined(COMPILER_GCC) # define ARCH_32BIT 1
# define COMPILER_GCC 0 #endif
#endif
#if !defined(COMPILER_CLANG) #if ARCH_ARM32 || ARCH_ARM64 || ARCH_X64 || ARCH_X86
# define COMPILER_CLANG 0 # define ARCH_LITTLE_ENDIAN 1
#endif #else
#if !defined(OS_WINDOWS) # error Endianness of this architecture not understood by context cracker.
# define OS_WINDOWS 0 #endif
#endif
#if !defined(OS_LINUX) ////////////////////////////////
# define OS_LINUX 0 //~ rjf: Language Cracking
#endif
#if !defined(OS_MAC) #if defined(__cplusplus)
# define OS_MAC 0 # define LANG_CPP 1
#endif #else
#if !defined(LANG_CPP) # define LANG_C 1
# define LANG_CPP 0 #endif
#endif
#if !defined(LANG_C) ////////////////////////////////
# define LANG_C 0 //~ rjf: Build Option Cracking
#endif
#if !defined(BUILD_DEBUG)
#if ARCH_ARM32 || ARCH_ARM64 || ARCH_X64 || ARCH_X86 # define BUILD_DEBUG 1
# define ARCH_LITTLE_ENDIAN 1 #endif
#else
# error Endianness of this architecture not understood by context cracker #if !defined(BUILD_SUPPLEMENTARY_UNIT)
#endif # define BUILD_SUPPLEMENTARY_UNIT 0
#endif
#endif // BASE_CONTEXT_CRACKING_H
#if !defined(BUILD_ENTRY_DEFINING_UNIT)
# define BUILD_ENTRY_DEFINING_UNIT 1
#endif
#if !defined(BUILD_CONSOLE_INTERFACE)
# define BUILD_CONSOLE_INTERFACE 0
#endif
#if !defined(BUILD_VERSION_MAJOR)
# define BUILD_VERSION_MAJOR 0
#endif
#if !defined(BUILD_VERSION_MINOR)
# define BUILD_VERSION_MINOR 9
#endif
#if !defined(BUILD_VERSION_PATCH)
# define BUILD_VERSION_PATCH 14
#endif
#define BUILD_VERSION_STRING_LITERAL Stringify(BUILD_VERSION_MAJOR) "." Stringify(BUILD_VERSION_MINOR) "." Stringify(BUILD_VERSION_PATCH)
#if BUILD_DEBUG
# define BUILD_MODE_STRING_LITERAL_APPEND " [Debug]"
#else
# define BUILD_MODE_STRING_LITERAL_APPEND ""
#endif
#if defined(BUILD_GIT_HASH)
# define BUILD_GIT_HASH_STRING_LITERAL_APPEND " [" BUILD_GIT_HASH "]"
#else
# define BUILD_GIT_HASH_STRING_LITERAL_APPEND ""
#endif
#if !defined(BUILD_TITLE)
# define BUILD_TITLE "Untitled"
#endif
#if !defined(BUILD_RELEASE_PHASE_STRING_LITERAL)
# define BUILD_RELEASE_PHASE_STRING_LITERAL "ALPHA"
#endif
#if !defined(BUILD_ISSUES_LINK_STRING_LITERAL)
# define BUILD_ISSUES_LINK_STRING_LITERAL "https://github.com/EpicGamesExt/raddebugger/issues"
#endif
#define BUILD_TITLE_STRING_LITERAL BUILD_TITLE " (" BUILD_VERSION_STRING_LITERAL " " BUILD_RELEASE_PHASE_STRING_LITERAL ") - " __DATE__ "" BUILD_GIT_HASH_STRING_LITERAL_APPEND BUILD_MODE_STRING_LITERAL_APPEND
////////////////////////////////
//~ rjf: Zero All Undefined Options
#if !defined(ARCH_32BIT)
# define ARCH_32BIT 0
#endif
#if !defined(ARCH_64BIT)
# define ARCH_64BIT 0
#endif
#if !defined(ARCH_X64)
# define ARCH_X64 0
#endif
#if !defined(ARCH_X86)
# define ARCH_X86 0
#endif
#if !defined(ARCH_ARM64)
# define ARCH_ARM64 0
#endif
#if !defined(ARCH_ARM32)
# define ARCH_ARM32 0
#endif
#if !defined(COMPILER_MSVC)
# define COMPILER_MSVC 0
#endif
#if !defined(COMPILER_GCC)
# define COMPILER_GCC 0
#endif
#if !defined(COMPILER_CLANG)
# define COMPILER_CLANG 0
#endif
#if !defined(OS_WINDOWS)
# define OS_WINDOWS 0
#endif
#if !defined(OS_LINUX)
# define OS_LINUX 0
#endif
#if !defined(OS_MAC)
# define OS_MAC 0
#endif
#if !defined(LANG_CPP)
# define LANG_CPP 0
#endif
#if !defined(LANG_C)
# define LANG_C 0
#endif
////////////////////////////////
//~ rjf: Unsupported Errors
#if ARCH_X86
# error You tried to build in x86 (32 bit) mode, but currently, only building in x64 (64 bit) mode is supported.
#endif
#if !ARCH_X64
# error You tried to build with an unsupported architecture. Currently, only building in x64 mode is supported.
#endif
#endif // BASE_CONTEXT_CRACKING_H
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+130
View File
@@ -0,0 +1,130 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
global U64 global_update_tick_idx = 0;
internal void
main_thread_base_entry_point(int arguments_count, char **arguments)
{
Temp scratch = scratch_begin(0, 0);
ThreadNameF("[main thread]");
//- rjf: set up telemetry
#if PROFILE_TELEMETRY
local_persist char tm_data[MB(64)];
tmLoadLibrary(TM_RELEASE);
tmSetMaxThreadCount(256);
tmInitialize(sizeof(tm_data), tm_data);
#endif
//- rjf: parse command line
String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, arguments_count, arguments);
CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings);
//- rjf: begin captures
B32 capture = cmd_line_has_flag(&cmdline, str8_lit("capture"));
if(capture)
{
ProfBeginCapture(arguments[0]);
}
#if PROFILE_TELEMETRY
tmMessage(0, TMMF_ICON_NOTE, BUILD_TITLE);
#endif
//- rjf: initialize all included layers
#if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL)
async_init();
#endif
#if defined(RDI_FROM_PDB_H) && !defined(P2R_INIT_MANUAL)
p2r_init();
#endif
#if defined(HASH_STORE_H) && !defined(HS_INIT_MANUAL)
hs_init();
#endif
#if defined(FILE_STREAM_H) && !defined(FS_INIT_MANUAL)
fs_init();
#endif
#if defined(TEXT_CACHE_H) && !defined(TXT_INIT_MANUAL)
txt_init();
#endif
#if defined(MUTABLE_TEXT_H) && !defined(MTX_INIT_MANUAL)
mtx_init();
#endif
#if defined(DASM_CACHE_H) && !defined(DASM_INIT_MANUAL)
dasm_init();
#endif
#if defined(DBGI_H) && !defined(DI_INIT_MANUAL)
di_init();
#endif
#if defined(DEMON_CORE_H) && !defined(DMN_INIT_MANUAL)
dmn_init();
#endif
#if defined(CTRL_CORE_H) && !defined(CTRL_INIT_MANUAL)
ctrl_init();
#endif
#if defined(OS_GFX_H) && !defined(OS_GFX_INIT_MANUAL)
os_gfx_init();
#endif
#if defined(FONT_PROVIDER_H) && !defined(FP_INIT_MANUAL)
fp_init();
#endif
#if defined(RENDER_CORE_H) && !defined(R_INIT_MANUAL)
r_init(&cmdline);
#endif
#if defined(TEXTURE_CACHE_H) && !defined(TEX_INIT_MANUAL)
tex_init();
#endif
#if defined(GEO_CACHE_H) && !defined(GEO_INIT_MANUAL)
geo_init();
#endif
#if defined(FONT_CACHE_H) && !defined(FNT_INIT_MANUAL)
fnt_init();
#endif
#if defined(DBG_ENGINE_CORE_H) && !defined(D_INIT_MANUAL)
d_init();
#endif
#if defined(RADDBG_CORE_H) && !defined(RD_INIT_MANUAL)
rd_init(&cmdline);
#endif
//- rjf: call into entry point
entry_point(&cmdline);
//- rjf: end captures
if(capture)
{
ProfEndCapture();
}
scratch_end(scratch);
}
internal void
supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params)
{
TCTX tctx;
tctx_init_and_equip(&tctx);
entry_point(params);
tctx_release();
}
internal U64
update_tick_idx(void)
{
U64 result = ins_atomic_u64_eval(&global_update_tick_idx);
return result;
}
internal B32
update(void)
{
ProfTick(0);
ins_atomic_u64_inc_eval(&global_update_tick_idx);
#if OS_FEATURE_GRAPHICAL
B32 result = frame();
#else
B32 result = 0;
#endif
return result;
}
+12
View File
@@ -0,0 +1,12 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_ENTRY_POINT_H
#define BASE_ENTRY_POINT_H
internal void main_thread_base_entry_point(int argc, char **argv);
internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params);
internal U64 update_tick_idx(void);
internal B32 update(void);
#endif // BASE_ENTRY_POINT_H
+20 -18
View File
@@ -1,18 +1,20 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
//~ rjf: Base Includes //~ rjf: Base Includes
#undef RADDBG_LAYER_COLOR #undef MARKUP_LAYER_COLOR
#define RADDBG_LAYER_COLOR 0.20f, 0.60f, 0.80f #define MARKUP_LAYER_COLOR 0.20f, 0.60f, 0.80f
#include "base_types.c" #include "base_core.c"
#include "base_markup.c" #include "base_profile.c"
#include "base_arena.c" #include "base_arena.c"
#include "base_math.c" #include "base_math.c"
#include "base_string.c" #include "base_strings.c"
#include "base_thread_context.c" #include "base_thread_context.c"
#include "base_command_line.c" #include "base_command_line.c"
#include "base_arena_dev.c" #include "base_markup.c"
#include "base_bits.c" #include "base_meta.c"
#include "base_log.c"
#include "base_entry_point.c"
+24 -23
View File
@@ -1,23 +1,24 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_INC_H #ifndef BASE_INC_H
#define BASE_INC_H #define BASE_INC_H
//////////////////////////////// ////////////////////////////////
//~ rjf: Base Includes //~ rjf: Base Includes
#include "base_context_cracking.h" #include "base_context_cracking.h"
#include "base_types.h"
#include "base_markup.h" #include "base_core.h"
#include "base_ins.h" #include "base_profile.h"
#include "base_linked_lists.h" #include "base_arena.h"
#include "base_arena.h" #include "base_math.h"
#include "base_math.h" #include "base_strings.h"
#include "base_string.h" #include "base_thread_context.h"
#include "base_thread_context.h" #include "base_command_line.h"
#include "base_command_line.h" #include "base_markup.h"
#include "base_arena_dev.h" #include "base_meta.h"
#include "base_bits.h" #include "base_log.h"
#include "base_entry_point.h"
#endif // BASE_INC_H
#endif // BASE_INC_H
-52
View File
@@ -1,52 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_INS_H
#define BASE_INS_H
////////////////////////////////
// NOTE(allen): Implementations of Intrinsics
#if OS_WINDOWS
# include <windows.h>
# include <tmmintrin.h>
# include <wmmintrin.h>
# include <intrin.h>
# if ARCH_X64
# define ins_atomic_u64_eval(x) InterlockedAdd((volatile LONG *)(x), 0)
# define ins_atomic_u64_inc_eval(x) InterlockedIncrement64((volatile __int64 *)(x))
# define ins_atomic_u64_dec_eval(x) InterlockedDecrement64((volatile __int64 *)(x))
# define ins_atomic_u64_eval_assign(x,c) InterlockedExchange64((volatile __int64 *)(x),(c))
# define ins_atomic_u64_add_eval(x,c) InterlockedAdd((volatile LONG *)(x), c)
# define ins_atomic_u32_eval_assign(x,c) InterlockedExchange((volatile LONG *)(x),(c))
# define ins_atomic_u32_eval_cond_assign(x,k,c) InterlockedCompareExchange((volatile LONG *)(x),(k),(c))
# define ins_atomic_ptr_eval_assign(x,c) (void*)ins_atomic_u64_eval_assign((volatile __int64 *)(x), (__int64)(c))
# endif
#elif OS_LINUX
# if ARCH_X64
# define ins_atomic_u64_inc_eval(x) __sync_fetch_and_add((volatile U64 *)(x), 1)
# endif
#else
// TODO(allen):
#endif
////////////////////////////////
// NOTE(allen): Intrinsic Checks
#if ARCH_X64
# if !defined(ins_atomic_u64_inc_eval)
# error missing: ins_atomic_u64_inc_eval
# endif
#else
# error the intrinsic set for this arch is not developed
#endif
#endif //BASE_INS_H
-73
View File
@@ -1,73 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_LINKED_LIST_H
#define BASE_LINKED_LIST_H
////////////////////////////////
//~ rjf: Helpers
#define CheckNil(nil,p) ((p) == 0 || (p) == nil)
#define SetNil(nil,p) ((p) = nil)
////////////////////////////////
//~ rjf: Base Macros
//- rjf: Base Doubly-Linked-List Macros
#define DLLInsert_NPZ(nil,f,l,p,n,next,prev) (CheckNil(nil,f) ? \
((f) = (l) = (n), SetNil(nil,(n)->next), SetNil(nil,(n)->prev)) :\
CheckNil(nil,p) ? \
((n)->next = (f), (f)->prev = (n), (f) = (n), SetNil(nil,(n)->prev)) :\
((p)==(l)) ? \
((l)->next = (n), (n)->prev = (l), (l) = (n), SetNil(nil, (n)->next)) :\
(((!CheckNil(nil,p) && CheckNil(nil,(p)->next)) ? (0) : ((p)->next->prev = (n))), ((n)->next = (p)->next), ((p)->next = (n)), ((n)->prev = (p))))
#define DLLPushBack_NPZ(nil,f,l,n,next,prev) DLLInsert_NPZ(nil,f,l,l,n,next,prev)
#define DLLPushFront_NPZ(nil,f,l,n,next,prev) DLLInsert_NPZ(nil,l,f,f,n,prev,next)
#define DLLRemove_NPZ(nil,f,l,n,next,prev) (((n) == (f) ? (f) = (n)->next : (0)),\
((n) == (l) ? (l) = (l)->prev : (0)),\
(CheckNil(nil,(n)->prev) ? (0) :\
((n)->prev->next = (n)->next)),\
(CheckNil(nil,(n)->next) ? (0) :\
((n)->next->prev = (n)->prev)))
//- rjf: Base Singly-Linked-List Queue Macros
#define SLLQueuePush_NZ(nil,f,l,n,next) (CheckNil(nil,f)?\
((f)=(l)=(n),SetNil(nil,(n)->next)):\
((l)->next=(n),(l)=(n),SetNil(nil,(n)->next)))
#define SLLQueuePushFront_NZ(nil,f,l,n,next) (CheckNil(nil,f)?\
((f)=(l)=(n),SetNil(nil,(n)->next)):\
((n)->next=(f),(f)=(n)))
#define SLLQueuePop_NZ(nil,f,l,next) ((f)==(l)?\
(SetNil(nil,f),SetNil(nil,l)):\
((f)=(f)->next))
//- rjf: Base Singly-Linked-List Stack Macros
#define SLLStackPush_N(f,n,next) ((n)->next=(f), (f)=(n))
#define SLLStackPop_N(f,next) ((f)=(f)->next)
////////////////////////////////
//~ rjf: Convenience Wrappers
//- rjf: Doubly-Linked-List Wrappers
#define DLLInsert_NP(f,l,p,n,next,prev) DLLInsert_NPZ(0,f,l,p,n,next,prev)
#define DLLPushBack_NP(f,l,n,next,prev) DLLPushBack_NPZ(0,f,l,n,next,prev)
#define DLLPushFront_NP(f,l,n,next,prev) DLLPushFront_NPZ(0,f,l,n,next,prev)
#define DLLRemove_NP(f,l,n,next,prev) DLLRemove_NPZ(0,f,l,n,next,prev)
#define DLLInsert(f,l,p,n) DLLInsert_NPZ(0,f,l,p,n,next,prev)
#define DLLPushBack(f,l,n) DLLPushBack_NPZ(0,f,l,n,next,prev)
#define DLLPushFront(f,l,n) DLLPushFront_NPZ(0,f,l,n,next,prev)
#define DLLRemove(f,l,n) DLLRemove_NPZ(0,f,l,n,next,prev)
//- rjf: Singly-Linked-List Queue Wrappers
#define SLLQueuePush_N(f,l,n,next) SLLQueuePush_NZ(0,f,l,n,next)
#define SLLQueuePushFront_N(f,l,n,next) SLLQueuePushFront_NZ(0,f,l,n,next)
#define SLLQueuePop_N(f,l,next) SLLQueuePop_NZ(0,f,l,next)
#define SLLQueuePush(f,l,n) SLLQueuePush_NZ(0,f,l,n,next)
#define SLLQueuePushFront(f,l,n) SLLQueuePushFront_NZ(0,f,l,n,next)
#define SLLQueuePop(f,l) SLLQueuePop_NZ(0,f,l,next)
//- rjf: Singly-Linked-List Stack Wrappers
#define SLLStackPush(f,n) SLLStackPush_N(f,n,next)
#define SLLStackPop(f) SLLStackPop_N(f,next)
#endif //BASE_LINKED_LIST_H
+103
View File
@@ -0,0 +1,103 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Globals/Thread-Locals
C_LINKAGE thread_static Log *log_active;
#if !BUILD_SUPPLEMENTARY_UNIT
C_LINKAGE thread_static Log *log_active = 0;
#endif
////////////////////////////////
//~ rjf: Log Creation/Selection
internal Log *
log_alloc(void)
{
Arena *arena = arena_alloc();
Log *log = push_array(arena, Log, 1);
log->arena = arena;
return log;
}
internal void
log_release(Log *log)
{
arena_release(log->arena);
}
internal void
log_select(Log *log)
{
log_active = log;
}
////////////////////////////////
//~ rjf: Log Building/Clearing
internal void
log_msg(LogMsgKind kind, String8 string)
{
if(log_active != 0 && log_active->top_scope != 0)
{
String8 string_copy = push_str8_copy(log_active->arena, string);
str8_list_push(log_active->arena, &log_active->top_scope->strings[kind], string_copy);
}
}
internal void
log_msgf(LogMsgKind kind, char *fmt, ...)
{
if(log_active != 0)
{
Temp scratch = scratch_begin(0, 0);
va_list args;
va_start(args, fmt);
String8 string = push_str8fv(scratch.arena, fmt, args);
log_msg(kind, string);
va_end(args);
scratch_end(scratch);
}
}
////////////////////////////////
//~ rjf: Log Scopes
internal void
log_scope_begin(void)
{
if(log_active != 0)
{
U64 pos = arena_pos(log_active->arena);
LogScope *scope = push_array(log_active->arena, LogScope, 1);
scope->pos = pos;
SLLStackPush(log_active->top_scope, scope);
}
}
internal LogScopeResult
log_scope_end(Arena *arena)
{
LogScopeResult result = {0};
if(log_active != 0)
{
LogScope *scope = log_active->top_scope;
if(scope != 0)
{
SLLStackPop(log_active->top_scope);
if(arena != 0)
{
for EachEnumVal(LogMsgKind, kind)
{
Temp scratch = scratch_begin(&arena, 1);
String8 result_unindented = str8_list_join(scratch.arena, &scope->strings[kind], 0);
result.strings[kind] = indented_from_string(arena, result_unindented);
scratch_end(scratch);
}
}
arena_pop_to(log_active->arena, scope->pos);
}
}
return result;
}
+65
View File
@@ -0,0 +1,65 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_LOG_H
#define BASE_LOG_H
////////////////////////////////
//~ rjf: Log Types
typedef enum LogMsgKind
{
LogMsgKind_Info,
LogMsgKind_UserError,
LogMsgKind_COUNT
}
LogMsgKind;
typedef struct LogScope LogScope;
struct LogScope
{
LogScope *next;
U64 pos;
String8List strings[LogMsgKind_COUNT];
};
typedef struct LogScopeResult LogScopeResult;
struct LogScopeResult
{
String8 strings[LogMsgKind_COUNT];
};
typedef struct Log Log;
struct Log
{
Arena *arena;
LogScope *top_scope;
};
////////////////////////////////
//~ rjf: Log Creation/Selection
internal Log *log_alloc(void);
internal void log_release(Log *log);
internal void log_select(Log *log);
////////////////////////////////
//~ rjf: Log Building
internal void log_msg(LogMsgKind kind, String8 string);
internal void log_msgf(LogMsgKind kind, char *fmt, ...);
#define log_info(s) log_msg(LogMsgKind_Info, (s))
#define log_infof(fmt, ...) log_msgf(LogMsgKind_Info, (fmt), __VA_ARGS__)
#define log_user_error(s) log_msg(LogMsgKind_UserError, (s))
#define log_user_errorf(fmt, ...) log_msgf(LogMsgKind_UserError, (fmt), __VA_ARGS__)
#define LogInfoNamedBlock(s) DeferLoop(log_infof("%S:\n{\n", (s)), log_infof("}\n"))
#define LogInfoNamedBlockF(fmt, ...) DeferLoop((log_infof(fmt, __VA_ARGS__), log_infof(":\n{\n")), log_infof("}\n"))
////////////////////////////////
//~ rjf: Log Scopes
internal void log_scope_begin(void);
internal LogScopeResult log_scope_end(Arena *arena);
#endif // BASE_LOG_H
+21 -2
View File
@@ -1,2 +1,21 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal void
set_thread_name(String8 string)
{
ProfThreadName("%.*s", str8_varg(string));
os_set_thread_name(string);
}
internal void
set_thread_namef(char *fmt, ...)
{
Temp scratch = scratch_begin(0, 0);
va_list args;
va_start(args, fmt);
String8 string = push_str8fv(scratch.arena, fmt, args);
set_thread_name(string);
va_end(args);
scratch_end(scratch);
}
+12 -79
View File
@@ -1,79 +1,12 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_MARKUP_H #ifndef BASE_MARKUP_H
#define BASE_MARKUP_H #define BASE_MARKUP_H
//////////////////////////////// internal void set_thread_name(String8 string);
//~ rjf: Zero Settings internal void set_thread_namef(char *fmt, ...);
#define ThreadNameF(...) (set_thread_namef(__VA_ARGS__))
#if !defined(PROFILE_TELEMETRY) #define ThreadName(str) (set_thread_name(str))
# define PROFILE_TELEMETRY 0
#endif #endif // BASE_MARKUP_H
#if !defined(MARKUP_LAYER_COLOR)
# define MARKUP_LAYER_COLOR 1.00f, 0.00f, 1.00f
#endif
////////////////////////////////
//~ rjf: Third Party Includes
#if PROFILE_TELEMETRY
# include "rad_tm.h"
# if OS_WINDOWS
# pragma comment(lib, "rad_tm_win64.lib")
# endif
#endif
////////////////////////////////
//~ rjf: Telemetry Profile Defines
#if PROFILE_TELEMETRY
# define ProfBegin(...) tmEnter(0, 0, __VA_ARGS__)
# define ProfBeginDynamic(...) (TM_API_PTR ? TM_API_PTR->_tmEnterZoneV_Core(0, 0, __FILE__, &g_telemetry_filename_id, __LINE__, __VA_ARGS__) : (void)0)
# define ProfEnd(...) (TM_API_PTR ? TM_API_PTR->_tmLeaveZone(0) : (void)0)
# define ProfTick(...) tmTick(0)
# define ProfIsCapturing(...) tmRunning()
# define ProfBeginCapture(...) tmOpen(0, __VA_ARGS__, __DATE__, "localhost", TMCT_TCP, TELEMETRY_DEFAULT_PORT, TMOF_INIT_NETWORKING|TMOF_CAPTURE_CONTEXT_SWITCHES, 100)
# define ProfEndCapture(...) tmClose(0)
# define ProfThreadName(...) (TM_API_PTR ? TM_API_PTR->_tmThreadName(0, 0, __VA_ARGS__) : (void)0)
# define ProfMsg(...) (TM_API_PTR ? TM_API_PTR->_tmMessageV_Core(0, TMMF_ICON_NOTE, __FILE__, &g_telemetry_filename_id, __LINE__, __VA_ARGS__) : (void)0)
# define ProfBeginLockWait(...) tmStartWaitForLock(0, 0, __VA_ARGS__)
# define ProfEndLockWait(...) tmEndWaitForLock(0)
# define ProfLockTake(...) tmAcquiredLock(0, 0, __VA_ARGS__)
# define ProfLockDrop(...) tmReleasedLock(0, __VA_ARGS__)
# define ProfColor(color) tmZoneColorSticky(color)
#endif
////////////////////////////////
//~ rjf: Zeroify Undefined Defines
#if !defined(ProfBegin)
# define ProfBegin(...) (0)
# define ProfBeginDynamic(...) (0)
# define ProfEnd(...) (0)
# define ProfTick(...) (0)
# define ProfIsCapturing(...) (0)
# define ProfBeginCapture(...) (0)
# define ProfEndCapture(...) (0)
# define ProfThreadName(...) (0)
# define ProfMsg(...) (0)
# define ProfBeginLockWait(...) (0)
# define ProfEndLockWait(...) (0)
# define ProfLockTake(...) (0)
# define ProfLockDrop(...) (0)
# define ProfColor(...) (0)
#endif
////////////////////////////////
//~ rjf: Helper Wrappers
#define ProfBeginFunction(...) ProfBegin(this_function_name)
#define ProfScope(...) DeferLoop(ProfBeginDynamic(__VA_ARGS__), ProfEnd())
////////////////////////////////
//~ rjf: General Markup
#define ThreadName(...) (ProfThreadName(__VA_ARGS__))
#endif // BASE_MARKUP_H
+616 -607
View File
File diff suppressed because it is too large. Load diff
+649 -648
View File
File diff suppressed because it is too large. Load diff
+422
View File
@@ -0,0 +1,422 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Type Info Lookups
internal Member *
member_from_name(Type *type, String8 name)
{
Member *member = &member_nil;
if(type->members != 0 && name.size != 0)
{
for(U64 idx = 0; idx < type->count; idx += 1)
{
if(str8_match(type->members[idx].name, name, 0))
{
member = &type->members[idx];
break;
}
}
}
return member;
}
////////////////////////////////
//~ rjf: Type Info * Instance Operations
internal void
typed_data_rebase_ptrs(Type *type, String8 data, void *base_ptr)
{
Temp scratch = scratch_begin(0, 0);
typedef struct RebaseTypeTask RebaseTypeTask;
struct RebaseTypeTask
{
RebaseTypeTask *next;
Type *type;
U8 *ptr;
};
RebaseTypeTask start_task = {0, type, data.str};
RebaseTypeTask *first_task = &start_task;
RebaseTypeTask *last_task = first_task;
for(RebaseTypeTask *t = first_task; t != 0; t = t->next)
{
switch(t->type->kind)
{
default:{}break;
case TypeKind_Ptr:
if(!(t->type->flags & TypeFlag_IsExternal))
{
*(U64 *)t->ptr = ((U64)(*(U8 **)t->ptr - (U8 *)base_ptr));
}break;
case TypeKind_Array:
{
for(U64 idx = 0; idx < t->type->count; idx += 1)
{
RebaseTypeTask *task = push_array(scratch.arena, RebaseTypeTask, 1);
task->type = t->type->direct;
task->ptr = t->ptr + t->type->direct->size * idx;
SLLQueuePush(first_task, last_task, task);
}
}break;
case TypeKind_Struct:
{
for(U64 idx = 0; idx < t->type->count; idx += 1)
{
Member *member = &t->type->members[idx];
RebaseTypeTask *task = push_array(scratch.arena, RebaseTypeTask, 1);
task->type = member->type;
task->ptr = t->ptr + member->value;
SLLQueuePush(first_task, last_task, task);
}
}break;
}
}
scratch_end(scratch);
}
internal String8
serialized_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params)
{
Temp scratch = scratch_begin(&arena, 1);
String8List strings = {0};
str8_serial_begin(scratch.arena, &strings);
{
typedef struct SerializeTypeTask SerializeTypeTask;
struct SerializeTypeTask
{
SerializeTypeTask *next;
Type *type;
U64 count;
U8 *src;
Type *containing_type;
U8 *containing_ptr;
B32 is_post_header;
};
SerializeTypeTask start_task = {0, type, 1, data.str};
SerializeTypeTask *first_task = &start_task;
SerializeTypeTask *last_task = first_task;
for(SerializeTypeTask *t = first_task; t != 0; t = t->next)
{
switch(t->type->kind)
{
//- rjf: leaf -> just copy the data directly
default:
if(TypeKind_FirstLeaf <= t->type->kind && t->type->kind <= TypeKind_LastLeaf)
{
str8_serial_push_string(scratch.arena, &strings, str8(t->src, t->type->size*t->count));
}break;
//- rjf: pointers -> try to interpret/understand pointer & read/write, otherwise just write as plain data
case TypeKind_Ptr:
{
// rjf: unpack info about this pointer
TypeSerializePtrRefInfo *ptr_ref_info = 0;
for(U64 idx = 0; idx < params->ptr_ref_infos_count; idx += 1)
{
if(params->ptr_ref_infos[idx].type == t->type->direct)
{
ptr_ref_info = &params->ptr_ref_infos[idx];
break;
}
}
// rjf: indexification -> subtract base, divide direct size, write index
if(ptr_ref_info != 0 && ptr_ref_info->indexify_base != 0)
{
U64 ptr_value = 0;
MemoryCopy(&ptr_value, t->src, sizeof(ptr_value));
U64 ptr_write_value = ((U64)((U8 *)ptr_value - (U8 *)ptr_ref_info->indexify_base)/t->type->direct->size);
str8_serial_push_struct(scratch.arena, &strings, &ptr_write_value);
}
// rjf: offsetification -> subtract base, write offsets
else if(ptr_ref_info != 0 && ptr_ref_info->offsetify_base != 0)
{
U64 ptr_value = 0;
MemoryCopy(&ptr_value, t->src, sizeof(ptr_value));
U64 ptr_write_value = (U64)((U8 *)ptr_value - (U8 *)ptr_ref_info->offsetify_base);
str8_serial_push_struct(scratch.arena, &strings, &ptr_write_value);
}
// rjf: size-by-member (pre-header): still potentially dependent on other members which
// delimit our size, so push a new post-header task for pointer.
else if(t->type->count_delimiter_name.size != 0 && !t->is_post_header)
{
SerializeTypeTask *task = push_array(scratch.arena, SerializeTypeTask, 1);
task->type = t->type;
task->count = t->count;
task->src = t->src;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
task->is_post_header = 1;
SLLQueuePush(first_task, last_task, task);
}
// rjf: size-by-member (post-header): all flat parts of containing struct have been
// iterated, so now we can read the size, & descend to new task to read pointer
// destination contents
else if(t->type->count_delimiter_name.size != 0 && t->is_post_header)
{
// rjf: determine count of this pointer
U64 count = 0;
{
Member *count_member = member_from_name(t->containing_type, t->type->count_delimiter_name);
MemoryCopy(&count, t->containing_ptr + count_member->value, count_member->type->size);
}
// rjf: push task
SerializeTypeTask *task = push_array(scratch.arena, SerializeTypeTask, 1);
task->type = t->type->direct;
task->count = count;
task->src = *(void **)t->src;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}
// rjf: catch-all: write pointer value
else
{
str8_serial_push_string(scratch.arena, &strings, str8(t->src, t->type->size*t->count));
}
}break;
//- rjf: arrays -> descend to underlying type, + count
case TypeKind_Array:
{
SerializeTypeTask *task = push_array(scratch.arena, SerializeTypeTask, 1);
task->type = t->type->direct;
task->count = t->type->count;
task->src = t->src;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}break;
//- rjf: struct -> descend to members
case TypeKind_Struct:
{
U64 off = 0;
for(U64 idx = 0; idx < t->count; idx += 1)
{
for(U64 member_idx = 0; member_idx < t->type->count; member_idx += 1)
{
if(t->type->members[member_idx].flags & MemberFlag_DoNotSerialize)
{
continue;
}
SerializeTypeTask *task = push_array(scratch.arena, SerializeTypeTask, 1);
task->type = t->type->members[member_idx].type;
task->count = 1;
task->src = t->src + idx*t->type->size + t->type->members[member_idx].value;
task->containing_type = t->type;
task->containing_ptr = t->src;
SLLQueuePush(first_task, last_task, task);
}
}
}break;
//- rjf: enum -> descend to basic type interpretation
case TypeKind_Enum:
{
SerializeTypeTask *task = push_array(scratch.arena, SerializeTypeTask, 1);
task->type = t->type->direct;
task->count = t->count;
task->src = t->src;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}break;
}
}
}
String8 result = str8_serial_end(arena, &strings);
scratch_end(scratch);
return result;
}
internal String8
deserialized_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params)
{
String8 result = {0};
result.size = type->size;
result.str = push_array(arena, U8, result.size);
{
Temp scratch = scratch_begin(&arena, 1);
typedef struct DeserializeTypeTask DeserializeTypeTask;
struct DeserializeTypeTask
{
DeserializeTypeTask *next;
Type *type;
U64 count;
U8 *dst;
Type *containing_type;
U8 *containing_ptr;
B32 is_post_header;
};
U64 read_off = 0;
DeserializeTypeTask start_task = {0, type, 1, result.str};
DeserializeTypeTask *first_task = &start_task;
DeserializeTypeTask *last_task = first_task;
for(DeserializeTypeTask *t = first_task; t != 0; t = t->next)
{
U8 *t_src = data.str + read_off;
switch(t->type->kind)
{
//- rjf: leaf -> copy the data directly
default:
if(TypeKind_FirstLeaf <= t->type->kind && t->type->kind <= TypeKind_LastLeaf)
{
MemoryCopy(t->dst, t_src, t->type->size*t->count);
read_off += t->type->size*t->count;
}break;
//- rjf: pointers -> try to interpret/understand pointer & read/write, otherwise skip
case TypeKind_Ptr:
{
// rjf: unpack info about this pointer
TypeSerializePtrRefInfo *ptr_ref_info = 0;
for(U64 idx = 0; idx < params->ptr_ref_infos_count; idx += 1)
{
if(params->ptr_ref_infos[idx].type == t->type->direct)
{
ptr_ref_info = &params->ptr_ref_infos[idx];
break;
}
}
// rjf: indexification -> add base, multiply direct size
if(ptr_ref_info != 0 && ptr_ref_info->indexify_base != 0)
{
U64 ptr_value = 0;
MemoryCopy(&ptr_value, t_src, sizeof(ptr_value));
U64 ptr_write_value = (ptr_value + (U64)ptr_ref_info->indexify_base) * t->type->direct->size;
MemoryCopy(t->dst, &ptr_write_value, sizeof(ptr_write_value));
read_off += sizeof(ptr_value);
}
// rjf: offsetification -> subtract base, write offsets
else if(ptr_ref_info != 0 && ptr_ref_info->offsetify_base != 0)
{
U64 ptr_value = 0;
MemoryCopy(&ptr_value, t_src, sizeof(ptr_value));
U64 ptr_write_value = ptr_value + (U64)ptr_ref_info->offsetify_base;
MemoryCopy(t->dst, &ptr_write_value, sizeof(ptr_write_value));
read_off += sizeof(ptr_value);
}
// rjf: size-by-member (pre-header): still potentially dependent on other members which
// delimit our size, so push a new post-header task for pointer.
else if(t->type->count_delimiter_name.size != 0 && !t->is_post_header)
{
DeserializeTypeTask *task = push_array(scratch.arena, DeserializeTypeTask, 1);
task->type = t->type;
task->count = t->count;
task->dst = t->dst;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
task->is_post_header = 1;
SLLQueuePush(first_task, last_task, task);
}
// rjf: size-by-member (post-header): all flat parts of containing struct have been
// iterated, so now we can read the size, & descend to new task to read pointer
// destination contents
else if(t->type->count_delimiter_name.size != 0 && t->is_post_header)
{
// rjf: determine count of this pointer
U64 count = 0;
{
Member *count_member = member_from_name(t->containing_type, t->type->count_delimiter_name);
MemoryCopy(&count, t->containing_ptr + count_member->value, count_member->type->size);
}
// rjf: allocate buffer for pointer destination; write address into pointer value slot
U64 ptr_dest_buffer_size = (count+1)*t->type->direct->size;
U8 *ptr_dest_buffer = push_array(arena, U8, ptr_dest_buffer_size);
MemoryCopy(t->dst, &ptr_dest_buffer, sizeof(ptr_dest_buffer));
// rjf: push task
DeserializeTypeTask *task = push_array(scratch.arena, DeserializeTypeTask, 1);
task->type = t->type->direct;
task->count = count;
task->dst = ptr_dest_buffer;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}
// rjf: catch-all: read pointer value
else
{
MemoryCopy(t->dst, t_src, t->type->size*t->count);
read_off += t->type->size*t->count;
}
}break;
//- rjf: arrays -> descend to underlying type, + count
case TypeKind_Array:
{
DeserializeTypeTask *task = push_array(scratch.arena, DeserializeTypeTask, 1);
task->type = t->type->direct;
task->count = t->type->count;
task->dst = t->dst;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}break;
//- rjf: struct -> descend to members
case TypeKind_Struct:
{
for(U64 idx = 0; idx < t->count; idx += 1)
{
for(U64 member_idx = 0; member_idx < t->type->count; member_idx += 1)
{
if(t->type->members[member_idx].flags & MemberFlag_DoNotSerialize)
{
continue;
}
DeserializeTypeTask *task = push_array(scratch.arena, DeserializeTypeTask, 1);
task->type = t->type->members[member_idx].type;
task->count = 1;
task->dst = t->dst + idx*t->type->size + t->type->members[member_idx].value;
task->containing_type = t->type;
task->containing_ptr = t->dst;
SLLQueuePush(first_task, last_task, task);
}
}
}break;
//- rjf: enum -> descend to basic type interpretation
case TypeKind_Enum:
{
DeserializeTypeTask *task = push_array(scratch.arena, DeserializeTypeTask, 1);
task->type = t->type->direct;
task->count = t->count;
task->dst = t->dst;
task->containing_type = t->containing_type;
task->containing_ptr = t->containing_ptr;
SLLQueuePush(first_task, last_task, task);
}break;
}
}
if(params->advance_out != 0)
{
params->advance_out[0] = read_off;
}
scratch_end(scratch);
}
return result;
}
internal String8
deep_copy_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params)
{
Temp scratch = scratch_begin(&arena, 1);
String8 data_srlz = serialized_from_typed_data(scratch.arena, type, data, params);
String8 data_copy = deserialized_from_typed_data(arena, type, data_srlz, params);
scratch_end(scratch);
return data_copy;
}
+298
View File
@@ -0,0 +1,298 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_META_H
#define BASE_META_H
////////////////////////////////
//~ rjf: Meta Markup Features
#define EmbedFile(name, path)
#define TweakB32(name, default) (TWEAK_##name)
#define TweakF32(name, default, min, max) (TWEAK_##name)
////////////////////////////////
//~ rjf: Tweak Info Tables
typedef struct TweakB32Info TweakB32Info;
struct TweakB32Info
{
String8 name;
B32 default_value;
B32 *value_ptr;
};
typedef struct TweakF32Info TweakF32Info;
struct TweakF32Info
{
String8 name;
F32 default_value;
Rng1F32 value_range;
F32 *value_ptr;
};
typedef struct TweakB32InfoTable TweakB32InfoTable;
struct TweakB32InfoTable
{
TweakB32Info *v;
U64 count;
};
typedef struct TweakF32InfoTable TweakF32InfoTable;
struct TweakF32InfoTable
{
TweakF32Info *v;
U64 count;
};
typedef struct EmbedInfo EmbedInfo;
struct EmbedInfo
{
String8 name;
String8 *data;
U128 *hash;
};
typedef struct EmbedInfoTable EmbedInfoTable;
struct EmbedInfoTable
{
EmbedInfo *v;
U64 count;
};
////////////////////////////////
//~ rjf: Type Info Types
typedef enum TypeKind
{
TypeKind_Null,
// rjf: leaves
TypeKind_Void, TypeKind_FirstLeaf = TypeKind_Void,
TypeKind_U8,
TypeKind_U16,
TypeKind_U32,
TypeKind_U64,
TypeKind_S8,
TypeKind_S16,
TypeKind_S32,
TypeKind_S64,
TypeKind_B8,
TypeKind_B16,
TypeKind_B32,
TypeKind_B64,
TypeKind_F32,
TypeKind_F64, TypeKind_LastLeaf = TypeKind_F64,
// rjf: operators
TypeKind_Ptr,
TypeKind_Array,
// rjf: user-defined-types
TypeKind_Struct,
TypeKind_Union,
TypeKind_Enum,
TypeKind_COUNT
}
TypeKind;
typedef U32 TypeFlags;
enum
{
TypeFlag_IsExternal = (1<<0),
TypeFlag_IsPlainText = (1<<1),
TypeFlag_IsCodeText = (1<<2),
TypeFlag_IsPathText = (1<<3),
};
typedef U32 MemberFlags;
enum
{
MemberFlag_DoNotSerialize = (1<<0),
};
typedef struct Type Type;
typedef struct Member Member;
struct Member
{
String8 name;
String8 pretty_name;
Type *type;
U64 value;
MemberFlags flags;
};
typedef struct Type Type;
struct Type
{
TypeKind kind;
TypeFlags flags;
U64 size;
Type *direct;
String8 name;
String8 count_delimiter_name; // gathered from surrounding members, turns *->[1] into *->[N]
U64 count;
Member *members;
};
////////////////////////////////
//~ rjf: Type Serialization Parameters
typedef struct TypeSerializePtrRefInfo TypeSerializePtrRefInfo;
struct TypeSerializePtrRefInfo
{
Type *type; // pointers to this
void *indexify_base; // can be indexified using this
void *offsetify_base; // can be offsetified using this
void *nil_ptr; // is terminal if matching 0 or this
};
typedef struct TypeSerializeParams TypeSerializeParams;
struct TypeSerializeParams
{
U64 *advance_out;
TypeSerializePtrRefInfo *ptr_ref_infos;
U64 ptr_ref_infos_count;
};
////////////////////////////////
//~ rjf: Type Name -> Type Info
#define type(T) (&T##__type)
////////////////////////////////
//~ rjf: Type Info Table Initializer Helpers
#define member_lit_comp(S, ti, m, ...) {str8_lit_comp(#m), {0}, (ti), OffsetOf(S, m), __VA_ARGS__}
#define struct_members(S) read_only global Member S##__members[] =
#define struct_type(S, ...) read_only global Type S##__type = {TypeKind_Struct, 0, sizeof(S), &type_nil, str8_lit_comp(#S), {0}, ArrayCount(S##__members), S##__members, __VA_ARGS__}
#define named_struct_type(name, S, ...) read_only global Type name##__type = {TypeKind_Struct, 0, sizeof(S), &type_nil, str8_lit_comp(#name), {0}, ArrayCount(name##__members), name##__members, __VA_ARGS__}
#define ptr_type(name, ti, ...) read_only global Type name = {TypeKind_Ptr, 0, sizeof(void *), (ti), __VA_ARGS__}
////////////////////////////////
//~ rjf: Globals
read_only global Type type_nil = {TypeKind_Null, 0, 0, &type_nil};
read_only global Member member_nil = {{0}, {0}, &type_nil};
////////////////////////////////
//~ rjf: Built-In Types
//- rjf: leaves
read_only global Type void__type = {TypeKind_Void, 0, 0, &type_nil, str8_lit_comp("void")};
read_only global Type U8__type = {TypeKind_U8, 0, sizeof(U8), &type_nil, str8_lit_comp("U8")};
read_only global Type U16__type = {TypeKind_U16, 0, sizeof(U16), &type_nil, str8_lit_comp("U16")};
read_only global Type U32__type = {TypeKind_U32, 0, sizeof(U32), &type_nil, str8_lit_comp("U32")};
read_only global Type U64__type = {TypeKind_U64, 0, sizeof(U64), &type_nil, str8_lit_comp("U64")};
read_only global Type S8__type = {TypeKind_S8, 0, sizeof(S8), &type_nil, str8_lit_comp("S8")};
read_only global Type S16__type = {TypeKind_S16, 0, sizeof(S16), &type_nil, str8_lit_comp("S16")};
read_only global Type S32__type = {TypeKind_S32, 0, sizeof(S32), &type_nil, str8_lit_comp("S32")};
read_only global Type S64__type = {TypeKind_S64, 0, sizeof(S64), &type_nil, str8_lit_comp("S64")};
read_only global Type B8__type = {TypeKind_B8, 0, sizeof(B8), &type_nil, str8_lit_comp("B8")};
read_only global Type B16__type = {TypeKind_B16, 0, sizeof(B16), &type_nil, str8_lit_comp("B16")};
read_only global Type B32__type = {TypeKind_B32, 0, sizeof(B32), &type_nil, str8_lit_comp("B32")};
read_only global Type B64__type = {TypeKind_B64, 0, sizeof(B64), &type_nil, str8_lit_comp("B64")};
read_only global Type F32__type = {TypeKind_F32, 0, sizeof(F32), &type_nil, str8_lit_comp("F32")};
read_only global Type F64__type = {TypeKind_F64, 0, sizeof(F64), &type_nil, str8_lit_comp("F64")};
read_only global Type *type_kind_type_table[] =
{
&type_nil,
type(void),
type(U8),
type(U16),
type(U32),
type(U64),
type(S8),
type(S16),
type(S32),
type(S64),
type(B8),
type(B16),
type(B32),
type(B64),
type(F32),
type(F64),
&type_nil,
&type_nil,
&type_nil,
&type_nil,
&type_nil,
};
//- rjf: Rng1U64
struct_members(Rng1U64)
{
member_lit_comp(Rng1U64, type(U64), min),
member_lit_comp(Rng1U64, type(U64), max),
};
struct_type(Rng1U64);
//- rjf: String8
ptr_type(String8__str_ptr_type, type(U8), str8_lit_comp("size"));
struct_members(String8)
{
member_lit_comp(String8, &String8__str_ptr_type, str),
member_lit_comp(String8, type(U64), size),
};
struct_type(String8);
//- rjf: String8Node
extern Type String8Node__type;
Type String8Node__ptr_type = {TypeKind_Ptr, 0, sizeof(void *), &String8Node__type};
Member String8Node__members[] =
{
{str8_lit_comp("next"), {0}, &String8Node__ptr_type, OffsetOf(String8Node, next)},
{str8_lit_comp("string"), {0}, type(String8), OffsetOf(String8Node, string)},
};
Type String8Node__type =
{
TypeKind_Struct,
0,
sizeof(String8Node),
&type_nil,
str8_lit_comp("String8Node"),
{0},
ArrayCount(String8Node__members),
String8Node__members,
};
//- rjf: String8List
Member String8List__members[] =
{
{str8_lit_comp("first"), {0}, &String8Node__ptr_type, OffsetOf(String8List, first)},
{str8_lit_comp("last"), {0}, &String8Node__ptr_type, OffsetOf(String8List, last), MemberFlag_DoNotSerialize},
{str8_lit_comp("node_count"), {0}, type(U64), OffsetOf(String8List, node_count)},
{str8_lit_comp("total_size"), {0}, type(U64), OffsetOf(String8List, total_size)},
};
Type String8List__type =
{
TypeKind_Struct,
0,
sizeof(String8List),
&type_nil,
str8_lit_comp("String8List"),
{0},
ArrayCount(String8List__members),
String8List__members,
};
////////////////////////////////
//~ rjf: Type Info Lookups
internal Member *member_from_name(Type *type, String8 name);
#define EachMember(T, it) (Member *it = (type(T))->members; it != 0 && it < (type(T))->members + (type(T))->count; it += 1)
////////////////////////////////
//~ rjf: Type Info * Instance Operations
internal void typed_data_rebase_ptrs(Type *type, String8 data, void *base_ptr);
internal String8 serialized_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params);
internal String8 deserialized_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params);
internal String8 deep_copy_from_typed_data(Arena *arena, Type *type, String8 data, TypeSerializeParams *params);
#define struct_rebase_ptrs(T, ptr, base) typed_data_rebase_ptrs(type(T), str8_struct(ptr), (base))
#define serialized_from_struct(arena, T, ptr, ...) serialized_from_typed_data((arena), type(T), str8_struct(ptr), &(TypeSerializeParams){.ptr_ref_infos = 0, __VA_ARGS__})
#define struct_from_serialized(arena, T, string, ...) (T *)deserialized_from_typed_data((arena), type(T), (string), &(TypeSerializeParams){.ptr_ref_infos = 0, __VA_ARGS__}).str
#define deep_copy_from_struct(arena, T, ptr, ...) (T *)deep_copy_from_typed_data((arena), type(T), str8_struct(ptr), &(TypeSerializeParams){.ptr_ref_infos = 0, __VA_ARGS__}).str
#endif // BASE_META_H
+2
View File
@@ -0,0 +1,2 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
+96
View File
@@ -0,0 +1,96 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_PROFILE_H
#define BASE_PROFILE_H
////////////////////////////////
//~ rjf: Zero Settings
#if !defined(PROFILE_TELEMETRY)
# define PROFILE_TELEMETRY 0
#endif
#if !defined(MARKUP_LAYER_COLOR)
# define MARKUP_LAYER_COLOR 1.00f, 0.00f, 1.00f
#endif
////////////////////////////////
//~ rjf: Third Party Includes
#if PROFILE_TELEMETRY
# include "rad_tm.h"
# if OS_WINDOWS
# pragma comment(lib, "rad_tm_win64.lib")
# endif
#endif
////////////////////////////////
//~ rjf: Telemetry Profile Defines
#if PROFILE_TELEMETRY
# define ProfBegin(...) tmEnter(0, 0, __VA_ARGS__)
# define ProfBeginDynamic(...) (TM_API_PTR ? TM_API_PTR->_tmEnterZoneV_Core(0, 0, __FILE__, &g_telemetry_filename_id, __LINE__, __VA_ARGS__) : (void)0)
# define ProfEnd(...) (TM_API_PTR ? TM_API_PTR->_tmLeaveZone(0) : (void)0)
# define ProfTick(...) tmTick(0)
# define ProfIsCapturing(...) tmRunning()
# define ProfBeginCapture(...) tmOpen(0, __VA_ARGS__, __DATE__, "localhost", TMCT_TCP, TELEMETRY_DEFAULT_PORT, TMOF_INIT_NETWORKING|TMOF_CAPTURE_CONTEXT_SWITCHES, 100)
# define ProfEndCapture(...) tmClose(0)
# define ProfThreadName(...) (TM_API_PTR ? TM_API_PTR->_tmThreadName(0, 0, __VA_ARGS__) : (void)0)
# define ProfMsg(...) (TM_API_PTR ? TM_API_PTR->_tmMessageV_Core(0, TMMF_ICON_NOTE, __FILE__, &g_telemetry_filename_id, __LINE__, __VA_ARGS__) : (void)0)
# define ProfBeginLockWait(...) tmStartWaitForLock(0, 0, __VA_ARGS__)
# define ProfEndLockWait(...) tmEndWaitForLock(0)
# define ProfLockTake(...) tmAcquiredLock(0, 0, __VA_ARGS__)
# define ProfLockDrop(...) tmReleasedLock(0, __VA_ARGS__)
# define ProfColor(color) tmZoneColorSticky(color)
# define ProfBeginV(...) \
if (TM_API_PTR) { \
static tm_uint64 file_id = 0; TM_API_PTR->_tmStaticString(&file_id, __FILE__); \
Temp scratch = scratch_begin(0,0); \
String8 string = push_str8f(scratch.arena, __VA_ARGS__); \
tm_uint64 hash = TM_API_PTR->_tmHash((char*)string.str, string.size); \
hash = TM_API_PTR->_tmSendDynamicString(hash, (char*)string.str); \
TM_API_PTR->_tmEnterZoneFast_Core(0, 0, file_id, __LINE__, hash); \
scratch_end(scratch); \
}
# define ProfNoteV(...) \
if (TM_API_PTR) { \
static tm_uint64 file_id = 0; TM_API_PTR->_tmStaticString(&file_id, __FILE__); \
Temp scratch = scratch_begin(0,0); \
String8 string = push_str8f(scratch.arena, __VA_ARGS__); \
tm_uint64 hash = TM_API_PTR->_tmHash((char*)string.str, string.size); \
hash = TM_API_PTR->_tmSendDynamicString(hash, (char*)string.str); \
TM_API_PTR->_tmMessageFast_Core(0, TMMF_ICON_NOTE, file_id, __LINE__, hash); \
scratch_end(scratch); \
}
#endif
////////////////////////////////
//~ rjf: Zeroify Undefined Defines
#if !defined(ProfBegin)
# define ProfBegin(...) (0)
# define ProfBeginDynamic(...) (0)
# define ProfEnd(...) (0)
# define ProfTick(...) (0)
# define ProfIsCapturing(...) (0)
# define ProfBeginCapture(...) (0)
# define ProfEndCapture(...) (0)
# define ProfThreadName(...) (0)
# define ProfMsg(...) (0)
# define ProfBeginLockWait(...) (0)
# define ProfEndLockWait(...) (0)
# define ProfLockTake(...) (0)
# define ProfLockDrop(...) (0)
# define ProfColor(...) (0)
# define ProfBeginV(...) (0)
# define ProfNoteV(...) (0)
#endif
////////////////////////////////
//~ rjf: Helper Wrappers
#define ProfBeginFunction(...) ProfBegin(this_function_name)
#define ProfScope(...) DeferLoop(ProfBeginDynamic(__VA_ARGS__), ProfEnd())
#endif // BASE_PROFILE_H
File diff suppressed because it is too large. Load diff
@@ -1,351 +1,406 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_STRING_H #ifndef BASE_STRINGS_H
#define BASE_STRING_H #define BASE_STRINGS_H
//////////////////////////////// ////////////////////////////////
//~ rjf: Third Party Includes //~ rjf: Third Party Includes
#define STB_SPRINTF_DECORATE(name) raddbg_##name #define STB_SPRINTF_DECORATE(name) raddbg_##name
#include "third_party/stb/stb_sprintf.h" #include "third_party/stb/stb_sprintf.h"
//////////////////////////////// ////////////////////////////////
//~ rjf: String Types //~ rjf: String Types
typedef struct String8 String8; typedef struct String8 String8;
struct String8 struct String8
{ {
U8 *str; U8 *str;
U64 size; U64 size;
}; };
typedef struct String16 String16; typedef struct String16 String16;
struct String16 struct String16
{ {
U16 *str; U16 *str;
U64 size; U64 size;
}; };
typedef struct String32 String32; typedef struct String32 String32;
struct String32 struct String32
{ {
U32 *str; U32 *str;
U64 size; U64 size;
}; };
//////////////////////////////// ////////////////////////////////
//~ rjf: String List & Array Types //~ rjf: String List & Array Types
typedef struct String8Node String8Node; typedef struct String8Node String8Node;
struct String8Node struct String8Node
{ {
String8Node *next; String8Node *next;
String8 string; String8 string;
}; };
typedef struct String8MetaNode String8MetaNode; typedef struct String8MetaNode String8MetaNode;
struct String8MetaNode struct String8MetaNode
{ {
String8MetaNode *next; String8MetaNode *next;
String8Node *node; String8Node *node;
}; };
typedef struct String8List String8List; typedef struct String8List String8List;
struct String8List struct String8List
{ {
String8Node *first; String8Node *first;
String8Node *last; String8Node *last;
U64 node_count; U64 node_count;
U64 total_size; U64 total_size;
}; };
typedef struct String8Array String8Array; typedef struct String8Array String8Array;
struct String8Array struct String8Array
{ {
String8 *strings; String8 *v;
U64 count; U64 count;
}; };
//////////////////////////////// ////////////////////////////////
//~ rjf: String Matching, Splitting, & Joining Types //~ rjf: String Matching, Splitting, & Joining Types
typedef U32 StringMatchFlags; typedef U32 StringMatchFlags;
enum enum
{ {
StringMatchFlag_CaseInsensitive = (1 << 0), StringMatchFlag_CaseInsensitive = (1 << 0),
StringMatchFlag_RightSideSloppy = (1 << 1), StringMatchFlag_RightSideSloppy = (1 << 1),
StringMatchFlag_SlashInsensitive = (1 << 2), StringMatchFlag_SlashInsensitive = (1 << 2),
}; };
typedef U32 StringSplitFlags; typedef U32 StringSplitFlags;
enum enum
{ {
StringSplitFlag_KeepEmpties = (1 << 0), StringSplitFlag_KeepEmpties = (1 << 0),
}; };
typedef enum PathStyle typedef enum PathStyle
{ {
PathStyle_Relative, PathStyle_Null,
PathStyle_WindowsAbsolute, PathStyle_Relative,
PathStyle_UnixAbsolute, PathStyle_WindowsAbsolute,
PathStyle_UnixAbsolute,
#if OS_WINDOWS
PathStyle_SystemAbsolute = PathStyle_WindowsAbsolute #if OS_WINDOWS
#elif OS_LINUX PathStyle_SystemAbsolute = PathStyle_WindowsAbsolute
PathStyle_SystemAbsolute = PathStyle_UnixAbsolute #elif OS_LINUX
#else PathStyle_SystemAbsolute = PathStyle_UnixAbsolute
# error "absolute path style is undefined for this OS" #else
#endif # error "absolute path style is undefined for this OS"
} #endif
PathStyle; }
PathStyle;
typedef struct StringJoin StringJoin;
struct StringJoin typedef struct StringJoin StringJoin;
{ struct StringJoin
String8 pre; {
String8 sep; String8 pre;
String8 post; String8 sep;
}; String8 post;
};
////////////////////////////////
//~ rjf: String Pair Types ////////////////////////////////
//~ rjf: String Pair Types
typedef struct String8TxtPtPair String8TxtPtPair;
struct String8TxtPtPair typedef struct String8TxtPtPair String8TxtPtPair;
{ struct String8TxtPtPair
String8 string; {
TxtPt pt; String8 string;
}; TxtPt pt;
};
////////////////////////////////
//~ rjf: UTF Decoding Types ////////////////////////////////
//~ rjf: UTF Decoding Types
typedef struct UnicodeDecode UnicodeDecode;
struct UnicodeDecode typedef struct UnicodeDecode UnicodeDecode;
{ struct UnicodeDecode
U32 inc; {
U32 codepoint; U32 inc;
}; U32 codepoint;
};
////////////////////////////////
//~ rjf: Character Classification & Conversion Functions ////////////////////////////////
//~ rjf: String Fuzzy Matching Types
internal B32 char_is_space(U8 c);
internal B32 char_is_upper(U8 c); typedef struct FuzzyMatchRangeNode FuzzyMatchRangeNode;
internal B32 char_is_lower(U8 c); struct FuzzyMatchRangeNode
internal B32 char_is_alpha(U8 c); {
internal B32 char_is_slash(U8 c); FuzzyMatchRangeNode *next;
internal B32 char_is_digit(U8 c, U32 base); Rng1U64 range;
internal U8 char_to_lower(U8 c); };
internal U8 char_to_upper(U8 c);
internal U8 char_to_correct_slash(U8 c); typedef struct FuzzyMatchRangeList FuzzyMatchRangeList;
struct FuzzyMatchRangeList
//////////////////////////////// {
//~ rjf: C-String Measurement FuzzyMatchRangeNode *first;
FuzzyMatchRangeNode *last;
internal U64 cstring8_length(U8 *c); U64 count;
internal U64 cstring16_length(U16 *c); U64 needle_part_count;
internal U64 cstring32_length(U32 *c); U64 total_dim;
};
////////////////////////////////
//~ rjf: String Constructors ////////////////////////////////
//~ rjf: Character Classification & Conversion Functions
#define str8_lit(S) str8((U8*)(S), sizeof(S) - 1)
#define str8_lit_comp(S) {(U8*)(S), sizeof(S) - 1,} internal B32 char_is_space(U8 c);
#define str8_varg(S) (int)((S).size), ((S).str) internal B32 char_is_upper(U8 c);
internal B32 char_is_lower(U8 c);
#define str8_array(S,C) str8((U8*)(S), sizeof(*(S))*(C)) internal B32 char_is_alpha(U8 c);
#define str8_array_fixed(S) str8((U8*)(S), sizeof(S)) internal B32 char_is_slash(U8 c);
#define str8_struct(S) str8((U8*)(S), sizeof(*(S))) internal B32 char_is_digit(U8 c, U32 base);
internal U8 char_to_lower(U8 c);
internal String8 str8(U8 *str, U64 size); internal U8 char_to_upper(U8 c);
internal String8 str8_range(U8 *first, U8 *one_past_last); internal U8 char_to_correct_slash(U8 c);
internal String8 str8_zero(void);
internal String16 str16(U16 *str, U64 size); ////////////////////////////////
internal String16 str16_range(U16 *first, U16 *one_past_last); //~ rjf: C-String Measurement
internal String16 str16_zero(void);
internal String32 str32(U32 *str, U64 size); internal U64 cstring8_length(U8 *c);
internal String32 str32_range(U32 *first, U32 *one_past_last); internal U64 cstring16_length(U16 *c);
internal String32 str32_zero(void); internal U64 cstring32_length(U32 *c);
internal String8 str8_cstring(char *c);
internal String16 str16_cstring(U16 *c); ////////////////////////////////
internal String32 str32_cstring(U32 *c); //~ rjf: String Constructors
internal String8 str8_cstring_capped(void *cstr, void *cap);
#define str8_lit(S) str8((U8*)(S), sizeof(S) - 1)
//////////////////////////////// #define str8_lit_comp(S) {(U8*)(S), sizeof(S) - 1,}
//~ rjf: String Stylization #define str8_varg(S) (int)((S).size), ((S).str)
internal String8 upper_from_str8(Arena *arena, String8 string); #define str8_array(S,C) str8((U8*)(S), sizeof(*(S))*(C))
internal String8 lower_from_str8(Arena *arena, String8 string); #define str8_array_fixed(S) str8((U8*)(S), sizeof(S))
internal String8 backslashed_from_str8(Arena *arena, String8 string); #define str8_struct(S) str8((U8*)(S), sizeof(*(S)))
//////////////////////////////// internal String8 str8(U8 *str, U64 size);
//~ rjf: String Matching internal String8 str8_range(U8 *first, U8 *one_past_last);
internal String8 str8_zero(void);
internal B32 str8_match(String8 a, String8 b, StringMatchFlags flags); internal String16 str16(U16 *str, U64 size);
internal U64 str8_find_needle(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags); internal String16 str16_range(U16 *first, U16 *one_past_last);
internal B32 str8_ends_with(String8 string, String8 end, StringMatchFlags flags); internal String16 str16_zero(void);
internal String32 str32(U32 *str, U64 size);
//////////////////////////////// internal String32 str32_range(U32 *first, U32 *one_past_last);
//~ rjf: String Slicing internal String32 str32_zero(void);
internal String8 str8_cstring(char *c);
internal String8 str8_substr(String8 str, Rng1U64 range); internal String16 str16_cstring(U16 *c);
internal String8 str8_prefix(String8 str, U64 size); internal String32 str32_cstring(U32 *c);
internal String8 str8_skip(String8 str, U64 amt); internal String8 str8_cstring_capped(void *cstr, void *cap);
internal String8 str8_postfix(String8 str, U64 size); internal String16 str16_cstring_capped(void *cstr, void *cap);
internal String8 str8_chop(String8 str, U64 amt); internal String8 str8_cstring_capped_reverse(void *raw_start, void *raw_cap);
internal String8 str8_skip_chop_whitespace(String8 string);
////////////////////////////////
//////////////////////////////// //~ rjf: String Stylization
//~ rjf: String Formatting & Copying
internal String8 upper_from_str8(Arena *arena, String8 string);
internal String8 push_str8_cat(Arena *arena, String8 s1, String8 s2); internal String8 lower_from_str8(Arena *arena, String8 string);
internal String8 push_str8_copy(Arena *arena, String8 s); internal String8 backslashed_from_str8(Arena *arena, String8 string);
internal String8 push_str8fv(Arena *arena, char *fmt, va_list args);
internal String8 push_str8f(Arena *arena, char *fmt, ...); ////////////////////////////////
//~ rjf: String Matching
////////////////////////////////
//~ rjf: String <=> Integer Conversions internal B32 str8_match(String8 a, String8 b, StringMatchFlags flags);
internal U64 str8_find_needle(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
//- rjf: string -> integer internal U64 str8_find_needle_reverse(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
internal S64 sign_from_str8(String8 string, String8 *string_tail); internal B32 str8_ends_with(String8 string, String8 end, StringMatchFlags flags);
internal B32 str8_is_integer(String8 string, U32 radix);
internal U64 u64_from_str8(String8 string, U32 radix); ////////////////////////////////
internal S64 s64_from_str8(String8 string, U32 radix); //~ rjf: String Slicing
internal B32 try_u64_from_str8_c_rules(String8 string, U64 *x);
internal B32 try_s64_from_str8_c_rules(String8 string, S64 *x); internal String8 str8_substr(String8 str, Rng1U64 range);
internal String8 str8_prefix(String8 str, U64 size);
//- rjf: string -> integer (base64 & base16) internal String8 str8_skip(String8 str, U64 amt);
internal U64 base64_size_from_data_size(U64 size_in_bytes); internal String8 str8_postfix(String8 str, U64 size);
internal U64 base64_from_data(U8 *dst, U8 *src, U64 src_size); internal String8 str8_chop(String8 str, U64 amt);
internal U64 base16_size_from_data_size(U64 size_in_bytes); internal String8 str8_skip_chop_whitespace(String8 string);
internal U64 base16_from_data(U8 *dst, U8 *src, U64 src_size);
////////////////////////////////
//- rjf: integer -> string //~ rjf: String Formatting & Copying
internal String8 str8_from_memory_size(Arena *arena, U64 z);
internal String8 str8_from_u64(Arena *arena, U64 u64, U32 radix, U8 min_digits, U8 digit_group_separator); internal String8 push_str8_cat(Arena *arena, String8 s1, String8 s2);
internal String8 str8_from_s64(Arena *arena, S64 s64, U32 radix, U8 min_digits, U8 digit_group_separator); internal String8 push_str8_copy(Arena *arena, String8 s);
internal String8 push_str8fv(Arena *arena, char *fmt, va_list args);
//////////////////////////////// internal String8 push_str8f(Arena *arena, char *fmt, ...);
//~ rjf: String <=> Float Conversions
////////////////////////////////
internal F64 f64_from_str8(String8 string); //~ rjf: String <=> Integer Conversions
//////////////////////////////// //- rjf: string -> integer
//~ rjf: String List Construction Functions internal S64 sign_from_str8(String8 string, String8 *string_tail);
internal B32 str8_is_integer(String8 string, U32 radix);
internal String8Node* str8_list_push_node(String8List *list, String8Node *node); internal U64 u64_from_str8(String8 string, U32 radix);
internal String8Node* str8_list_push_node_set_string(String8List *list, String8Node *node, String8 string); internal S64 s64_from_str8(String8 string, U32 radix);
internal String8Node* str8_list_push_node_front(String8List *list, String8Node *node); internal B32 try_u64_from_str8_c_rules(String8 string, U64 *x);
internal String8Node* str8_list_push_node_front_set_string(String8List *list, String8Node *node, String8 string); internal B32 try_s64_from_str8_c_rules(String8 string, S64 *x);
internal String8Node* str8_list_push(Arena *arena, String8List *list, String8 string);
internal String8Node* str8_list_push_front(Arena *arena, String8List *list, String8 string); //- rjf: integer -> string
internal void str8_list_concat_in_place(String8List *list, String8List *to_push); internal String8 str8_from_memory_size(Arena *arena, U64 size);
internal String8Node* str8_list_push_aligner(Arena *arena, String8List *list, U64 min, U64 align); internal String8 str8_from_count(Arena *arena, U64 count);
internal String8Node* str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...); internal String8 str8_from_bits_u32(Arena *arena, U32 x);
internal String8Node* str8_list_push_frontf(Arena *arena, String8List *list, char *fmt, ...); internal String8 str8_from_bits_u64(Arena *arena, U64 x);
internal String8List str8_list_copy(Arena *arena, String8List *list); internal String8 str8_from_u64(Arena *arena, U64 u64, U32 radix, U8 min_digits, U8 digit_group_separator);
#define str8_list_first(list) ((list)->first ? (list)->first->string : str8_zero()) internal String8 str8_from_s64(Arena *arena, S64 s64, U32 radix, U8 min_digits, U8 digit_group_separator);
//////////////////////////////// ////////////////////////////////
//~ rjf: String Splitting & Joining //~ rjf: String <=> Float Conversions
internal String8List str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags); internal F64 f64_from_str8(String8 string);
internal String8List str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags);
internal String8List str8_list_split_by_string_chars(Arena *arena, String8List list, String8 split_chars, StringSplitFlags flags); ////////////////////////////////
internal String8 str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params); //~ rjf: String List Construction Functions
internal void str8_list_from_flags(Arena *arena, String8List *list, U32 flags, String8 *flag_string_table, U32 flag_string_count);
internal String8Node* str8_list_push_node(String8List *list, String8Node *node);
//////////////////////////////// internal String8Node* str8_list_push_node_set_string(String8List *list, String8Node *node, String8 string);
//~ rjf; String Arrays internal String8Node* str8_list_push_node_front(String8List *list, String8Node *node);
internal String8Node* str8_list_push_node_front_set_string(String8List *list, String8Node *node, String8 string);
internal String8Array str8_array_from_list(Arena *arena, String8List *list); internal String8Node* str8_list_push(Arena *arena, String8List *list, String8 string);
internal String8Array str8_array_reserve(Arena *arena, U64 count); internal String8Node* str8_list_push_front(Arena *arena, String8List *list, String8 string);
internal void str8_list_concat_in_place(String8List *list, String8List *to_push);
//////////////////////////////// internal String8Node* str8_list_push_aligner(Arena *arena, String8List *list, U64 min, U64 align);
//~ rjf: String Path Helpers internal String8Node* str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...);
internal String8Node* str8_list_push_frontf(Arena *arena, String8List *list, char *fmt, ...);
internal String8 str8_chop_last_slash(String8 string); internal String8List str8_list_copy(Arena *arena, String8List *list);
internal String8 str8_skip_last_slash(String8 string); #define str8_list_first(list) ((list)->first ? (list)->first->string : str8_zero())
internal String8 str8_chop_last_dot(String8 string);
internal String8 str8_skip_last_dot(String8 string); ////////////////////////////////
//~ rjf: String Splitting & Joining
internal PathStyle path_style_from_str8(String8 string);
internal String8List str8_split_path(Arena *arena, String8 string); internal String8List str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags);
internal void str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style); internal String8List str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags);
internal String8 str8_path_list_join_by_style(Arena *arena, String8List *path, PathStyle style); internal String8List str8_list_split_by_string_chars(Arena *arena, String8List list, String8 split_chars, StringSplitFlags flags);
internal String8 str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params);
internal String8TxtPtPair str8_txt_pt_pair_from_string(String8 string); internal void str8_list_from_flags(Arena *arena, String8List *list, U32 flags, String8 *flag_string_table, U32 flag_string_count);
//////////////////////////////// ////////////////////////////////
//~ rjf: UTF-8 & UTF-16 Decoding/Encoding //~ rjf; String Arrays
internal UnicodeDecode utf8_decode(U8 *str, U64 max); internal String8Array str8_array_from_list(Arena *arena, String8List *list);
internal UnicodeDecode utf16_decode(U16 *str, U64 max); internal String8Array str8_array_reserve(Arena *arena, U64 count);
internal U32 utf8_encode(U8 *str, U32 codepoint);
internal U32 utf16_encode(U16 *str, U32 codepoint); ////////////////////////////////
internal U32 utf8_from_utf32_single(U8 *buffer, U32 character); //~ rjf: String Path Helpers
//////////////////////////////// internal String8 str8_chop_last_slash(String8 string);
//~ rjf: Unicode String Conversions internal String8 str8_skip_last_slash(String8 string);
internal String8 str8_chop_last_dot(String8 string);
internal String8 str8_from_16(Arena *arena, String16 in); internal String8 str8_skip_last_dot(String8 string);
internal String16 str16_from_8(Arena *arena, String8 in);
internal String8 str8_from_32(Arena *arena, String32 in); internal PathStyle path_style_from_str8(String8 string);
internal String32 str32_from_8(Arena *arena, String8 in); internal String8List str8_split_path(Arena *arena, String8 string);
internal void str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style);
//////////////////////////////// internal String8 str8_path_list_join_by_style(Arena *arena, String8List *path, PathStyle style);
//~ rjf: Basic Types & Space Enum -> String Conversions
internal String8TxtPtPair str8_txt_pt_pair_from_string(String8 string);
internal String8 string_from_dimension(Dimension dimension);
internal String8 string_from_side(Side side); ////////////////////////////////
internal String8 string_from_operating_system(OperatingSystem os); //~ rjf: UTF-8 & UTF-16 Decoding/Encoding
internal String8 string_from_architecture(Architecture arch);
internal UnicodeDecode utf8_decode(U8 *str, U64 max);
//////////////////////////////// internal UnicodeDecode utf16_decode(U16 *str, U64 max);
//~ rjf: Time Types -> String internal U32 utf8_encode(U8 *str, U32 codepoint);
internal U32 utf16_encode(U16 *str, U32 codepoint);
internal String8 string_from_week_day(WeekDay week_day); internal U32 utf8_from_utf32_single(U8 *buffer, U32 character);
internal String8 string_from_month(Month month);
internal String8 push_date_time_string(Arena *arena, DateTime *date_time); ////////////////////////////////
internal String8 push_file_name_date_time_string(Arena *arena, DateTime *date_time); //~ rjf: Unicode String Conversions
internal String8 string_from_elapsed_time(Arena *arena, DateTime dt);
internal String8 str8_from_16(Arena *arena, String16 in);
//////////////////////////////// internal String16 str16_from_8(Arena *arena, String8 in);
//~ rjf: String <-> Color internal String8 str8_from_32(Arena *arena, String32 in);
internal String32 str32_from_8(Arena *arena, String8 in);
internal String8 hex_string_from_rgba_4f32(Arena *arena, Vec4F32 rgba);
internal Vec4F32 rgba_from_hex_string_4f32(String8 hex_string); ////////////////////////////////
//~ String -> Enum Conversions
////////////////////////////////
//~ NOTE(allen): Serialization Helpers internal OperatingSystem operating_system_from_string(String8 string);
internal void str8_serial_begin(Arena *arena, String8List *srl); ////////////////////////////////
internal String8 str8_serial_end(Arena *arena, String8List *srl); //~ rjf: Basic Types & Space Enum -> String Conversions
internal void str8_serial_write_to_dst(String8List *srl, void *out);
internal U64 str8_serial_push_align(Arena *arena, String8List *srl, U64 align); internal String8 string_from_dimension(Dimension dimension);
internal void * str8_serial_push_size(Arena *arena, String8List *srl, U64 size); internal String8 string_from_side(Side side);
internal void * str8_serial_push_data(Arena *arena, String8List *srl, void *data, U64 size); internal String8 string_from_operating_system(OperatingSystem os);
internal void str8_serial_push_data_list(Arena *arena, String8List *srl, String8Node *first); internal String8 string_from_arch(Arch arch);
internal void str8_serial_push_u64(Arena *arena, String8List *srl, U64 x);
internal void str8_serial_push_u32(Arena *arena, String8List *srl, U32 x); ////////////////////////////////
internal void str8_serial_push_u16(Arena *arena, String8List *srl, U16 x); //~ rjf: Time Types -> String
internal void str8_serial_push_u8(Arena *arena, String8List *srl, U8 x);
internal void str8_serial_push_cstr(Arena *arena, String8List *srl, String8 str); internal String8 string_from_week_day(WeekDay week_day);
internal void str8_serial_push_string(Arena *arena, String8List *srl, String8 str); internal String8 string_from_month(Month month);
#define str8_serial_push_array(arena, srl, ptr, count) str8_serial_push_data(arena, srl, ptr, sizeof(*(ptr)) * (count)) internal String8 push_date_time_string(Arena *arena, DateTime *date_time);
#define str8_serial_push_struct(arena, srl, ptr) str8_serial_push_array(arena, srl, ptr, 1) internal String8 push_file_name_date_time_string(Arena *arena, DateTime *date_time);
internal String8 string_from_elapsed_time(Arena *arena, DateTime dt);
////////////////////////////////
//~ rjf: Deserialization Helpers ////////////////////////////////
//~ Globally Unique Ids
internal U64 str8_deserial_read(String8 string, U64 off, void *read_dst, U64 read_size, U64 granularity);
internal U64 str8_deserial_find_first_match(String8 string, U64 off, U16 scan_val); internal String8 string_from_guid(Arena *arena, Guid guid);
internal void * str8_deserial_get_raw_ptr(String8 string, U64 off, U64 size);internal U64 str8_deserial_read_cstr(String8 string, U64 off, String8 *cstr_out); internal B32 try_guid_from_string(String8 string, Guid *guid_out);
internal U64 str8_deserial_read_windows_utf16_string16(String8 string, U64 off, String16 *str_out); internal Guid guid_from_string(String8 string);
internal U64 str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out);
#define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr))) ////////////////////////////////
#define str8_deserial_read_struct(string, off, ptr) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr)), sizeof(*(ptr))) //~ rjf: Basic Text Indentation
#endif // BASE_STRING_H internal String8 indented_from_string(Arena *arena, String8 string);
////////////////////////////////
//~ rjf: Text Escaping
internal String8 escaped_from_raw_str8(Arena *arena, String8 string);
internal String8 raw_from_escaped_str8(Arena *arena, String8 string);
////////////////////////////////
//~ rjf: Text Wrapping
internal String8List wrapped_lines_from_string(Arena *arena, String8 string, U64 first_line_max_width, U64 max_width, U64 wrap_indent);
////////////////////////////////
//~ rjf: String <-> Color
internal String8 hex_string_from_rgba_4f32(Arena *arena, Vec4F32 rgba);
internal Vec4F32 rgba_from_hex_string_4f32(String8 hex_string);
////////////////////////////////
//~ rjf: String Fuzzy Matching
internal FuzzyMatchRangeList fuzzy_match_find(Arena *arena, String8 needle, String8 haystack);
internal FuzzyMatchRangeList fuzzy_match_range_list_copy(Arena *arena, FuzzyMatchRangeList *src);
////////////////////////////////
//~ NOTE(allen): Serialization Helpers
internal void str8_serial_begin(Arena *arena, String8List *srl);
internal String8 str8_serial_end(Arena *arena, String8List *srl);
internal void str8_serial_write_to_dst(String8List *srl, void *out);
internal U64 str8_serial_push_align(Arena *arena, String8List *srl, U64 align);
internal void * str8_serial_push_size(Arena *arena, String8List *srl, U64 size);
internal void * str8_serial_push_data(Arena *arena, String8List *srl, void *data, U64 size);
internal void str8_serial_push_data_list(Arena *arena, String8List *srl, String8Node *first);
internal void str8_serial_push_u64(Arena *arena, String8List *srl, U64 x);
internal void str8_serial_push_u32(Arena *arena, String8List *srl, U32 x);
internal void str8_serial_push_u16(Arena *arena, String8List *srl, U16 x);
internal void str8_serial_push_u8(Arena *arena, String8List *srl, U8 x);
internal void str8_serial_push_cstr(Arena *arena, String8List *srl, String8 str);
internal void str8_serial_push_string(Arena *arena, String8List *srl, String8 str);
#define str8_serial_push_array(arena, srl, ptr, count) str8_serial_push_data(arena, srl, ptr, sizeof(*(ptr)) * (count))
#define str8_serial_push_struct(arena, srl, ptr) str8_serial_push_array(arena, srl, ptr, 1)
////////////////////////////////
//~ rjf: Deserialization Helpers
internal U64 str8_deserial_read(String8 string, U64 off, void *read_dst, U64 read_size, U64 granularity);
internal U64 str8_deserial_find_first_match(String8 string, U64 off, U16 scan_val);
internal void * str8_deserial_get_raw_ptr(String8 string, U64 off, U64 size);internal U64 str8_deserial_read_cstr(String8 string, U64 off, String8 *cstr_out);
internal U64 str8_deserial_read_windows_utf16_string16(String8 string, U64 off, String16 *str_out);
internal U64 str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out);
#define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr)))
#define str8_deserial_read_struct(string, off, ptr) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr)), sizeof(*(ptr)))
#endif // BASE_STRINGS_H
+87 -78
View File
@@ -1,78 +1,87 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
// NOTE(allen): Thread Context Functions // NOTE(allen): Thread Context Functions
C_LINKAGE thread_static TCTX* tctx_thread_local; C_LINKAGE thread_static TCTX* tctx_thread_local;
#if !SUPPLEMENT_UNIT #if !BUILD_SUPPLEMENTARY_UNIT
C_LINKAGE thread_static TCTX* tctx_thread_local = 0; C_LINKAGE thread_static TCTX* tctx_thread_local = 0;
#endif #endif
internal void internal void
tctx_init_and_equip(TCTX *tctx){ tctx_init_and_equip(TCTX *tctx){
MemoryZeroStruct(tctx); MemoryZeroStruct(tctx);
Arena **arena_ptr = tctx->arenas; Arena **arena_ptr = tctx->arenas;
for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){ for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){
*arena_ptr = arena_alloc(); *arena_ptr = arena_alloc();
} }
tctx_thread_local = tctx; tctx_thread_local = tctx;
} }
internal TCTX* internal void
tctx_get_equipped(void){ tctx_release(void)
return(tctx_thread_local); {
} for(U64 i = 0; i < ArrayCount(tctx_thread_local->arenas); i += 1)
{
internal Arena* arena_release(tctx_thread_local->arenas[i]);
tctx_get_scratch(Arena **conflicts, U64 count){ }
TCTX *tctx = tctx_get_equipped(); }
Arena *result = 0; internal TCTX*
Arena **arena_ptr = tctx->arenas; tctx_get_equipped(void){
for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){ return(tctx_thread_local);
Arena **conflict_ptr = conflicts; }
B32 has_conflict = 0;
for (U64 j = 0; j < count; j += 1, conflict_ptr += 1){ internal Arena*
if (*arena_ptr == *conflict_ptr){ tctx_get_scratch(Arena **conflicts, U64 count){
has_conflict = 1; TCTX *tctx = tctx_get_equipped();
break;
} Arena *result = 0;
} Arena **arena_ptr = tctx->arenas;
if (!has_conflict){ for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){
result = *arena_ptr; Arena **conflict_ptr = conflicts;
break; B32 has_conflict = 0;
} for (U64 j = 0; j < count; j += 1, conflict_ptr += 1){
} if (*arena_ptr == *conflict_ptr){
has_conflict = 1;
return(result); break;
} }
}
internal void if (!has_conflict){
tctx_set_thread_name(String8 string){ result = *arena_ptr;
TCTX *tctx = tctx_get_equipped(); break;
U64 size = ClampTop(string.size, sizeof(tctx->thread_name)); }
MemoryCopy(tctx->thread_name, string.str, size); }
tctx->thread_name_size = size;
} return(result);
}
internal String8
tctx_get_thread_name(void){ internal void
TCTX *tctx = tctx_get_equipped(); tctx_set_thread_name(String8 string){
String8 result = str8(tctx->thread_name, tctx->thread_name_size); TCTX *tctx = tctx_get_equipped();
return(result); U64 size = ClampTop(string.size, sizeof(tctx->thread_name));
} MemoryCopy(tctx->thread_name, string.str, size);
tctx->thread_name_size = size;
internal void }
tctx_write_srcloc(char *file_name, U64 line_number){
TCTX *tctx = tctx_get_equipped(); internal String8
tctx->file_name = file_name; tctx_get_thread_name(void){
tctx->line_number = line_number; TCTX *tctx = tctx_get_equipped();
} String8 result = str8(tctx->thread_name, tctx->thread_name_size);
return(result);
internal void }
tctx_read_srcloc(char **file_name, U64 *line_number){
TCTX *tctx = tctx_get_equipped(); internal void
*file_name = tctx->file_name; tctx_write_srcloc(char *file_name, U64 line_number){
*line_number = tctx->line_number; TCTX *tctx = tctx_get_equipped();
} tctx->file_name = file_name;
tctx->line_number = line_number;
}
internal void
tctx_read_srcloc(char **file_name, U64 *line_number){
TCTX *tctx = tctx_get_equipped();
*file_name = tctx->file_name;
*line_number = tctx->line_number;
}
+41 -40
View File
@@ -1,40 +1,41 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_THREAD_CONTEXT_H #ifndef BASE_THREAD_CONTEXT_H
#define BASE_THREAD_CONTEXT_H #define BASE_THREAD_CONTEXT_H
//////////////////////////////// ////////////////////////////////
// NOTE(allen): Thread Context // NOTE(allen): Thread Context
typedef struct TCTX TCTX; typedef struct TCTX TCTX;
struct TCTX struct TCTX
{ {
Arena *arenas[2]; Arena *arenas[2];
U8 thread_name[32]; U8 thread_name[32];
U64 thread_name_size; U64 thread_name_size;
char *file_name; char *file_name;
U64 line_number; U64 line_number;
}; };
//////////////////////////////// ////////////////////////////////
// NOTE(allen): Thread Context Functions // NOTE(allen): Thread Context Functions
internal void tctx_init_and_equip(TCTX *tctx); internal void tctx_init_and_equip(TCTX *tctx);
internal TCTX* tctx_get_equipped(void); internal void tctx_release(void);
internal TCTX* tctx_get_equipped(void);
internal Arena* tctx_get_scratch(Arena **conflicts, U64 count);
internal Arena* tctx_get_scratch(Arena **conflicts, U64 countt);
internal void tctx_set_thread_name(String8 name);
internal String8 tctx_get_thread_name(void); internal void tctx_set_thread_name(String8 name);
internal String8 tctx_get_thread_name(void);
internal void tctx_write_srcloc(char *file_name, U64 line_number);
internal void tctx_read_srcloc(char **file_name, U64 *line_number); internal void tctx_write_srcloc(char *file_name, U64 line_number);
#define tctx_write_this_srcloc() tctx_write_srcloc(__FILE__, __LINE__) internal void tctx_read_srcloc(char **file_name, U64 *line_number);
#define tctx_write_this_srcloc() tctx_write_srcloc(__FILE__, __LINE__)
#define scratch_begin(conflicts, count) temp_begin(tctx_get_scratch((conflicts), (count)))
#define scratch_end(scratch) temp_end(scratch) #define scratch_begin(conflicts, count) temp_begin(tctx_get_scratch((conflicts), (count)))
#define scratch_end(scratch) temp_end(scratch)
#endif //BASE_THREAD_CONTEXT_H
#endif // BASE_THREAD_CONTEXT_H
+649
View File
@@ -0,0 +1,649 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ Generated Code
#include "generated/codeview.meta.c"
////////////////////////////////
//~ CodeView Common Decoding Helper Functions
internal U64
cv_hash_from_string(String8 string)
{
U64 result = 5381;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
}
return result;
}
internal U64
cv_hash_from_item_id(CV_ItemId item_id)
{
U64 result = cv_hash_from_string(str8_struct(&item_id));
return result;
}
internal CV_NumericParsed
cv_numeric_from_data_range(U8 *first, U8 *opl)
{
CV_NumericParsed result = {0};
if(first + 2 <= opl)
{
U16 x = *(U16*)first;
if(x < 0x8000)
{
result.kind = CV_NumericKind_USHORT;
result.val = first;
result.encoded_size = 2;
}
else
{
U64 val_size = 0;
switch(x)
{
case CV_NumericKind_CHAR: val_size = 1; break;
case CV_NumericKind_SHORT:
case CV_NumericKind_USHORT: val_size = 2; break;
case CV_NumericKind_LONG:
case CV_NumericKind_ULONG: val_size = 4; break;
case CV_NumericKind_FLOAT32: val_size = 4; break;
case CV_NumericKind_FLOAT64: val_size = 8; break;
case CV_NumericKind_FLOAT80: val_size = 10; break;
case CV_NumericKind_FLOAT128: val_size = 16; break;
case CV_NumericKind_QUADWORD:
case CV_NumericKind_UQUADWORD: val_size = 8; break;
case CV_NumericKind_FLOAT48: val_size = 6; break;
case CV_NumericKind_COMPLEX32: val_size = 8; break;
case CV_NumericKind_COMPLEX64: val_size = 16; break;
case CV_NumericKind_COMPLEX80: val_size = 20; break;
case CV_NumericKind_COMPLEX128:val_size = 32; break;
case CV_NumericKind_VARSTRING: val_size = 0; break; // TODO: ???
case CV_NumericKind_OCTWORD:
case CV_NumericKind_UOCTWORD: val_size = 16; break;
case CV_NumericKind_DECIMAL: val_size = 0; break; // TODO: ???
case CV_NumericKind_DATE: val_size = 0; break; // TODO: ???
case CV_NumericKind_UTF8STRING:val_size = 0; break; // TODO: ???
case CV_NumericKind_FLOAT16: val_size = 2; break;
}
if(first + 2 + val_size <= opl)
{
result.kind = x;
result.val = (first + 2);
result.encoded_size = 2 + val_size;
}
}
}
return result;
}
internal U64
cv_read_numeric(String8 data, U64 offset, CV_NumericParsed *out)
{
*out = cv_numeric_from_data_range(data.str + offset, data.str + data.size);
return out->encoded_size;
}
internal B32
cv_numeric_fits_in_u64(CV_NumericParsed *num)
{
B32 result = 0;
switch(num->kind)
{
case CV_NumericKind_USHORT:
case CV_NumericKind_ULONG:
case CV_NumericKind_UQUADWORD:
{
result = 1;
}break;
}
return result;
}
internal B32
cv_numeric_fits_in_s64(CV_NumericParsed *num)
{
B32 result = 0;
switch(num->kind)
{
case CV_NumericKind_CHAR:
case CV_NumericKind_SHORT:
case CV_NumericKind_LONG:
case CV_NumericKind_QUADWORD:
{
result = 1;
}break;
}
return result;
}
internal B32
cv_numeric_fits_in_f64(CV_NumericParsed *num)
{
B32 result = 0;
switch(num->kind)
{
case CV_NumericKind_FLOAT32:
case CV_NumericKind_FLOAT64:
{
result = 1;
}break;
}
return result;
}
internal U64
cv_u64_from_numeric(CV_NumericParsed *num)
{
U64 result = 0;
switch(num->kind)
{
case CV_NumericKind_USHORT: {result = *(U16*)num->val;}break;
case CV_NumericKind_ULONG: {result = *(U32*)num->val;}break;
case CV_NumericKind_UQUADWORD:{result = *(U64*)num->val;}break;
}
return result;
}
internal S64
cv_s64_from_numeric(CV_NumericParsed *num)
{
S64 result = 0;
switch(num->kind)
{
case CV_NumericKind_CHAR: {result = *(S8*)num->val;}break;
case CV_NumericKind_SHORT: {result = *(S16*)num->val;}break;
case CV_NumericKind_LONG: {result = *(S32*)num->val;}break;
case CV_NumericKind_QUADWORD: {result = *(S64*)num->val;}break;
}
return(result);
}
internal F64
cv_f64_from_numeric(CV_NumericParsed *num)
{
F64 result = 0;
switch(num->kind)
{
case CV_NumericKind_FLOAT32:{result = *(F32*)num->val;}break;
case CV_NumericKind_FLOAT64:{result = *(F64*)num->val;}break;
}
return(result);
}
internal U64
cv_decode_inline_annot_u32(String8 data, U64 offset, U32 *out_value)
{
U64 cursor = offset;
// rjf: read header
U8 header = 0;
cursor += str8_deserial_read_struct(data, cursor, &header);
// rjf: decode value
U32 value = 0;
{
// 1 byte
if((header & 0x80) == 0)
{
value = header;
}
// 2 bytes
else if((header & 0xC0) == 0x80 && cursor+1 <= data.size)
{
U8 second_byte;
cursor += str8_deserial_read_struct(data, cursor, &second_byte);
value = ((header & 0x3F) << 8) | second_byte;
}
// 4 bytes
else if((header & 0xE0) == 0xC0 && cursor+3 <= data.size)
{
U8 second_byte, third_byte, fourth_byte;
cursor += str8_deserial_read_struct(data, cursor, &second_byte);
cursor += str8_deserial_read_struct(data, cursor, &third_byte);
cursor += str8_deserial_read_struct(data, cursor, &fourth_byte);
value = (((U32)header & 0x1F) << 24) | ((U32)second_byte << 16) | ((U32)third_byte << 8) | (U32)fourth_byte;
}
// bad encode
else if((header & 0xE0) == 0xE0)
{
value = max_U32;
}
}
// rjf: output results
if(out_value)
{
*out_value = value;
}
U64 read_size = cursor - offset;
return read_size;
}
internal U64
cv_decode_inline_annot_s32(String8 data, U64 offset, S32 *out_value)
{
U32 value;
U64 read_size = cv_decode_inline_annot_u32(data, offset, &value);
if(value & 1)
{
value = -(value >> 1);
}
else
{
value = value >> 1;
}
*out_value = (S32)value;
return read_size;
}
internal S32
cv_inline_annot_signed_from_unsigned_operand(U32 value)
{
if(value & 1)
{
value = -(value >> 1);
}
else
{
value = value >> 1;
}
S32 result = (S32)value;
return result;
}
////////////////////////////////
//~ CodeView Parsing Functions
//- rjf: record range stream parsing
internal CV_RecRangeStream*
cv_rec_range_stream_from_data(Arena *arena, String8 sym_data, U64 sym_align)
{
Assert(1 <= sym_align && IsPow2OrZero(sym_align));
CV_RecRangeStream *result = push_array(arena, CV_RecRangeStream, 1);
U8 *data = sym_data.str;
U64 cursor = 0;
U64 cap = sym_data.size;
for(;cursor + sizeof(CV_RecHeader) <= cap;)
{
// setup a new chunk
CV_RecRangeChunk *cur_chunk = push_array_aligned(arena, CV_RecRangeChunk, 1, 64);
SLLQueuePush(result->first_chunk, result->last_chunk, cur_chunk);
U64 partial_count = 0;
for(;partial_count < CV_REC_RANGE_CHUNK_SIZE && cursor + sizeof(CV_RecHeader) <= cap; partial_count += 1)
{
// compute cap
CV_RecHeader *hdr = (CV_RecHeader*)(data + cursor);
U64 symbol_cap_unclamped = cursor + 2 + hdr->size;
U64 symbol_cap = ClampTop(symbol_cap_unclamped, cap);
// push on range
cur_chunk->ranges[partial_count].off = cursor + 2;
cur_chunk->ranges[partial_count].hdr = *hdr;
// update cursor
U32 next_pos = AlignPow2(symbol_cap, sym_align);
cursor = next_pos;
}
result->total_count += partial_count;
}
return result;
}
internal CV_RecRangeArray
cv_rec_range_array_from_stream(Arena *arena, CV_RecRangeStream *stream)
{
U64 total_count = stream->total_count;
CV_RecRange *ranges = push_array_no_zero_aligned(arena, CV_RecRange, total_count, 8);
U64 idx = 0;
for(CV_RecRangeChunk *chunk = stream->first_chunk; chunk != 0; chunk = chunk->next)
{
U64 copy_count_raw = total_count - idx;
U64 copy_count = ClampTop(copy_count_raw, CV_REC_RANGE_CHUNK_SIZE);
MemoryCopy(ranges + idx, chunk->ranges, copy_count*sizeof(CV_RecRange));
idx += copy_count;
}
CV_RecRangeArray result = {0};
result.ranges = ranges;
result.count = total_count;
return result;
}
//- rjf: sym stream parsing
internal CV_SymParsed *
cv_sym_from_data(Arena *arena, String8 sym_data, U64 sym_align)
{
Assert(1 <= sym_align && IsPow2OrZero(sym_align));
ProfBeginFunction();
Temp scratch = scratch_begin(&arena, 1);
//- rjf: gather symbols
CV_RecRangeStream *stream = cv_rec_range_stream_from_data(scratch.arena, sym_data, sym_align);
//- rjf: convert to result, fill basics
CV_SymParsed *result = push_array(arena, CV_SymParsed, 1);
result->data = sym_data;
result->sym_align = sym_align;
result->sym_ranges = cv_rec_range_array_from_stream(arena, stream);
//- rjf: extract top-level-info
{
CV_RecRange *range = result->sym_ranges.ranges;
CV_RecRange *opl = range + result->sym_ranges.count;
for(;range < opl; range += 1)
{
U8 *first = sym_data.str + range->off + 2;
U64 cap = range->hdr.size - 2;
switch(range->hdr.kind)
{
case CV_SymKind_COMPILE:
if(sizeof(CV_SymCompile) <= cap)
{
CV_SymCompile *compile = (CV_SymCompile*)first;
String8 ver_str = str8_cstring_capped((char*)(compile + 1), (char *)(first + cap));
result->info.arch = compile->machine;
result->info.language = CV_CompileFlags_ExtractLanguage(compile->flags);;
result->info.compiler_name = ver_str;
}break;
case CV_SymKind_COMPILE2:
if(sizeof(CV_SymCompile2) <= cap)
{
CV_SymCompile2 *compile2 = (CV_SymCompile2*)first;
String8 ver_str = str8_cstring_capped((char*)(compile2 + 1), (char*)(first + cap));
String8 compiler_name = push_str8f(arena, "%.*s %u.%u.%u",
str8_varg(ver_str),
compile2->ver_major,
compile2->ver_minor,
compile2->ver_build);
result->info.arch = compile2->machine;
result->info.language = CV_Compile2Flags_ExtractLanguage(compile2->flags);;
result->info.compiler_name = compiler_name;
}break;
case CV_SymKind_COMPILE3:
if(sizeof(CV_SymCompile3) <= cap)
{
CV_SymCompile3 *compile3 = (CV_SymCompile3*)first;
String8 ver_str = str8_cstring_capped((char*)(compile3 + 1), (char *)(first + cap));
String8 compiler_name = push_str8f(arena, "%.*s %u.%u.%u",
str8_varg(ver_str),
compile3->ver_major,
compile3->ver_minor,
compile3->ver_build);
result->info.arch = compile3->machine;
result->info.language = CV_Compile3Flags_ExtractLanguage(compile3->flags);;
result->info.compiler_name = compiler_name;
}break;
}
}
}
scratch_end(scratch);
ProfEnd();
return result;
}
//- rjf: leaf stream parsing
internal CV_LeafParsed *
cv_leaf_from_data(Arena *arena, String8 leaf_data, CV_TypeId itype_first)
{
ProfBeginFunction();
Temp scratch = scratch_begin(&arena, 1);
// gather up symbols
CV_RecRangeStream *stream = cv_rec_range_stream_from_data(scratch.arena, leaf_data, 1);
// convert to result
CV_LeafParsed *result = push_array(arena, CV_LeafParsed, 1);
result->data = leaf_data;
result->itype_first = itype_first;
result->itype_opl = itype_first + stream->total_count;
result->leaf_ranges = cv_rec_range_array_from_stream(arena, stream);
scratch_end(scratch);
ProfEnd();
return result;
}
////////////////////////////////
//~ CodeView C13 Parser Functions
internal CV_C13Parsed *
cv_c13_parsed_from_data(Arena *arena, String8 c13_data, String8 strtbl, COFF_SectionHeaderArray sections)
{
ProfBeginFunction();
//////////////////////////////
//- rjf: gather c13 sub-sections
//
CV_C13SubSectionNode *file_chksms = 0;
CV_C13SubSectionNode *first = 0;
CV_C13SubSectionNode *last = 0;
U64 count = 0;
{
U32 cursor = 0;
for(; cursor + sizeof(CV_C13SubSectionHeader) <= c13_data.size;)
{
// read header
CV_C13SubSectionHeader *hdr = (CV_C13SubSectionHeader*)(c13_data.str + cursor);
// get sub section info
U32 sub_section_off = cursor + sizeof(*hdr);
U32 sub_section_size_raw = hdr->size;
U32 after_sub_section_off_unclamped = sub_section_off + sub_section_size_raw;
U32 after_sub_section_off = ClampTop(after_sub_section_off_unclamped, c13_data.size);
U32 sub_section_size = after_sub_section_off - sub_section_off;
// emit sub section
if(!(hdr->kind & CV_C13SubSectionKind_IgnoreFlag))
{
CV_C13SubSectionNode *node = push_array(arena, CV_C13SubSectionNode, 1);
SLLQueuePush(first, last, node);
count += 1;
node->kind = hdr->kind;
node->off = sub_section_off;
node->size = sub_section_size;
if(hdr->kind == CV_C13SubSectionKind_FileChksms)
{
file_chksms = node;
}
}
// move cursor
cursor = AlignPow2(after_sub_section_off, 4);
}
}
//////////////////////////////
//- rjf: parse each sub-section
//
U64 inlinee_lines_parsed_slots_count = 4096;
CV_C13InlineeLinesParsedNode **inlinee_lines_parsed_slots = push_array(arena, CV_C13InlineeLinesParsedNode *, inlinee_lines_parsed_slots_count);
for(CV_C13SubSectionNode *node = first;
node != 0;
node = node->next)
{
U8 *first = c13_data.str + node->off;
U32 cap = node->size;
switch(node->kind)
{
default:{}break;
//////////////////////////
//- rjf: line info sub-section
//
case CV_C13SubSectionKind_Lines:
if(sizeof(CV_C13SubSecLinesHeader) <= cap)
{
// read header
U32 read_off = 0;
U64 read_off_opl = node->size;
CV_C13SubSecLinesHeader *hdr = (CV_C13SubSecLinesHeader*)(first + read_off);
read_off += sizeof(*hdr);
// rjf: extract section index
U32 sec_idx = hdr->sec;
// rjf: bad section index -> skip
if(sec_idx < 1 || sections.count < sec_idx)
{
continue;
}
// extract top level info
B32 has_cols = !!(hdr->flags & CV_C13SubSecLinesFlag_HasColumns);
U64 secrel_off = hdr->sec_off;
U64 secrel_opl = secrel_off + hdr->len;
U64 sec_base_off = sections.v[sec_idx - 1].voff;
// read files
for(;read_off+sizeof(CV_C13File) <= read_off_opl;)
{
// rjf: grab next file header
CV_C13File *file = (CV_C13File*)(first + read_off);
U32 file_off = file->file_off;
U32 line_count_unclamped = file->num_lines;
U32 block_size = file->block_size;
// file_name from file_off
String8 file_name = {0};
if(file_off + sizeof(CV_C13Checksum) <= file_chksms->size)
{
CV_C13Checksum *checksum = (CV_C13Checksum*)(c13_data.str + file_chksms->off + file_off);
U32 name_off = checksum->name_off;
file_name = str8_cstring_capped((char*)(strtbl.str + name_off),
(char*)(strtbl.str + strtbl.size));
}
// array layouts
U32 line_item_size = sizeof(CV_C13Line);
if (has_cols){
line_item_size += sizeof(CV_C13Column);
}
U32 line_array_off = read_off + sizeof(*file);
U32 line_count_max = (read_off_opl - line_array_off) / line_item_size;
U32 line_count = ClampTop(line_count_unclamped, line_count_max);
U32 col_array_off = line_array_off + line_count*sizeof(CV_C13Line);
// parse lines
U64 *voffs = push_array_no_zero(arena, U64, line_count + 1);
U32 *line_nums = push_array_no_zero(arena, U32, line_count);
{
CV_C13Line *line_ptr = (CV_C13Line*)(first + line_array_off);
CV_C13Line *line_opl = line_ptr + line_count;
// TODO(allen): check order correctness here
U32 i = 0;
for (; line_ptr < line_opl; line_ptr += 1, i += 1){
voffs[i] = line_ptr->off + secrel_off + sec_base_off;
line_nums[i] = CV_C13LineFlags_ExtractLineNumber(line_ptr->flags);
}
voffs[i] = secrel_opl + sec_base_off;
}
// emit parsed lines
CV_C13LinesParsedNode *lines_parsed_node = push_array(arena, CV_C13LinesParsedNode, 1);
CV_C13LinesParsed *lines_parsed = &lines_parsed_node->v;
lines_parsed->sec_idx = sec_idx;
lines_parsed->file_off = file_off;
lines_parsed->secrel_base_off = secrel_off;
lines_parsed->file_name = file_name;
lines_parsed->voffs = voffs;
lines_parsed->line_nums = line_nums;
lines_parsed->line_count = line_count;
SLLQueuePush(node->lines_first, node->lines_last, lines_parsed_node);
// rjf: advance
read_off += sizeof(*file);
read_off += line_item_size*line_count;
}
}break;
//////////////////////////
//- rjf: inlinee line info sub-section
//
case CV_C13SubSectionKind_InlineeLines:
if(sizeof(CV_C13InlineeLinesSig) <= cap)
{
// rjf: read sig
U32 read_off = 0;
U64 read_off_opl = node->size;
CV_C13InlineeLinesSig *sig = (CV_C13InlineeLinesSig *)(first + read_off);
read_off += sizeof(*sig);
// rjf: read source lines
for(;read_off + sizeof(CV_C13InlineeSourceLineHeader) <= read_off_opl;)
{
// rjf: read next header
CV_C13InlineeSourceLineHeader *hdr = (CV_C13InlineeSourceLineHeader *)(first + read_off);
read_off += sizeof(*hdr);
// rjf: file_off -> file_name
String8 file_name = {0};
if(hdr->file_off + sizeof(CV_C13Checksum) <= file_chksms->size)
{
CV_C13Checksum *checksum = (CV_C13Checksum*)(c13_data.str + file_chksms->off + hdr->file_off);
U32 name_off = checksum->name_off;
file_name = str8_cstring_capped((char*)(strtbl.str + name_off),
(char*)(strtbl.str + strtbl.size));
}
// rjf: parse extra files
U32 extra_file_count = 0;
U32 *extra_files = 0;
if(*sig == CV_C13InlineeLinesSig_EXTRA_FILES && read_off+sizeof(U32) <= read_off_opl)
{
U32 *extra_file_count_ptr = (U32 *)(first + read_off);
read_off += sizeof(*extra_file_count_ptr);
U32 max_extra_file_count = (read_off_opl-read_off)/sizeof(U32);
extra_file_count = Min(*extra_file_count_ptr, max_extra_file_count);
extra_files = (U32 *)(first + read_off);
read_off += sizeof(*extra_files)*extra_file_count;
}
// rjf: push node for this inlinee lines parsed into this subsection's list
CV_C13InlineeLinesParsedNode *n = push_array(arena, CV_C13InlineeLinesParsedNode, 1);
SLLQueuePush(node->inlinee_lines_first, node->inlinee_lines_last, n);
n->v.inlinee = hdr->inlinee;
n->v.file_name = file_name;
n->v.file_off = hdr->file_off;
n->v.first_source_ln = hdr->first_source_ln;
n->v.extra_file_count = extra_file_count;
n->v.extra_files = extra_files;
// rjf: push node into inlinee parse hash table
U64 hash = cv_hash_from_item_id(hdr->inlinee);
U64 slot_idx = hash%inlinee_lines_parsed_slots_count;
SLLStackPush_N(inlinee_lines_parsed_slots[slot_idx], n, hash_next);
}
}break;
}
}
//////////////////////////////
//- rjf: fill output
//
CV_C13Parsed *result = push_array(arena, CV_C13Parsed, 1);
result->data = c13_data;
result->first_sub_section = first;
result->last_sub_section = last;
result->sub_section_count = count;
result->file_chksms_sub_section = file_chksms;
result->inlinee_lines_parsed_slots = inlinee_lines_parsed_slots;
result->inlinee_lines_parsed_slots_count = inlinee_lines_parsed_slots_count;
ProfEnd();
return result;
}
File diff suppressed because it is too large. Load diff
+630
View File
@@ -0,0 +1,630 @@
////////////////////////////////
//~ rjf: CV Numerics
@table(name val)
CV_NumericKindTable:
{
{CHAR 0x8000}
{SHORT 0x8001}
{USHORT 0x8002}
{LONG 0x8003}
{ULONG 0x8004}
{FLOAT32 0x8005}
{FLOAT64 0x8006}
{FLOAT80 0x8007}
{FLOAT128 0x8008}
{QUADWORD 0x8009}
{UQUADWORD 0x800a}
{FLOAT48 0x800b}
{COMPLEX32 0x800c}
{COMPLEX64 0x800d}
{COMPLEX80 0x800e}
{COMPLEX128 0x800f}
{VARSTRING 0x8010}
{OCTWORD 0x8017}
{UOCTWORD 0x8018}
{DECIMAL 0x8019}
{DATE 0x801a}
{UTF8STRING 0x801b}
{FLOAT16 0x801c}
}
@enum(U16) CV_NumericKind:
{
@expand(CV_NumericKindTable a) `$(a.name) = $(a.val)`
}
@enum2string_switch(CV_NumericKind)
cv_string_from_numeric_kind:
{
@expand(CV_NumericKindTable a) `case CV_NumericKind_$(a.name):{result = str8_lit("$(a.name)");}break`;
}
////////////////////////////////
//~ rjf: CV Architectures
@table(name val)
CV_ArchTable:
{
{8080 0x00}
{8086 0x01}
{80286 0x02}
{80386 0x03}
{80486 0x04}
{PENTIUM 0x05}
{PENTIUMII 0x06}
{PENTIUMIII 0x07}
{MIPS 0x10}
{MIPS16 0x11}
{MIPS32 0x12}
{MIPS64 0x13}
{MIPSI 0x14}
{MIPSII 0x15}
{MIPSIII 0x16}
{MIPSIV 0x17}
{MIPSV 0x18}
{M68000 0x20}
{M68010 0x21}
{M68020 0x22}
{M68030 0x23}
{M68040 0x24}
{ALPHA 0x30}
{ALPHA_21164 0x31}
{ALPHA_21164A 0x32}
{ALPHA_21264 0x33}
{ALPHA_21364 0x34}
{PPC601 0x40}
{PPC603 0x41}
{PPC604 0x42}
{PPC620 0x43}
{PPCFP 0x44}
{PPCBE 0x45}
{SH3 0x50}
{SH3E 0x51}
{SH3DSP 0x52}
{SH4 0x53}
{SHMEDIA 0x54}
{ARM3 0x60}
{ARM4 0x61}
{ARM4T 0x62}
{ARM5 0x63}
{ARM5T 0x64}
{ARM6 0x65}
{ARM_XMAC 0x66}
{ARM_WMMX 0x67}
{ARM7 0x68}
{OMNI 0x70}
{IA64_1 0x80}
{IA64_2 0x81}
{CEE 0x90}
{AM33 0xA0}
{M32R 0xB0}
{TRICORE 0xC0}
{X64 0xD0}
{EBC 0xE0}
{THUMB 0xF0}
{ARMNT 0xF4}
{ARM64 0xF6}
{D3D11_SHADER 0x100}
}
@enum(U16) CV_Arch:
{
@expand(CV_ArchTable a) `$(a.name) = $(a.val)`,
`IA64 = CV_Arch_IA64_1`,
`PENTIUMPRO = CV_Arch_PENTIUMII`,
`MIPSR4000 = CV_Arch_MIPS`,
`ALPHA_21064 = CV_Arch_ALPHA`,
`AMD64 = CV_Arch_X64`,
}
@enum2string_switch(CV_Arch)
cv_string_from_arch:
{
@expand(CV_ArchTable a) `case CV_Arch_$(a.name):{result = str8_lit("$(a.name)");}break`;
}
////////////////////////////////
//~ rjf: CV Registers
@table(name val) CV_AllRegTable:
{
{ERR 30000}
{TEB 30001}
{TIMER 30002}
{EFAD1 30003}
{EFAD2 30004}
{EFAD3 30005}
{VFRAME 30006}
{HANDLE 30007}
{PARAMS 30008}
{LOCALS 30009}
{TID 30010}
{ENV 30011}
{CMDLN 30012}
}
@enum(U16) CV_AllReg:
{
@expand(CV_AllRegTable a) `$(a.name) = $(a.val)`
}
////////////////////////////////
//~ rjf: CV Sym Kinds
@table(name header_type_name val) CV_SymKindTable:
{
{COMPILE Compile 0x0001}
{REGISTER_16t - 0x0002}
{CONSTANT_16t - 0x0003}
{UDT_16t - 0x0004}
{SSEARCH StartSearch 0x0005}
{END - 0x0006}
{SKIP - 0x0007}
{CVRESERVE - 0x0008}
{OBJNAME_ST - 0x0009}
{ENDARG - 0x000a}
{COBOLUDT_16t - 0x000b}
{MANYREG_16t - 0x000c}
{RETURN Return 0x000d}
{ENTRYTHIS - 0x000e}
{BPREL16 - 0x0100}
{LDATA16 - 0x0101}
{GDATA16 - 0x0102}
{PUB16 - 0x0103}
{LPROC16 - 0x0104}
{GPROC16 - 0x0105}
{THUNK16 - 0x0106}
{BLOCK16 - 0x0107}
{WITH16 - 0x0108}
{LABEL16 - 0x0109}
{CEXMODEL16 - 0x010a}
{VFTABLE16 - 0x010b}
{REGREL16 - 0x010c}
{BPREL32_16t - 0x0200}
{LDATA32_16t - 0x0201}
{GDATA32_16t - 0x0202}
{PUB32_16t - 0x0203}
{LPROC32_16t - 0x0204}
{GPROC32_16t - 0x0205}
{THUNK32_ST - 0x0206}
{BLOCK32_ST - 0x0207}
{WITH32_ST - 0x0208}
{LABEL32_ST - 0x0209}
{CEXMODEL32 - 0x020a}
{VFTABLE32_16t - 0x020b}
{REGREL32_16t - 0x020c}
{LTHREAD32_16t - 0x020d}
{GTHREAD32_16t - 0x020e}
{SLINK32 SLink32 0x020f}
{LPROCMIPS_16t - 0x0300}
{GPROCMIPS_16t - 0x0301}
{PROCREF_ST - 0x0400}
{DATAREF_ST - 0x0401}
{ALIGN - 0x0402}
{LPROCREF_ST - 0x0403}
{OEM OEM 0x0404}
{TI16_MAX - 0x1000}
{CONSTANT_ST - 0x1002}
{UDT_ST - 0x1003}
{COBOLUDT_ST - 0x1004}
{MANYREG_ST - 0x1005}
{BPREL32_ST - 0x1006}
{LDATA32_ST - 0x1007}
{GDATA32_ST - 0x1008}
{PUB32_ST - 0x1009}
{LPROC32_ST - 0x100a}
{GPROC32_ST - 0x100b}
{VFTABLE32 VPath32 0x100c}
{REGREL32_ST - 0x100d}
{LTHREAD32_ST - 0x100e}
{GTHREAD32_ST - 0x100f}
{LPROCMIPS_ST - 0x1010}
{GPROCMIPS_ST - 0x1011}
{FRAMEPROC Frameproc 0x1012}
{COMPILE2_ST - 0x1013}
{MANYREG2_ST - 0x1014}
{LPROCIA64_ST - 0x1015}
{GPROCIA64_ST - 0x1016}
{LOCALSLOT_ST - 0x1017}
{PARAMSLOT_ST - 0x1018}
{ANNOTATION Annotation 0x1019}
{GMANPROC_ST - 0x101a}
{LMANPROC_ST - 0x101b}
{RESERVED1 - 0x101c}
{RESERVED2 - 0x101d}
{RESERVED3 - 0x101e}
{RESERVED4 - 0x101f}
{LMANDATA_ST - 0x1020}
{GMANDATA_ST - 0x1021}
{MANFRAMEREL_ST - 0x1022}
{MANREGISTER_ST - 0x1023}
{MANSLOT_ST - 0x1024}
{MANMANYREG_ST - 0x1025}
{MANREGREL_ST - 0x1026}
{MANMANYREG2_ST - 0x1027}
{MANTYPREF - 0x1028}
{UNAMESPACE_ST - 0x1029}
{ST_MAX - 0x1100}
{OBJNAME ObjName 0x1101}
{THUNK32 Thunk32 0x1102}
{BLOCK32 Block32 0x1103}
{WITH32 - 0x1104}
{LABEL32 Label32 0x1105}
{REGISTER Register 0x1106}
{CONSTANT Constant 0x1107}
{UDT UDT 0x1108}
{COBOLUDT - 0x1109}
{MANYREG Manyreg 0x110a}
{BPREL32 BPRel32 0x110b}
{LDATA32 Data32 0x110c}
{GDATA32 Data32 0x110d}
{PUB32 Pub32 0x110e}
{LPROC32 Proc32 0x110f}
{GPROC32 Proc32 0x1110}
{REGREL32 Regrel32 0x1111}
{LTHREAD32 Thread32 0x1112}
{GTHREAD32 Thread32 0x1113}
{LPROCMIPS - 0x1114}
{GPROCMIPS - 0x1115}
{COMPILE2 Compile2 0x1116}
{MANYREG2 Manyreg2 0x1117}
{LPROCIA64 - 0x1118}
{GPROCIA64 - 0x1119}
{LOCALSLOT Slot 0x111a}
{PARAMSLOT - 0x111b}
{LMANDATA - 0x111c}
{GMANDATA - 0x111d}
{MANFRAMEREL AttrFrameRel 0x111e}
{MANREGISTER AttrReg 0x111f}
{MANSLOT - 0x1120}
{MANMANYREG AttrManyReg 0x1121}
{MANREGREL AttrRegRel 0x1122}
{MANMANYREG2 - 0x1123}
{UNAMESPACE UNamespace 0x1124}
{PROCREF Ref2 0x1125}
{DATAREF Ref2 0x1126}
{LPROCREF Ref2 0x1127}
{ANNOTATIONREF - 0x1128}
{TOKENREF - 0x1129}
{GMANPROC - 0x112a}
{LMANPROC - 0x112b}
{TRAMPOLINE Trampoline 0x112c}
{MANCONSTANT - 0x112d}
{ATTR_FRAMEREL AttrFrameRel 0x112e}
{ATTR_REGISTER AttrReg 0x112f}
{ATTR_REGREL AttrRegRel 0x1130}
{ATTR_MANYREG AttrManyReg 0x1131}
{SEPCODE Sepcode 0x1132}
{DEFRANGE_2005 - 0x1134}
{DEFRANGE2_2005 - 0x1135}
{SECTION Section 0x1136}
{COFFGROUP CoffGroup 0x1137}
{EXPORT Export 0x1138}
{CALLSITEINFO CallSiteInfo 0x1139}
{FRAMECOOKIE FrameCookie 0x113a}
{DISCARDED Discarded 0x113b}
{COMPILE3 Compile3 0x113c}
{ENVBLOCK EnvBlock 0x113d}
{LOCAL Local 0x113e}
{DEFRANGE - 0x113f}
{DEFRANGE_SUBFIELD DefrangeSubfield 0x1140}
{DEFRANGE_REGISTER DefrangeRegister 0x1141}
{DEFRANGE_FRAMEPOINTER_REL DefrangeFramepointerRel 0x1142}
{DEFRANGE_SUBFIELD_REGISTER DefrangeSubfieldRegister 0x1143}
{DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE DefrangeFramepointerRelFullScope 0x1144}
{DEFRANGE_REGISTER_REL DefrangeRegisterRel 0x1145}
{LPROC32_ID - 0x1146}
{GPROC32_ID - 0x1147}
{LPROCMIPS_ID - 0x1148}
{GPROCMIPS_ID - 0x1149}
{LPROCIA64_ID - 0x114a}
{GPROCIA64_ID - 0x114b}
{BUILDINFO BuildInfo 0x114c}
{INLINESITE InlineSite 0x114d}
{INLINESITE_END - 0x114e}
{PROC_ID_END - 0x114f}
{DEFRANGE_HLSL - 0x1150}
{GDATA_HLSL - 0x1151}
{LDATA_HLSL - 0x1152}
{FILESTATIC FileStatic 0x1153}
{LPROC32_DPC - 0x1155}
{LPROC32_DPC_ID - 0x1156}
{DEFRANGE_DPC_PTR_TAG - 0x1157}
{DPC_SYM_TAG_MAP - 0x1158}
{ARMSWITCHTABLE - 0x1159}
{CALLEES FunctionList 0x115a}
{CALLERS FunctionList 0x115b}
{POGODATA PogoInfo 0x115c}
{INLINESITE2 InlineSite2 0x115d}
{HEAPALLOCSITE HeapAllocSite 0x115e}
{MOD_TYPEREF ModTypeRef 0x115f}
{REF_MINIPDB RefMiniPdb 0x1160}
{PDBMAP - 0x1161}
{GDATA_HLSL32 - 0x1162}
{LDATA_HLSL32 - 0x1163}
{GDATA_HLSL32_EX - 0x1164}
{LDATA_HLSL32_EX - 0x1165}
{FASTLINK FastLink 0x1167}
{INLINEES Inlinees 0x1168}
}
@enum(U16) CV_SymKind:
{
@expand(CV_SymKindTable a) `$(a.name) = $(a.val)`
}
@enum2string_switch(CV_SymKind)
cv_string_from_sym_kind:
{
@expand(CV_SymKindTable a) `case CV_SymKind_$(a.name):{result = str8_lit("$(a.name)");}break`;
}
@gen(functions)
{
`internal U64 cv_header_struct_size_from_sym_kind(CV_SymKind v);`;
}
@gen(functions) @c_file
{
`internal U64`;
`cv_header_struct_size_from_sym_kind(CV_SymKind v)`;
`{`;
`U64 result = 0;`;
`switch(v)`;
`{`;
`default:{}break;`;
@expand(CV_SymKindTable a) `$(a.header_type_name != "-" -> "case CV_SymKind_"..a.name..":{result = sizeof(CV_Sym"..a.header_type_name..");}break;")`;
`}`;
`return result;`;
`}`;
}
////////////////////////////////
//~ rjf: CV Basic Types
@table(name val type_name)
CV_BasicTypeTable:
{
{NOTYPE 0x00 "" }
{ABS 0x01 "" }
{SEGMENT 0x02 "" }
{VOID 0x03 "void" }
{CURRENCY 0x04 "" }
{NBASICSTR 0x05 "" }
{FBASICSTR 0x06 "" }
{NOTTRANS 0x07 "" }
{HRESULT 0x08 "HRESULT" }
{CHAR 0x10 "char" }
{SHORT 0x11 "S16" }
{LONG 0x12 "S32" }
{QUAD 0x13 "S64" }
{OCT 0x14 "S128" }
{UCHAR 0x20 "UCHAR" }
{USHORT 0x21 "U16" }
{ULONG 0x22 "U32" }
{UQUAD 0x23 "U64" }
{UOCT 0x24 "U128" }
{BOOL8 0x30 "B8" }
{BOOL16 0x31 "B16" }
{BOOL32 0x32 "B32" }
{BOOL64 0x33 "B64" }
{FLOAT32 0x40 "F32" }
{FLOAT64 0x41 "F64" }
{FLOAT80 0x42 "F80" }
{FLOAT128 0x43 "F128" }
{FLOAT48 0x44 "F48" }
{FLOAT32PP 0x45 "F32PP" }
{FLOAT16 0x46 "F16" }
{COMPLEX32 0x50 "ComplexF32" }
{COMPLEX64 0x51 "ComplexF64" }
{COMPLEX80 0x52 "ComplexF80" }
{COMPLEX128 0x53 "ComplexF128" }
{BIT 0x60 "" }
{PASCHAR 0x61 "" }
{BOOL32FF 0x62 "B32FF" }
{INT8 0x68 "S8" }
{UINT8 0x69 "U8" }
{RCHAR 0x70 "char" }
{WCHAR 0x71 "WCHAR" }
{INT16 0x72 "S16" }
{UINT16 0x73 "U16" }
{INT32 0x74 "S32" }
{UINT32 0x75 "U32" }
{INT64 0x76 "S64" }
{UINT64 0x77 "U64" }
{INT128 0x78 "S128" }
{UINT128 0x79 "U128" }
{CHAR16 0x7a "CHAR16" }
{CHAR32 0x7b "CHAR32" }
{CHAR8 0x7c "char" }
{PTR 0xf0 "PTR" }
}
@enum(U8) CV_BasicType:
{
@expand(CV_BasicTypeTable a) `$(a.name) = $(a.val)`
}
@enum2string_switch(CV_BasicType) cv_string_from_basic_type:
{
@expand(CV_BasicTypeTable a) `case CV_BasicType_$(a.name):{result = str8_lit("$(a.name)");}break`
}
@enum2string_switch(CV_BasicType) cv_type_name_from_basic_type:
{
@expand(CV_BasicTypeTable a) `case CV_BasicType_$(a.name):{result = str8_lit("$(a.type_name)");}break`
}
////////////////////////////////
//~ rjf: CV Leaf Kinds
@table(name header_type_name val)
CV_LeafKindTable:
{
{NOTYPE - 0x0000}
{MODIFIER_16t - 0x0001}
{POINTER_16t - 0x0002}
{ARRAY_16t - 0x0003}
{CLASS_16t - 0x0004}
{STRUCTURE_16t - 0x0005}
{UNION_16t - 0x0006}
{ENUM_16t - 0x0007}
{PROCEDURE_16t - 0x0008}
{MFUNCTION_16t - 0x0009}
{VTSHAPE VTShape 0x000a}
{COBOL0_16t - 0x000b}
{COBOL1 - 0x000c}
{BARRAY_16t - 0x000d}
{LABEL Label 0x000e}
{NULL - 0x000f}
{NOTTRAN - 0x0010}
{DIMARRAY_16t - 0x0011}
{VFTPATH_16t - 0x0012}
{PRECOMP_16t - 0x0013}
{ENDPRECOMP - 0x0014}
{OEM_16t - 0x0015}
{TYPESERVER_ST - 0x0016}
{SKIP_16t - 0x0200}
{ARGLIST_16t - 0x0201}
{DEFARG_16t - 0x0202}
{LIST - 0x0203}
{FIELDLIST_16t - 0x0204}
{DERIVED_16t - 0x0205}
{BITFIELD_16t - 0x0206}
{METHODLIST_16t - 0x0207}
{DIMCONU_16t - 0x0208}
{DIMCONLU_16t - 0x0209}
{DIMVARU_16t - 0x020a}
{DIMVARLU_16t - 0x020b}
{REFSYM - 0x020c}
{BCLASS_16t - 0x0400}
{VBCLASS_16t - 0x0401}
{IVBCLASS_16t - 0x0402}
{ENUMERATE_ST - 0x0403}
{FRIENDFCN_16t - 0x0404}
{INDEX_16t - 0x0405}
{MEMBER_16t - 0x0406}
{STMEMBER_16t - 0x0407}
{METHOD_16t - 0x0408}
{NESTTYPE_16t - 0x0409}
{VFUNCTAB_16t - 0x040a}
{FRIENDCLS_16t - 0x040b}
{ONEMETHOD_16t - 0x040c}
{VFUNCOFF_16t - 0x040d}
{TI16_MAX - 0x1000}
{MODIFIER Modifier 0x1001}
{POINTER Pointer 0x1002}
{ARRAY_ST - 0x1003}
{CLASS_ST - 0x1004}
{STRUCTURE_ST - 0x1005}
{UNION_ST - 0x1006}
{ENUM_ST - 0x1007}
{PROCEDURE Procedure 0x1008}
{MFUNCTION MFunction 0x1009}
{COBOL0 - 0x100a}
{BARRAY - 0x100b}
{DIMARRAY_ST - 0x100c}
{VFTPATH VFPath 0x100d}
{PRECOMP_ST - 0x100e}
{OEM - 0x100f}
{ALIAS_ST - 0x1010}
{OEM2 - 0x1011}
{SKIP Skip 0x1200}
{ARGLIST ArgList 0x1201}
{DEFARG_ST - 0x1202}
{FIELDLIST - 0x1203}
{DERIVED - 0x1204}
{BITFIELD BitField 0x1205}
{METHODLIST MethodListMember 0x1206}
{DIMCONU - 0x1207}
{DIMCONLU - 0x1208}
{DIMVARU - 0x1209}
{DIMVARLU - 0x120a}
{BCLASS BClass 0x1400}
{VBCLASS VBClass 0x1401}
{IVBCLASS - 0x1402}
{FRIENDFCN_ST - 0x1403}
{INDEX Index 0x1404}
{MEMBER_ST - 0x1405}
{STMEMBER_ST - 0x1406}
{METHOD_ST - 0x1407}
{NESTTYPE_ST - 0x1408}
{VFUNCTAB VFuncTab 0x1409}
{FRIENDCLS - 0x140a}
{ONEMETHOD_ST - 0x140b}
{VFUNCOFF VFuncOff 0x140c}
{NESTTYPEEX_ST - 0x140d}
{MEMBERMODIFY_ST - 0x140e}
{MANAGED_ST - 0x140f}
{ST_MAX - 0x1500}
{TYPESERVER TypeServer 0x1501}
{ENUMERATE Enumerate 0x1502}
{ARRAY Array 0x1503}
{CLASS Struct 0x1504}
{STRUCTURE Struct 0x1505}
{UNION Union 0x1506}
{ENUM Enum 0x1507}
{DIMARRAY - 0x1508}
{PRECOMP PreComp 0x1509}
{ALIAS Alias 0x150a}
{DEFARG - 0x150b}
{FRIENDFCN - 0x150c}
{MEMBER Member 0x150d}
{STMEMBER StMember 0x150e}
{METHOD Method 0x150f}
{NESTTYPE NestType 0x1510}
{ONEMETHOD OneMethod 0x1511}
{NESTTYPEEX NestTypeEx 0x1512}
{MEMBERMODIFY - 0x1513}
{MANAGED - 0x1514}
{TYPESERVER2 TypeServer2 0x1515}
{STRIDED_ARRAY - 0x1516}
{HLSL - 0x1517}
{MODIFIER_EX - 0x1518}
{INTERFACE Struct 0x1519}
{BINTERFACE - 0x151a}
{VECTOR - 0x151b}
{MATRIX - 0x151c}
{VFTABLE - 0x151d}
{FUNC_ID FuncId 0x1601}
{MFUNC_ID MFuncId 0x1602}
{BUILDINFO BuildInfo 0x1603}
{SUBSTR_LIST SubstrList 0x1604}
{STRING_ID StringId 0x1605}
{UDT_SRC_LINE UDTSrcLine 0x1606}
{UDT_MOD_SRC_LINE UDTModSrcLine 0x1607}
{CLASS2 Struct2 0x1608}
{STRUCT2 Struct2 0x1609}
}
@enum(U16) CV_LeafKind:
{
@expand(CV_LeafKindTable a) `$(a.name) = $(a.val)`;
}
@enum2string_switch(CV_LeafKind)
cv_string_from_leaf_kind:
{
@expand(CV_LeafKindTable a) `case CV_LeafKind_$(a.name):{result = str8_lit("$(a.name)");}break`;
}
@gen(functions)
{
`internal U64 cv_header_struct_size_from_leaf_kind(CV_LeafKind v);`;
}
@gen(functions) @c_file
{
`internal U64`;
`cv_header_struct_size_from_leaf_kind(CV_LeafKind v)`;
`{`;
`U64 result = 0;`;
`switch(v)`;
`{`;
`default:{}break;`;
@expand(CV_LeafKindTable a) `$(a.header_type_name != "-" -> "case CV_LeafKind_"..a.name..":{result = sizeof(CV_Leaf"..a.header_type_name..");}break;")`;
`}`;
`return result;`;
`}`;
}
File diff suppressed because it is too large. Load diff
+84
View File
@@ -0,0 +1,84 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CODEVIEW_STRINGIZE_H
#define CODEVIEW_STRINGIZE_H
////////////////////////////////
//~ CodeView Stringize Helper Types
typedef struct CV_StringizeSymParams{
CV_Arch arch;
} CV_StringizeSymParams;
typedef struct CV_StringizeLeafParams{
U32 dummy;
} CV_StringizeLeafParams;
////////////////////////////////
//~ CodeView Common Stringize Functions
internal void cv_stringize_numeric(Arena *arena, String8List *out, CV_NumericParsed *num);
internal void cv_stringize_lvar_addr_range(Arena *arena, String8List *out,
CV_LvarAddrRange *range);
internal void cv_stringize_lvar_addr_gap(Arena *arena, String8List *out, CV_LvarAddrGap *gap);
internal void cv_stringize_lvar_addr_gap_list(Arena *arena, String8List *out,
void *first, void *opl);
internal String8 cv_string_from_basic_type(CV_BasicType basic_type);
internal String8 cv_string_from_c13_sub_section_kind(CV_C13SubSectionKind kind);
internal String8 cv_string_from_reg(CV_Arch arch, CV_Reg reg);
internal String8 cv_string_from_pointer_kind(CV_PointerKind ptr_kind);
internal String8 cv_string_from_pointer_mode(CV_PointerMode ptr_mode);
internal String8 cv_string_from_hfa_kind(CV_HFAKind hfa_kind);
internal String8 cv_string_from_mo_com_udt_kind(CV_MoComUDTKind mo_com_udt_kind);
////////////////////////////////
//~ CodeView Flags Stringize Functions
internal void cv_stringize_modifier_flags(Arena *arena, String8List *out,
U32 indent, CV_ModifierFlags flags);
internal void cv_stringize_type_props(Arena *arena, String8List *out,
U32 indent, CV_TypeProps props);
internal void cv_stringize_pointer_attribs(Arena *arena, String8List *out,
U32 indent, CV_PointerAttribs attribs);
internal void cv_stringize_local_flags(Arena *arena, String8List *out,
U32 indent, CV_LocalFlags flags);
////////////////////////////////
//~ CodeView Sym Stringize Functions
internal void cv_stringize_sym_parsed(Arena *arena, String8List *out, CV_SymParsed *sym);
internal void cv_stringize_sym_range(Arena *arena, String8List *out,
CV_RecRange *range, String8 data,
CV_StringizeSymParams *p);
internal void cv_stringize_sym_array(Arena *arena, String8List *out,
CV_RecRangeArray *ranges, String8 data,
CV_StringizeSymParams *p);
////////////////////////////////
//~ CodeView Leaf Stringize Functions
internal void cv_stringize_leaf_parsed(Arena *arena, String8List *out, CV_LeafParsed *leaf);
internal void cv_stringize_leaf_range(Arena *arena, String8List *out,
CV_RecRange *range, CV_TypeId itype, String8 data,
CV_StringizeLeafParams *p);
internal void cv_stringize_leaf_array(Arena *arena, String8List *out,
CV_RecRangeArray *ranges, CV_TypeId itype_first,
String8 data,
CV_StringizeLeafParams *p);
////////////////////////////////
//~ CodeView C13 Stringize Functions
internal void cv_stringize_c13_parsed(Arena *arena, String8List *out, CV_C13Parsed *c13);
internal String8 cv_string_from_inline_range_kind(CV_InlineRangeKind kind);
#endif // CODEVIEW_STRINGIZE_H
+718
View File
@@ -0,0 +1,718 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
internal String8
cv_string_from_numeric_kind(CV_NumericKind v)
{
String8 result = str8_lit("<Unknown CV_NumericKind>");
switch(v)
{
default:{}break;
case CV_NumericKind_CHAR:{result = str8_lit("CHAR");}break;
case CV_NumericKind_SHORT:{result = str8_lit("SHORT");}break;
case CV_NumericKind_USHORT:{result = str8_lit("USHORT");}break;
case CV_NumericKind_LONG:{result = str8_lit("LONG");}break;
case CV_NumericKind_ULONG:{result = str8_lit("ULONG");}break;
case CV_NumericKind_FLOAT32:{result = str8_lit("FLOAT32");}break;
case CV_NumericKind_FLOAT64:{result = str8_lit("FLOAT64");}break;
case CV_NumericKind_FLOAT80:{result = str8_lit("FLOAT80");}break;
case CV_NumericKind_FLOAT128:{result = str8_lit("FLOAT128");}break;
case CV_NumericKind_QUADWORD:{result = str8_lit("QUADWORD");}break;
case CV_NumericKind_UQUADWORD:{result = str8_lit("UQUADWORD");}break;
case CV_NumericKind_FLOAT48:{result = str8_lit("FLOAT48");}break;
case CV_NumericKind_COMPLEX32:{result = str8_lit("COMPLEX32");}break;
case CV_NumericKind_COMPLEX64:{result = str8_lit("COMPLEX64");}break;
case CV_NumericKind_COMPLEX80:{result = str8_lit("COMPLEX80");}break;
case CV_NumericKind_COMPLEX128:{result = str8_lit("COMPLEX128");}break;
case CV_NumericKind_VARSTRING:{result = str8_lit("VARSTRING");}break;
case CV_NumericKind_OCTWORD:{result = str8_lit("OCTWORD");}break;
case CV_NumericKind_UOCTWORD:{result = str8_lit("UOCTWORD");}break;
case CV_NumericKind_DECIMAL:{result = str8_lit("DECIMAL");}break;
case CV_NumericKind_DATE:{result = str8_lit("DATE");}break;
case CV_NumericKind_UTF8STRING:{result = str8_lit("UTF8STRING");}break;
case CV_NumericKind_FLOAT16:{result = str8_lit("FLOAT16");}break;
}
return result;
}
internal String8
cv_string_from_arch(CV_Arch v)
{
String8 result = str8_lit("<Unknown CV_Arch>");
switch(v)
{
default:{}break;
case CV_Arch_8080:{result = str8_lit("8080");}break;
case CV_Arch_8086:{result = str8_lit("8086");}break;
case CV_Arch_80286:{result = str8_lit("80286");}break;
case CV_Arch_80386:{result = str8_lit("80386");}break;
case CV_Arch_80486:{result = str8_lit("80486");}break;
case CV_Arch_PENTIUM:{result = str8_lit("PENTIUM");}break;
case CV_Arch_PENTIUMII:{result = str8_lit("PENTIUMII");}break;
case CV_Arch_PENTIUMIII:{result = str8_lit("PENTIUMIII");}break;
case CV_Arch_MIPS:{result = str8_lit("MIPS");}break;
case CV_Arch_MIPS16:{result = str8_lit("MIPS16");}break;
case CV_Arch_MIPS32:{result = str8_lit("MIPS32");}break;
case CV_Arch_MIPS64:{result = str8_lit("MIPS64");}break;
case CV_Arch_MIPSI:{result = str8_lit("MIPSI");}break;
case CV_Arch_MIPSII:{result = str8_lit("MIPSII");}break;
case CV_Arch_MIPSIII:{result = str8_lit("MIPSIII");}break;
case CV_Arch_MIPSIV:{result = str8_lit("MIPSIV");}break;
case CV_Arch_MIPSV:{result = str8_lit("MIPSV");}break;
case CV_Arch_M68000:{result = str8_lit("M68000");}break;
case CV_Arch_M68010:{result = str8_lit("M68010");}break;
case CV_Arch_M68020:{result = str8_lit("M68020");}break;
case CV_Arch_M68030:{result = str8_lit("M68030");}break;
case CV_Arch_M68040:{result = str8_lit("M68040");}break;
case CV_Arch_ALPHA:{result = str8_lit("ALPHA");}break;
case CV_Arch_ALPHA_21164:{result = str8_lit("ALPHA_21164");}break;
case CV_Arch_ALPHA_21164A:{result = str8_lit("ALPHA_21164A");}break;
case CV_Arch_ALPHA_21264:{result = str8_lit("ALPHA_21264");}break;
case CV_Arch_ALPHA_21364:{result = str8_lit("ALPHA_21364");}break;
case CV_Arch_PPC601:{result = str8_lit("PPC601");}break;
case CV_Arch_PPC603:{result = str8_lit("PPC603");}break;
case CV_Arch_PPC604:{result = str8_lit("PPC604");}break;
case CV_Arch_PPC620:{result = str8_lit("PPC620");}break;
case CV_Arch_PPCFP:{result = str8_lit("PPCFP");}break;
case CV_Arch_PPCBE:{result = str8_lit("PPCBE");}break;
case CV_Arch_SH3:{result = str8_lit("SH3");}break;
case CV_Arch_SH3E:{result = str8_lit("SH3E");}break;
case CV_Arch_SH3DSP:{result = str8_lit("SH3DSP");}break;
case CV_Arch_SH4:{result = str8_lit("SH4");}break;
case CV_Arch_SHMEDIA:{result = str8_lit("SHMEDIA");}break;
case CV_Arch_ARM3:{result = str8_lit("ARM3");}break;
case CV_Arch_ARM4:{result = str8_lit("ARM4");}break;
case CV_Arch_ARM4T:{result = str8_lit("ARM4T");}break;
case CV_Arch_ARM5:{result = str8_lit("ARM5");}break;
case CV_Arch_ARM5T:{result = str8_lit("ARM5T");}break;
case CV_Arch_ARM6:{result = str8_lit("ARM6");}break;
case CV_Arch_ARM_XMAC:{result = str8_lit("ARM_XMAC");}break;
case CV_Arch_ARM_WMMX:{result = str8_lit("ARM_WMMX");}break;
case CV_Arch_ARM7:{result = str8_lit("ARM7");}break;
case CV_Arch_OMNI:{result = str8_lit("OMNI");}break;
case CV_Arch_IA64_1:{result = str8_lit("IA64_1");}break;
case CV_Arch_IA64_2:{result = str8_lit("IA64_2");}break;
case CV_Arch_CEE:{result = str8_lit("CEE");}break;
case CV_Arch_AM33:{result = str8_lit("AM33");}break;
case CV_Arch_M32R:{result = str8_lit("M32R");}break;
case CV_Arch_TRICORE:{result = str8_lit("TRICORE");}break;
case CV_Arch_X64:{result = str8_lit("X64");}break;
case CV_Arch_EBC:{result = str8_lit("EBC");}break;
case CV_Arch_THUMB:{result = str8_lit("THUMB");}break;
case CV_Arch_ARMNT:{result = str8_lit("ARMNT");}break;
case CV_Arch_ARM64:{result = str8_lit("ARM64");}break;
case CV_Arch_D3D11_SHADER:{result = str8_lit("D3D11_SHADER");}break;
}
return result;
}
internal String8
cv_string_from_sym_kind(CV_SymKind v)
{
String8 result = str8_lit("<Unknown CV_SymKind>");
switch(v)
{
default:{}break;
case CV_SymKind_COMPILE:{result = str8_lit("COMPILE");}break;
case CV_SymKind_REGISTER_16t:{result = str8_lit("REGISTER_16t");}break;
case CV_SymKind_CONSTANT_16t:{result = str8_lit("CONSTANT_16t");}break;
case CV_SymKind_UDT_16t:{result = str8_lit("UDT_16t");}break;
case CV_SymKind_SSEARCH:{result = str8_lit("SSEARCH");}break;
case CV_SymKind_END:{result = str8_lit("END");}break;
case CV_SymKind_SKIP:{result = str8_lit("SKIP");}break;
case CV_SymKind_CVRESERVE:{result = str8_lit("CVRESERVE");}break;
case CV_SymKind_OBJNAME_ST:{result = str8_lit("OBJNAME_ST");}break;
case CV_SymKind_ENDARG:{result = str8_lit("ENDARG");}break;
case CV_SymKind_COBOLUDT_16t:{result = str8_lit("COBOLUDT_16t");}break;
case CV_SymKind_MANYREG_16t:{result = str8_lit("MANYREG_16t");}break;
case CV_SymKind_RETURN:{result = str8_lit("RETURN");}break;
case CV_SymKind_ENTRYTHIS:{result = str8_lit("ENTRYTHIS");}break;
case CV_SymKind_BPREL16:{result = str8_lit("BPREL16");}break;
case CV_SymKind_LDATA16:{result = str8_lit("LDATA16");}break;
case CV_SymKind_GDATA16:{result = str8_lit("GDATA16");}break;
case CV_SymKind_PUB16:{result = str8_lit("PUB16");}break;
case CV_SymKind_LPROC16:{result = str8_lit("LPROC16");}break;
case CV_SymKind_GPROC16:{result = str8_lit("GPROC16");}break;
case CV_SymKind_THUNK16:{result = str8_lit("THUNK16");}break;
case CV_SymKind_BLOCK16:{result = str8_lit("BLOCK16");}break;
case CV_SymKind_WITH16:{result = str8_lit("WITH16");}break;
case CV_SymKind_LABEL16:{result = str8_lit("LABEL16");}break;
case CV_SymKind_CEXMODEL16:{result = str8_lit("CEXMODEL16");}break;
case CV_SymKind_VFTABLE16:{result = str8_lit("VFTABLE16");}break;
case CV_SymKind_REGREL16:{result = str8_lit("REGREL16");}break;
case CV_SymKind_BPREL32_16t:{result = str8_lit("BPREL32_16t");}break;
case CV_SymKind_LDATA32_16t:{result = str8_lit("LDATA32_16t");}break;
case CV_SymKind_GDATA32_16t:{result = str8_lit("GDATA32_16t");}break;
case CV_SymKind_PUB32_16t:{result = str8_lit("PUB32_16t");}break;
case CV_SymKind_LPROC32_16t:{result = str8_lit("LPROC32_16t");}break;
case CV_SymKind_GPROC32_16t:{result = str8_lit("GPROC32_16t");}break;
case CV_SymKind_THUNK32_ST:{result = str8_lit("THUNK32_ST");}break;
case CV_SymKind_BLOCK32_ST:{result = str8_lit("BLOCK32_ST");}break;
case CV_SymKind_WITH32_ST:{result = str8_lit("WITH32_ST");}break;
case CV_SymKind_LABEL32_ST:{result = str8_lit("LABEL32_ST");}break;
case CV_SymKind_CEXMODEL32:{result = str8_lit("CEXMODEL32");}break;
case CV_SymKind_VFTABLE32_16t:{result = str8_lit("VFTABLE32_16t");}break;
case CV_SymKind_REGREL32_16t:{result = str8_lit("REGREL32_16t");}break;
case CV_SymKind_LTHREAD32_16t:{result = str8_lit("LTHREAD32_16t");}break;
case CV_SymKind_GTHREAD32_16t:{result = str8_lit("GTHREAD32_16t");}break;
case CV_SymKind_SLINK32:{result = str8_lit("SLINK32");}break;
case CV_SymKind_LPROCMIPS_16t:{result = str8_lit("LPROCMIPS_16t");}break;
case CV_SymKind_GPROCMIPS_16t:{result = str8_lit("GPROCMIPS_16t");}break;
case CV_SymKind_PROCREF_ST:{result = str8_lit("PROCREF_ST");}break;
case CV_SymKind_DATAREF_ST:{result = str8_lit("DATAREF_ST");}break;
case CV_SymKind_ALIGN:{result = str8_lit("ALIGN");}break;
case CV_SymKind_LPROCREF_ST:{result = str8_lit("LPROCREF_ST");}break;
case CV_SymKind_OEM:{result = str8_lit("OEM");}break;
case CV_SymKind_TI16_MAX:{result = str8_lit("TI16_MAX");}break;
case CV_SymKind_CONSTANT_ST:{result = str8_lit("CONSTANT_ST");}break;
case CV_SymKind_UDT_ST:{result = str8_lit("UDT_ST");}break;
case CV_SymKind_COBOLUDT_ST:{result = str8_lit("COBOLUDT_ST");}break;
case CV_SymKind_MANYREG_ST:{result = str8_lit("MANYREG_ST");}break;
case CV_SymKind_BPREL32_ST:{result = str8_lit("BPREL32_ST");}break;
case CV_SymKind_LDATA32_ST:{result = str8_lit("LDATA32_ST");}break;
case CV_SymKind_GDATA32_ST:{result = str8_lit("GDATA32_ST");}break;
case CV_SymKind_PUB32_ST:{result = str8_lit("PUB32_ST");}break;
case CV_SymKind_LPROC32_ST:{result = str8_lit("LPROC32_ST");}break;
case CV_SymKind_GPROC32_ST:{result = str8_lit("GPROC32_ST");}break;
case CV_SymKind_VFTABLE32:{result = str8_lit("VFTABLE32");}break;
case CV_SymKind_REGREL32_ST:{result = str8_lit("REGREL32_ST");}break;
case CV_SymKind_LTHREAD32_ST:{result = str8_lit("LTHREAD32_ST");}break;
case CV_SymKind_GTHREAD32_ST:{result = str8_lit("GTHREAD32_ST");}break;
case CV_SymKind_LPROCMIPS_ST:{result = str8_lit("LPROCMIPS_ST");}break;
case CV_SymKind_GPROCMIPS_ST:{result = str8_lit("GPROCMIPS_ST");}break;
case CV_SymKind_FRAMEPROC:{result = str8_lit("FRAMEPROC");}break;
case CV_SymKind_COMPILE2_ST:{result = str8_lit("COMPILE2_ST");}break;
case CV_SymKind_MANYREG2_ST:{result = str8_lit("MANYREG2_ST");}break;
case CV_SymKind_LPROCIA64_ST:{result = str8_lit("LPROCIA64_ST");}break;
case CV_SymKind_GPROCIA64_ST:{result = str8_lit("GPROCIA64_ST");}break;
case CV_SymKind_LOCALSLOT_ST:{result = str8_lit("LOCALSLOT_ST");}break;
case CV_SymKind_PARAMSLOT_ST:{result = str8_lit("PARAMSLOT_ST");}break;
case CV_SymKind_ANNOTATION:{result = str8_lit("ANNOTATION");}break;
case CV_SymKind_GMANPROC_ST:{result = str8_lit("GMANPROC_ST");}break;
case CV_SymKind_LMANPROC_ST:{result = str8_lit("LMANPROC_ST");}break;
case CV_SymKind_RESERVED1:{result = str8_lit("RESERVED1");}break;
case CV_SymKind_RESERVED2:{result = str8_lit("RESERVED2");}break;
case CV_SymKind_RESERVED3:{result = str8_lit("RESERVED3");}break;
case CV_SymKind_RESERVED4:{result = str8_lit("RESERVED4");}break;
case CV_SymKind_LMANDATA_ST:{result = str8_lit("LMANDATA_ST");}break;
case CV_SymKind_GMANDATA_ST:{result = str8_lit("GMANDATA_ST");}break;
case CV_SymKind_MANFRAMEREL_ST:{result = str8_lit("MANFRAMEREL_ST");}break;
case CV_SymKind_MANREGISTER_ST:{result = str8_lit("MANREGISTER_ST");}break;
case CV_SymKind_MANSLOT_ST:{result = str8_lit("MANSLOT_ST");}break;
case CV_SymKind_MANMANYREG_ST:{result = str8_lit("MANMANYREG_ST");}break;
case CV_SymKind_MANREGREL_ST:{result = str8_lit("MANREGREL_ST");}break;
case CV_SymKind_MANMANYREG2_ST:{result = str8_lit("MANMANYREG2_ST");}break;
case CV_SymKind_MANTYPREF:{result = str8_lit("MANTYPREF");}break;
case CV_SymKind_UNAMESPACE_ST:{result = str8_lit("UNAMESPACE_ST");}break;
case CV_SymKind_ST_MAX:{result = str8_lit("ST_MAX");}break;
case CV_SymKind_OBJNAME:{result = str8_lit("OBJNAME");}break;
case CV_SymKind_THUNK32:{result = str8_lit("THUNK32");}break;
case CV_SymKind_BLOCK32:{result = str8_lit("BLOCK32");}break;
case CV_SymKind_WITH32:{result = str8_lit("WITH32");}break;
case CV_SymKind_LABEL32:{result = str8_lit("LABEL32");}break;
case CV_SymKind_REGISTER:{result = str8_lit("REGISTER");}break;
case CV_SymKind_CONSTANT:{result = str8_lit("CONSTANT");}break;
case CV_SymKind_UDT:{result = str8_lit("UDT");}break;
case CV_SymKind_COBOLUDT:{result = str8_lit("COBOLUDT");}break;
case CV_SymKind_MANYREG:{result = str8_lit("MANYREG");}break;
case CV_SymKind_BPREL32:{result = str8_lit("BPREL32");}break;
case CV_SymKind_LDATA32:{result = str8_lit("LDATA32");}break;
case CV_SymKind_GDATA32:{result = str8_lit("GDATA32");}break;
case CV_SymKind_PUB32:{result = str8_lit("PUB32");}break;
case CV_SymKind_LPROC32:{result = str8_lit("LPROC32");}break;
case CV_SymKind_GPROC32:{result = str8_lit("GPROC32");}break;
case CV_SymKind_REGREL32:{result = str8_lit("REGREL32");}break;
case CV_SymKind_LTHREAD32:{result = str8_lit("LTHREAD32");}break;
case CV_SymKind_GTHREAD32:{result = str8_lit("GTHREAD32");}break;
case CV_SymKind_LPROCMIPS:{result = str8_lit("LPROCMIPS");}break;
case CV_SymKind_GPROCMIPS:{result = str8_lit("GPROCMIPS");}break;
case CV_SymKind_COMPILE2:{result = str8_lit("COMPILE2");}break;
case CV_SymKind_MANYREG2:{result = str8_lit("MANYREG2");}break;
case CV_SymKind_LPROCIA64:{result = str8_lit("LPROCIA64");}break;
case CV_SymKind_GPROCIA64:{result = str8_lit("GPROCIA64");}break;
case CV_SymKind_LOCALSLOT:{result = str8_lit("LOCALSLOT");}break;
case CV_SymKind_PARAMSLOT:{result = str8_lit("PARAMSLOT");}break;
case CV_SymKind_LMANDATA:{result = str8_lit("LMANDATA");}break;
case CV_SymKind_GMANDATA:{result = str8_lit("GMANDATA");}break;
case CV_SymKind_MANFRAMEREL:{result = str8_lit("MANFRAMEREL");}break;
case CV_SymKind_MANREGISTER:{result = str8_lit("MANREGISTER");}break;
case CV_SymKind_MANSLOT:{result = str8_lit("MANSLOT");}break;
case CV_SymKind_MANMANYREG:{result = str8_lit("MANMANYREG");}break;
case CV_SymKind_MANREGREL:{result = str8_lit("MANREGREL");}break;
case CV_SymKind_MANMANYREG2:{result = str8_lit("MANMANYREG2");}break;
case CV_SymKind_UNAMESPACE:{result = str8_lit("UNAMESPACE");}break;
case CV_SymKind_PROCREF:{result = str8_lit("PROCREF");}break;
case CV_SymKind_DATAREF:{result = str8_lit("DATAREF");}break;
case CV_SymKind_LPROCREF:{result = str8_lit("LPROCREF");}break;
case CV_SymKind_ANNOTATIONREF:{result = str8_lit("ANNOTATIONREF");}break;
case CV_SymKind_TOKENREF:{result = str8_lit("TOKENREF");}break;
case CV_SymKind_GMANPROC:{result = str8_lit("GMANPROC");}break;
case CV_SymKind_LMANPROC:{result = str8_lit("LMANPROC");}break;
case CV_SymKind_TRAMPOLINE:{result = str8_lit("TRAMPOLINE");}break;
case CV_SymKind_MANCONSTANT:{result = str8_lit("MANCONSTANT");}break;
case CV_SymKind_ATTR_FRAMEREL:{result = str8_lit("ATTR_FRAMEREL");}break;
case CV_SymKind_ATTR_REGISTER:{result = str8_lit("ATTR_REGISTER");}break;
case CV_SymKind_ATTR_REGREL:{result = str8_lit("ATTR_REGREL");}break;
case CV_SymKind_ATTR_MANYREG:{result = str8_lit("ATTR_MANYREG");}break;
case CV_SymKind_SEPCODE:{result = str8_lit("SEPCODE");}break;
case CV_SymKind_DEFRANGE_2005:{result = str8_lit("DEFRANGE_2005");}break;
case CV_SymKind_DEFRANGE2_2005:{result = str8_lit("DEFRANGE2_2005");}break;
case CV_SymKind_SECTION:{result = str8_lit("SECTION");}break;
case CV_SymKind_COFFGROUP:{result = str8_lit("COFFGROUP");}break;
case CV_SymKind_EXPORT:{result = str8_lit("EXPORT");}break;
case CV_SymKind_CALLSITEINFO:{result = str8_lit("CALLSITEINFO");}break;
case CV_SymKind_FRAMECOOKIE:{result = str8_lit("FRAMECOOKIE");}break;
case CV_SymKind_DISCARDED:{result = str8_lit("DISCARDED");}break;
case CV_SymKind_COMPILE3:{result = str8_lit("COMPILE3");}break;
case CV_SymKind_ENVBLOCK:{result = str8_lit("ENVBLOCK");}break;
case CV_SymKind_LOCAL:{result = str8_lit("LOCAL");}break;
case CV_SymKind_DEFRANGE:{result = str8_lit("DEFRANGE");}break;
case CV_SymKind_DEFRANGE_SUBFIELD:{result = str8_lit("DEFRANGE_SUBFIELD");}break;
case CV_SymKind_DEFRANGE_REGISTER:{result = str8_lit("DEFRANGE_REGISTER");}break;
case CV_SymKind_DEFRANGE_FRAMEPOINTER_REL:{result = str8_lit("DEFRANGE_FRAMEPOINTER_REL");}break;
case CV_SymKind_DEFRANGE_SUBFIELD_REGISTER:{result = str8_lit("DEFRANGE_SUBFIELD_REGISTER");}break;
case CV_SymKind_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:{result = str8_lit("DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE");}break;
case CV_SymKind_DEFRANGE_REGISTER_REL:{result = str8_lit("DEFRANGE_REGISTER_REL");}break;
case CV_SymKind_LPROC32_ID:{result = str8_lit("LPROC32_ID");}break;
case CV_SymKind_GPROC32_ID:{result = str8_lit("GPROC32_ID");}break;
case CV_SymKind_LPROCMIPS_ID:{result = str8_lit("LPROCMIPS_ID");}break;
case CV_SymKind_GPROCMIPS_ID:{result = str8_lit("GPROCMIPS_ID");}break;
case CV_SymKind_LPROCIA64_ID:{result = str8_lit("LPROCIA64_ID");}break;
case CV_SymKind_GPROCIA64_ID:{result = str8_lit("GPROCIA64_ID");}break;
case CV_SymKind_BUILDINFO:{result = str8_lit("BUILDINFO");}break;
case CV_SymKind_INLINESITE:{result = str8_lit("INLINESITE");}break;
case CV_SymKind_INLINESITE_END:{result = str8_lit("INLINESITE_END");}break;
case CV_SymKind_PROC_ID_END:{result = str8_lit("PROC_ID_END");}break;
case CV_SymKind_DEFRANGE_HLSL:{result = str8_lit("DEFRANGE_HLSL");}break;
case CV_SymKind_GDATA_HLSL:{result = str8_lit("GDATA_HLSL");}break;
case CV_SymKind_LDATA_HLSL:{result = str8_lit("LDATA_HLSL");}break;
case CV_SymKind_FILESTATIC:{result = str8_lit("FILESTATIC");}break;
case CV_SymKind_LPROC32_DPC:{result = str8_lit("LPROC32_DPC");}break;
case CV_SymKind_LPROC32_DPC_ID:{result = str8_lit("LPROC32_DPC_ID");}break;
case CV_SymKind_DEFRANGE_DPC_PTR_TAG:{result = str8_lit("DEFRANGE_DPC_PTR_TAG");}break;
case CV_SymKind_DPC_SYM_TAG_MAP:{result = str8_lit("DPC_SYM_TAG_MAP");}break;
case CV_SymKind_ARMSWITCHTABLE:{result = str8_lit("ARMSWITCHTABLE");}break;
case CV_SymKind_CALLEES:{result = str8_lit("CALLEES");}break;
case CV_SymKind_CALLERS:{result = str8_lit("CALLERS");}break;
case CV_SymKind_POGODATA:{result = str8_lit("POGODATA");}break;
case CV_SymKind_INLINESITE2:{result = str8_lit("INLINESITE2");}break;
case CV_SymKind_HEAPALLOCSITE:{result = str8_lit("HEAPALLOCSITE");}break;
case CV_SymKind_MOD_TYPEREF:{result = str8_lit("MOD_TYPEREF");}break;
case CV_SymKind_REF_MINIPDB:{result = str8_lit("REF_MINIPDB");}break;
case CV_SymKind_PDBMAP:{result = str8_lit("PDBMAP");}break;
case CV_SymKind_GDATA_HLSL32:{result = str8_lit("GDATA_HLSL32");}break;
case CV_SymKind_LDATA_HLSL32:{result = str8_lit("LDATA_HLSL32");}break;
case CV_SymKind_GDATA_HLSL32_EX:{result = str8_lit("GDATA_HLSL32_EX");}break;
case CV_SymKind_LDATA_HLSL32_EX:{result = str8_lit("LDATA_HLSL32_EX");}break;
case CV_SymKind_FASTLINK:{result = str8_lit("FASTLINK");}break;
case CV_SymKind_INLINEES:{result = str8_lit("INLINEES");}break;
}
return result;
}
internal String8
cv_string_from_basic_type(CV_BasicType v)
{
String8 result = str8_lit("<Unknown CV_BasicType>");
switch(v)
{
default:{}break;
case CV_BasicType_NOTYPE:{result = str8_lit("NOTYPE");}break;
case CV_BasicType_ABS:{result = str8_lit("ABS");}break;
case CV_BasicType_SEGMENT:{result = str8_lit("SEGMENT");}break;
case CV_BasicType_VOID:{result = str8_lit("VOID");}break;
case CV_BasicType_CURRENCY:{result = str8_lit("CURRENCY");}break;
case CV_BasicType_NBASICSTR:{result = str8_lit("NBASICSTR");}break;
case CV_BasicType_FBASICSTR:{result = str8_lit("FBASICSTR");}break;
case CV_BasicType_NOTTRANS:{result = str8_lit("NOTTRANS");}break;
case CV_BasicType_HRESULT:{result = str8_lit("HRESULT");}break;
case CV_BasicType_CHAR:{result = str8_lit("CHAR");}break;
case CV_BasicType_SHORT:{result = str8_lit("SHORT");}break;
case CV_BasicType_LONG:{result = str8_lit("LONG");}break;
case CV_BasicType_QUAD:{result = str8_lit("QUAD");}break;
case CV_BasicType_OCT:{result = str8_lit("OCT");}break;
case CV_BasicType_UCHAR:{result = str8_lit("UCHAR");}break;
case CV_BasicType_USHORT:{result = str8_lit("USHORT");}break;
case CV_BasicType_ULONG:{result = str8_lit("ULONG");}break;
case CV_BasicType_UQUAD:{result = str8_lit("UQUAD");}break;
case CV_BasicType_UOCT:{result = str8_lit("UOCT");}break;
case CV_BasicType_BOOL8:{result = str8_lit("BOOL8");}break;
case CV_BasicType_BOOL16:{result = str8_lit("BOOL16");}break;
case CV_BasicType_BOOL32:{result = str8_lit("BOOL32");}break;
case CV_BasicType_BOOL64:{result = str8_lit("BOOL64");}break;
case CV_BasicType_FLOAT32:{result = str8_lit("FLOAT32");}break;
case CV_BasicType_FLOAT64:{result = str8_lit("FLOAT64");}break;
case CV_BasicType_FLOAT80:{result = str8_lit("FLOAT80");}break;
case CV_BasicType_FLOAT128:{result = str8_lit("FLOAT128");}break;
case CV_BasicType_FLOAT48:{result = str8_lit("FLOAT48");}break;
case CV_BasicType_FLOAT32PP:{result = str8_lit("FLOAT32PP");}break;
case CV_BasicType_FLOAT16:{result = str8_lit("FLOAT16");}break;
case CV_BasicType_COMPLEX32:{result = str8_lit("COMPLEX32");}break;
case CV_BasicType_COMPLEX64:{result = str8_lit("COMPLEX64");}break;
case CV_BasicType_COMPLEX80:{result = str8_lit("COMPLEX80");}break;
case CV_BasicType_COMPLEX128:{result = str8_lit("COMPLEX128");}break;
case CV_BasicType_BIT:{result = str8_lit("BIT");}break;
case CV_BasicType_PASCHAR:{result = str8_lit("PASCHAR");}break;
case CV_BasicType_BOOL32FF:{result = str8_lit("BOOL32FF");}break;
case CV_BasicType_INT8:{result = str8_lit("INT8");}break;
case CV_BasicType_UINT8:{result = str8_lit("UINT8");}break;
case CV_BasicType_RCHAR:{result = str8_lit("RCHAR");}break;
case CV_BasicType_WCHAR:{result = str8_lit("WCHAR");}break;
case CV_BasicType_INT16:{result = str8_lit("INT16");}break;
case CV_BasicType_UINT16:{result = str8_lit("UINT16");}break;
case CV_BasicType_INT32:{result = str8_lit("INT32");}break;
case CV_BasicType_UINT32:{result = str8_lit("UINT32");}break;
case CV_BasicType_INT64:{result = str8_lit("INT64");}break;
case CV_BasicType_UINT64:{result = str8_lit("UINT64");}break;
case CV_BasicType_INT128:{result = str8_lit("INT128");}break;
case CV_BasicType_UINT128:{result = str8_lit("UINT128");}break;
case CV_BasicType_CHAR16:{result = str8_lit("CHAR16");}break;
case CV_BasicType_CHAR32:{result = str8_lit("CHAR32");}break;
case CV_BasicType_CHAR8:{result = str8_lit("CHAR8");}break;
case CV_BasicType_PTR:{result = str8_lit("PTR");}break;
}
return result;
}
internal String8
cv_type_name_from_basic_type(CV_BasicType v)
{
String8 result = str8_lit("<Unknown CV_BasicType>");
switch(v)
{
default:{}break;
case CV_BasicType_NOTYPE:{result = str8_lit("");}break;
case CV_BasicType_ABS:{result = str8_lit("");}break;
case CV_BasicType_SEGMENT:{result = str8_lit("");}break;
case CV_BasicType_VOID:{result = str8_lit("void");}break;
case CV_BasicType_CURRENCY:{result = str8_lit("");}break;
case CV_BasicType_NBASICSTR:{result = str8_lit("");}break;
case CV_BasicType_FBASICSTR:{result = str8_lit("");}break;
case CV_BasicType_NOTTRANS:{result = str8_lit("");}break;
case CV_BasicType_HRESULT:{result = str8_lit("HRESULT");}break;
case CV_BasicType_CHAR:{result = str8_lit("char");}break;
case CV_BasicType_SHORT:{result = str8_lit("S16");}break;
case CV_BasicType_LONG:{result = str8_lit("S32");}break;
case CV_BasicType_QUAD:{result = str8_lit("S64");}break;
case CV_BasicType_OCT:{result = str8_lit("S128");}break;
case CV_BasicType_UCHAR:{result = str8_lit("UCHAR");}break;
case CV_BasicType_USHORT:{result = str8_lit("U16");}break;
case CV_BasicType_ULONG:{result = str8_lit("U32");}break;
case CV_BasicType_UQUAD:{result = str8_lit("U64");}break;
case CV_BasicType_UOCT:{result = str8_lit("U128");}break;
case CV_BasicType_BOOL8:{result = str8_lit("B8");}break;
case CV_BasicType_BOOL16:{result = str8_lit("B16");}break;
case CV_BasicType_BOOL32:{result = str8_lit("B32");}break;
case CV_BasicType_BOOL64:{result = str8_lit("B64");}break;
case CV_BasicType_FLOAT32:{result = str8_lit("F32");}break;
case CV_BasicType_FLOAT64:{result = str8_lit("F64");}break;
case CV_BasicType_FLOAT80:{result = str8_lit("F80");}break;
case CV_BasicType_FLOAT128:{result = str8_lit("F128");}break;
case CV_BasicType_FLOAT48:{result = str8_lit("F48");}break;
case CV_BasicType_FLOAT32PP:{result = str8_lit("F32PP");}break;
case CV_BasicType_FLOAT16:{result = str8_lit("F16");}break;
case CV_BasicType_COMPLEX32:{result = str8_lit("ComplexF32");}break;
case CV_BasicType_COMPLEX64:{result = str8_lit("ComplexF64");}break;
case CV_BasicType_COMPLEX80:{result = str8_lit("ComplexF80");}break;
case CV_BasicType_COMPLEX128:{result = str8_lit("ComplexF128");}break;
case CV_BasicType_BIT:{result = str8_lit("");}break;
case CV_BasicType_PASCHAR:{result = str8_lit("");}break;
case CV_BasicType_BOOL32FF:{result = str8_lit("B32FF");}break;
case CV_BasicType_INT8:{result = str8_lit("S8");}break;
case CV_BasicType_UINT8:{result = str8_lit("U8");}break;
case CV_BasicType_RCHAR:{result = str8_lit("char");}break;
case CV_BasicType_WCHAR:{result = str8_lit("WCHAR");}break;
case CV_BasicType_INT16:{result = str8_lit("S16");}break;
case CV_BasicType_UINT16:{result = str8_lit("U16");}break;
case CV_BasicType_INT32:{result = str8_lit("S32");}break;
case CV_BasicType_UINT32:{result = str8_lit("U32");}break;
case CV_BasicType_INT64:{result = str8_lit("S64");}break;
case CV_BasicType_UINT64:{result = str8_lit("U64");}break;
case CV_BasicType_INT128:{result = str8_lit("S128");}break;
case CV_BasicType_UINT128:{result = str8_lit("U128");}break;
case CV_BasicType_CHAR16:{result = str8_lit("CHAR16");}break;
case CV_BasicType_CHAR32:{result = str8_lit("CHAR32");}break;
case CV_BasicType_CHAR8:{result = str8_lit("char");}break;
case CV_BasicType_PTR:{result = str8_lit("PTR");}break;
}
return result;
}
internal String8
cv_string_from_leaf_kind(CV_LeafKind v)
{
String8 result = str8_lit("<Unknown CV_LeafKind>");
switch(v)
{
default:{}break;
case CV_LeafKind_NOTYPE:{result = str8_lit("NOTYPE");}break;
case CV_LeafKind_MODIFIER_16t:{result = str8_lit("MODIFIER_16t");}break;
case CV_LeafKind_POINTER_16t:{result = str8_lit("POINTER_16t");}break;
case CV_LeafKind_ARRAY_16t:{result = str8_lit("ARRAY_16t");}break;
case CV_LeafKind_CLASS_16t:{result = str8_lit("CLASS_16t");}break;
case CV_LeafKind_STRUCTURE_16t:{result = str8_lit("STRUCTURE_16t");}break;
case CV_LeafKind_UNION_16t:{result = str8_lit("UNION_16t");}break;
case CV_LeafKind_ENUM_16t:{result = str8_lit("ENUM_16t");}break;
case CV_LeafKind_PROCEDURE_16t:{result = str8_lit("PROCEDURE_16t");}break;
case CV_LeafKind_MFUNCTION_16t:{result = str8_lit("MFUNCTION_16t");}break;
case CV_LeafKind_VTSHAPE:{result = str8_lit("VTSHAPE");}break;
case CV_LeafKind_COBOL0_16t:{result = str8_lit("COBOL0_16t");}break;
case CV_LeafKind_COBOL1:{result = str8_lit("COBOL1");}break;
case CV_LeafKind_BARRAY_16t:{result = str8_lit("BARRAY_16t");}break;
case CV_LeafKind_LABEL:{result = str8_lit("LABEL");}break;
case CV_LeafKind_NULL:{result = str8_lit("NULL");}break;
case CV_LeafKind_NOTTRAN:{result = str8_lit("NOTTRAN");}break;
case CV_LeafKind_DIMARRAY_16t:{result = str8_lit("DIMARRAY_16t");}break;
case CV_LeafKind_VFTPATH_16t:{result = str8_lit("VFTPATH_16t");}break;
case CV_LeafKind_PRECOMP_16t:{result = str8_lit("PRECOMP_16t");}break;
case CV_LeafKind_ENDPRECOMP:{result = str8_lit("ENDPRECOMP");}break;
case CV_LeafKind_OEM_16t:{result = str8_lit("OEM_16t");}break;
case CV_LeafKind_TYPESERVER_ST:{result = str8_lit("TYPESERVER_ST");}break;
case CV_LeafKind_SKIP_16t:{result = str8_lit("SKIP_16t");}break;
case CV_LeafKind_ARGLIST_16t:{result = str8_lit("ARGLIST_16t");}break;
case CV_LeafKind_DEFARG_16t:{result = str8_lit("DEFARG_16t");}break;
case CV_LeafKind_LIST:{result = str8_lit("LIST");}break;
case CV_LeafKind_FIELDLIST_16t:{result = str8_lit("FIELDLIST_16t");}break;
case CV_LeafKind_DERIVED_16t:{result = str8_lit("DERIVED_16t");}break;
case CV_LeafKind_BITFIELD_16t:{result = str8_lit("BITFIELD_16t");}break;
case CV_LeafKind_METHODLIST_16t:{result = str8_lit("METHODLIST_16t");}break;
case CV_LeafKind_DIMCONU_16t:{result = str8_lit("DIMCONU_16t");}break;
case CV_LeafKind_DIMCONLU_16t:{result = str8_lit("DIMCONLU_16t");}break;
case CV_LeafKind_DIMVARU_16t:{result = str8_lit("DIMVARU_16t");}break;
case CV_LeafKind_DIMVARLU_16t:{result = str8_lit("DIMVARLU_16t");}break;
case CV_LeafKind_REFSYM:{result = str8_lit("REFSYM");}break;
case CV_LeafKind_BCLASS_16t:{result = str8_lit("BCLASS_16t");}break;
case CV_LeafKind_VBCLASS_16t:{result = str8_lit("VBCLASS_16t");}break;
case CV_LeafKind_IVBCLASS_16t:{result = str8_lit("IVBCLASS_16t");}break;
case CV_LeafKind_ENUMERATE_ST:{result = str8_lit("ENUMERATE_ST");}break;
case CV_LeafKind_FRIENDFCN_16t:{result = str8_lit("FRIENDFCN_16t");}break;
case CV_LeafKind_INDEX_16t:{result = str8_lit("INDEX_16t");}break;
case CV_LeafKind_MEMBER_16t:{result = str8_lit("MEMBER_16t");}break;
case CV_LeafKind_STMEMBER_16t:{result = str8_lit("STMEMBER_16t");}break;
case CV_LeafKind_METHOD_16t:{result = str8_lit("METHOD_16t");}break;
case CV_LeafKind_NESTTYPE_16t:{result = str8_lit("NESTTYPE_16t");}break;
case CV_LeafKind_VFUNCTAB_16t:{result = str8_lit("VFUNCTAB_16t");}break;
case CV_LeafKind_FRIENDCLS_16t:{result = str8_lit("FRIENDCLS_16t");}break;
case CV_LeafKind_ONEMETHOD_16t:{result = str8_lit("ONEMETHOD_16t");}break;
case CV_LeafKind_VFUNCOFF_16t:{result = str8_lit("VFUNCOFF_16t");}break;
case CV_LeafKind_TI16_MAX:{result = str8_lit("TI16_MAX");}break;
case CV_LeafKind_MODIFIER:{result = str8_lit("MODIFIER");}break;
case CV_LeafKind_POINTER:{result = str8_lit("POINTER");}break;
case CV_LeafKind_ARRAY_ST:{result = str8_lit("ARRAY_ST");}break;
case CV_LeafKind_CLASS_ST:{result = str8_lit("CLASS_ST");}break;
case CV_LeafKind_STRUCTURE_ST:{result = str8_lit("STRUCTURE_ST");}break;
case CV_LeafKind_UNION_ST:{result = str8_lit("UNION_ST");}break;
case CV_LeafKind_ENUM_ST:{result = str8_lit("ENUM_ST");}break;
case CV_LeafKind_PROCEDURE:{result = str8_lit("PROCEDURE");}break;
case CV_LeafKind_MFUNCTION:{result = str8_lit("MFUNCTION");}break;
case CV_LeafKind_COBOL0:{result = str8_lit("COBOL0");}break;
case CV_LeafKind_BARRAY:{result = str8_lit("BARRAY");}break;
case CV_LeafKind_DIMARRAY_ST:{result = str8_lit("DIMARRAY_ST");}break;
case CV_LeafKind_VFTPATH:{result = str8_lit("VFTPATH");}break;
case CV_LeafKind_PRECOMP_ST:{result = str8_lit("PRECOMP_ST");}break;
case CV_LeafKind_OEM:{result = str8_lit("OEM");}break;
case CV_LeafKind_ALIAS_ST:{result = str8_lit("ALIAS_ST");}break;
case CV_LeafKind_OEM2:{result = str8_lit("OEM2");}break;
case CV_LeafKind_SKIP:{result = str8_lit("SKIP");}break;
case CV_LeafKind_ARGLIST:{result = str8_lit("ARGLIST");}break;
case CV_LeafKind_DEFARG_ST:{result = str8_lit("DEFARG_ST");}break;
case CV_LeafKind_FIELDLIST:{result = str8_lit("FIELDLIST");}break;
case CV_LeafKind_DERIVED:{result = str8_lit("DERIVED");}break;
case CV_LeafKind_BITFIELD:{result = str8_lit("BITFIELD");}break;
case CV_LeafKind_METHODLIST:{result = str8_lit("METHODLIST");}break;
case CV_LeafKind_DIMCONU:{result = str8_lit("DIMCONU");}break;
case CV_LeafKind_DIMCONLU:{result = str8_lit("DIMCONLU");}break;
case CV_LeafKind_DIMVARU:{result = str8_lit("DIMVARU");}break;
case CV_LeafKind_DIMVARLU:{result = str8_lit("DIMVARLU");}break;
case CV_LeafKind_BCLASS:{result = str8_lit("BCLASS");}break;
case CV_LeafKind_VBCLASS:{result = str8_lit("VBCLASS");}break;
case CV_LeafKind_IVBCLASS:{result = str8_lit("IVBCLASS");}break;
case CV_LeafKind_FRIENDFCN_ST:{result = str8_lit("FRIENDFCN_ST");}break;
case CV_LeafKind_INDEX:{result = str8_lit("INDEX");}break;
case CV_LeafKind_MEMBER_ST:{result = str8_lit("MEMBER_ST");}break;
case CV_LeafKind_STMEMBER_ST:{result = str8_lit("STMEMBER_ST");}break;
case CV_LeafKind_METHOD_ST:{result = str8_lit("METHOD_ST");}break;
case CV_LeafKind_NESTTYPE_ST:{result = str8_lit("NESTTYPE_ST");}break;
case CV_LeafKind_VFUNCTAB:{result = str8_lit("VFUNCTAB");}break;
case CV_LeafKind_FRIENDCLS:{result = str8_lit("FRIENDCLS");}break;
case CV_LeafKind_ONEMETHOD_ST:{result = str8_lit("ONEMETHOD_ST");}break;
case CV_LeafKind_VFUNCOFF:{result = str8_lit("VFUNCOFF");}break;
case CV_LeafKind_NESTTYPEEX_ST:{result = str8_lit("NESTTYPEEX_ST");}break;
case CV_LeafKind_MEMBERMODIFY_ST:{result = str8_lit("MEMBERMODIFY_ST");}break;
case CV_LeafKind_MANAGED_ST:{result = str8_lit("MANAGED_ST");}break;
case CV_LeafKind_ST_MAX:{result = str8_lit("ST_MAX");}break;
case CV_LeafKind_TYPESERVER:{result = str8_lit("TYPESERVER");}break;
case CV_LeafKind_ENUMERATE:{result = str8_lit("ENUMERATE");}break;
case CV_LeafKind_ARRAY:{result = str8_lit("ARRAY");}break;
case CV_LeafKind_CLASS:{result = str8_lit("CLASS");}break;
case CV_LeafKind_STRUCTURE:{result = str8_lit("STRUCTURE");}break;
case CV_LeafKind_UNION:{result = str8_lit("UNION");}break;
case CV_LeafKind_ENUM:{result = str8_lit("ENUM");}break;
case CV_LeafKind_DIMARRAY:{result = str8_lit("DIMARRAY");}break;
case CV_LeafKind_PRECOMP:{result = str8_lit("PRECOMP");}break;
case CV_LeafKind_ALIAS:{result = str8_lit("ALIAS");}break;
case CV_LeafKind_DEFARG:{result = str8_lit("DEFARG");}break;
case CV_LeafKind_FRIENDFCN:{result = str8_lit("FRIENDFCN");}break;
case CV_LeafKind_MEMBER:{result = str8_lit("MEMBER");}break;
case CV_LeafKind_STMEMBER:{result = str8_lit("STMEMBER");}break;
case CV_LeafKind_METHOD:{result = str8_lit("METHOD");}break;
case CV_LeafKind_NESTTYPE:{result = str8_lit("NESTTYPE");}break;
case CV_LeafKind_ONEMETHOD:{result = str8_lit("ONEMETHOD");}break;
case CV_LeafKind_NESTTYPEEX:{result = str8_lit("NESTTYPEEX");}break;
case CV_LeafKind_MEMBERMODIFY:{result = str8_lit("MEMBERMODIFY");}break;
case CV_LeafKind_MANAGED:{result = str8_lit("MANAGED");}break;
case CV_LeafKind_TYPESERVER2:{result = str8_lit("TYPESERVER2");}break;
case CV_LeafKind_STRIDED_ARRAY:{result = str8_lit("STRIDED_ARRAY");}break;
case CV_LeafKind_HLSL:{result = str8_lit("HLSL");}break;
case CV_LeafKind_MODIFIER_EX:{result = str8_lit("MODIFIER_EX");}break;
case CV_LeafKind_INTERFACE:{result = str8_lit("INTERFACE");}break;
case CV_LeafKind_BINTERFACE:{result = str8_lit("BINTERFACE");}break;
case CV_LeafKind_VECTOR:{result = str8_lit("VECTOR");}break;
case CV_LeafKind_MATRIX:{result = str8_lit("MATRIX");}break;
case CV_LeafKind_VFTABLE:{result = str8_lit("VFTABLE");}break;
case CV_LeafKind_FUNC_ID:{result = str8_lit("FUNC_ID");}break;
case CV_LeafKind_MFUNC_ID:{result = str8_lit("MFUNC_ID");}break;
case CV_LeafKind_BUILDINFO:{result = str8_lit("BUILDINFO");}break;
case CV_LeafKind_SUBSTR_LIST:{result = str8_lit("SUBSTR_LIST");}break;
case CV_LeafKind_STRING_ID:{result = str8_lit("STRING_ID");}break;
case CV_LeafKind_UDT_SRC_LINE:{result = str8_lit("UDT_SRC_LINE");}break;
case CV_LeafKind_UDT_MOD_SRC_LINE:{result = str8_lit("UDT_MOD_SRC_LINE");}break;
case CV_LeafKind_CLASS2:{result = str8_lit("CLASS2");}break;
case CV_LeafKind_STRUCT2:{result = str8_lit("STRUCT2");}break;
}
return result;
}
internal U64
cv_header_struct_size_from_sym_kind(CV_SymKind v)
{
U64 result = 0;
switch(v)
{
default:{}break;
case CV_SymKind_COMPILE:{result = sizeof(CV_SymCompile);}break;
case CV_SymKind_SSEARCH:{result = sizeof(CV_SymStartSearch);}break;
case CV_SymKind_RETURN:{result = sizeof(CV_SymReturn);}break;
case CV_SymKind_SLINK32:{result = sizeof(CV_SymSLink32);}break;
case CV_SymKind_OEM:{result = sizeof(CV_SymOEM);}break;
case CV_SymKind_VFTABLE32:{result = sizeof(CV_SymVPath32);}break;
case CV_SymKind_FRAMEPROC:{result = sizeof(CV_SymFrameproc);}break;
case CV_SymKind_ANNOTATION:{result = sizeof(CV_SymAnnotation);}break;
case CV_SymKind_OBJNAME:{result = sizeof(CV_SymObjName);}break;
case CV_SymKind_THUNK32:{result = sizeof(CV_SymThunk32);}break;
case CV_SymKind_BLOCK32:{result = sizeof(CV_SymBlock32);}break;
case CV_SymKind_LABEL32:{result = sizeof(CV_SymLabel32);}break;
case CV_SymKind_REGISTER:{result = sizeof(CV_SymRegister);}break;
case CV_SymKind_CONSTANT:{result = sizeof(CV_SymConstant);}break;
case CV_SymKind_UDT:{result = sizeof(CV_SymUDT);}break;
case CV_SymKind_MANYREG:{result = sizeof(CV_SymManyreg);}break;
case CV_SymKind_BPREL32:{result = sizeof(CV_SymBPRel32);}break;
case CV_SymKind_LDATA32:{result = sizeof(CV_SymData32);}break;
case CV_SymKind_GDATA32:{result = sizeof(CV_SymData32);}break;
case CV_SymKind_PUB32:{result = sizeof(CV_SymPub32);}break;
case CV_SymKind_LPROC32:{result = sizeof(CV_SymProc32);}break;
case CV_SymKind_GPROC32:{result = sizeof(CV_SymProc32);}break;
case CV_SymKind_REGREL32:{result = sizeof(CV_SymRegrel32);}break;
case CV_SymKind_LTHREAD32:{result = sizeof(CV_SymThread32);}break;
case CV_SymKind_GTHREAD32:{result = sizeof(CV_SymThread32);}break;
case CV_SymKind_COMPILE2:{result = sizeof(CV_SymCompile2);}break;
case CV_SymKind_MANYREG2:{result = sizeof(CV_SymManyreg2);}break;
case CV_SymKind_LOCALSLOT:{result = sizeof(CV_SymSlot);}break;
case CV_SymKind_MANFRAMEREL:{result = sizeof(CV_SymAttrFrameRel);}break;
case CV_SymKind_MANREGISTER:{result = sizeof(CV_SymAttrReg);}break;
case CV_SymKind_MANMANYREG:{result = sizeof(CV_SymAttrManyReg);}break;
case CV_SymKind_MANREGREL:{result = sizeof(CV_SymAttrRegRel);}break;
case CV_SymKind_UNAMESPACE:{result = sizeof(CV_SymUNamespace);}break;
case CV_SymKind_PROCREF:{result = sizeof(CV_SymRef2);}break;
case CV_SymKind_DATAREF:{result = sizeof(CV_SymRef2);}break;
case CV_SymKind_LPROCREF:{result = sizeof(CV_SymRef2);}break;
case CV_SymKind_TRAMPOLINE:{result = sizeof(CV_SymTrampoline);}break;
case CV_SymKind_ATTR_FRAMEREL:{result = sizeof(CV_SymAttrFrameRel);}break;
case CV_SymKind_ATTR_REGISTER:{result = sizeof(CV_SymAttrReg);}break;
case CV_SymKind_ATTR_REGREL:{result = sizeof(CV_SymAttrRegRel);}break;
case CV_SymKind_ATTR_MANYREG:{result = sizeof(CV_SymAttrManyReg);}break;
case CV_SymKind_SEPCODE:{result = sizeof(CV_SymSepcode);}break;
case CV_SymKind_SECTION:{result = sizeof(CV_SymSection);}break;
case CV_SymKind_COFFGROUP:{result = sizeof(CV_SymCoffGroup);}break;
case CV_SymKind_EXPORT:{result = sizeof(CV_SymExport);}break;
case CV_SymKind_CALLSITEINFO:{result = sizeof(CV_SymCallSiteInfo);}break;
case CV_SymKind_FRAMECOOKIE:{result = sizeof(CV_SymFrameCookie);}break;
case CV_SymKind_DISCARDED:{result = sizeof(CV_SymDiscarded);}break;
case CV_SymKind_COMPILE3:{result = sizeof(CV_SymCompile3);}break;
case CV_SymKind_ENVBLOCK:{result = sizeof(CV_SymEnvBlock);}break;
case CV_SymKind_LOCAL:{result = sizeof(CV_SymLocal);}break;
case CV_SymKind_DEFRANGE_SUBFIELD:{result = sizeof(CV_SymDefrangeSubfield);}break;
case CV_SymKind_DEFRANGE_REGISTER:{result = sizeof(CV_SymDefrangeRegister);}break;
case CV_SymKind_DEFRANGE_FRAMEPOINTER_REL:{result = sizeof(CV_SymDefrangeFramepointerRel);}break;
case CV_SymKind_DEFRANGE_SUBFIELD_REGISTER:{result = sizeof(CV_SymDefrangeSubfieldRegister);}break;
case CV_SymKind_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:{result = sizeof(CV_SymDefrangeFramepointerRelFullScope);}break;
case CV_SymKind_DEFRANGE_REGISTER_REL:{result = sizeof(CV_SymDefrangeRegisterRel);}break;
case CV_SymKind_BUILDINFO:{result = sizeof(CV_SymBuildInfo);}break;
case CV_SymKind_INLINESITE:{result = sizeof(CV_SymInlineSite);}break;
case CV_SymKind_FILESTATIC:{result = sizeof(CV_SymFileStatic);}break;
case CV_SymKind_CALLEES:{result = sizeof(CV_SymFunctionList);}break;
case CV_SymKind_CALLERS:{result = sizeof(CV_SymFunctionList);}break;
case CV_SymKind_POGODATA:{result = sizeof(CV_SymPogoInfo);}break;
case CV_SymKind_INLINESITE2:{result = sizeof(CV_SymInlineSite2);}break;
case CV_SymKind_HEAPALLOCSITE:{result = sizeof(CV_SymHeapAllocSite);}break;
case CV_SymKind_MOD_TYPEREF:{result = sizeof(CV_SymModTypeRef);}break;
case CV_SymKind_REF_MINIPDB:{result = sizeof(CV_SymRefMiniPdb);}break;
case CV_SymKind_FASTLINK:{result = sizeof(CV_SymFastLink);}break;
case CV_SymKind_INLINEES:{result = sizeof(CV_SymInlinees);}break;
}
return result;
}
internal U64
cv_header_struct_size_from_leaf_kind(CV_LeafKind v)
{
U64 result = 0;
switch(v)
{
default:{}break;
case CV_LeafKind_VTSHAPE:{result = sizeof(CV_LeafVTShape);}break;
case CV_LeafKind_LABEL:{result = sizeof(CV_LeafLabel);}break;
case CV_LeafKind_MODIFIER:{result = sizeof(CV_LeafModifier);}break;
case CV_LeafKind_POINTER:{result = sizeof(CV_LeafPointer);}break;
case CV_LeafKind_PROCEDURE:{result = sizeof(CV_LeafProcedure);}break;
case CV_LeafKind_MFUNCTION:{result = sizeof(CV_LeafMFunction);}break;
case CV_LeafKind_VFTPATH:{result = sizeof(CV_LeafVFPath);}break;
case CV_LeafKind_SKIP:{result = sizeof(CV_LeafSkip);}break;
case CV_LeafKind_ARGLIST:{result = sizeof(CV_LeafArgList);}break;
case CV_LeafKind_BITFIELD:{result = sizeof(CV_LeafBitField);}break;
case CV_LeafKind_METHODLIST:{result = sizeof(CV_LeafMethodListMember);}break;
case CV_LeafKind_BCLASS:{result = sizeof(CV_LeafBClass);}break;
case CV_LeafKind_VBCLASS:{result = sizeof(CV_LeafVBClass);}break;
case CV_LeafKind_INDEX:{result = sizeof(CV_LeafIndex);}break;
case CV_LeafKind_VFUNCTAB:{result = sizeof(CV_LeafVFuncTab);}break;
case CV_LeafKind_VFUNCOFF:{result = sizeof(CV_LeafVFuncOff);}break;
case CV_LeafKind_TYPESERVER:{result = sizeof(CV_LeafTypeServer);}break;
case CV_LeafKind_ENUMERATE:{result = sizeof(CV_LeafEnumerate);}break;
case CV_LeafKind_ARRAY:{result = sizeof(CV_LeafArray);}break;
case CV_LeafKind_CLASS:{result = sizeof(CV_LeafStruct);}break;
case CV_LeafKind_STRUCTURE:{result = sizeof(CV_LeafStruct);}break;
case CV_LeafKind_UNION:{result = sizeof(CV_LeafUnion);}break;
case CV_LeafKind_ENUM:{result = sizeof(CV_LeafEnum);}break;
case CV_LeafKind_PRECOMP:{result = sizeof(CV_LeafPreComp);}break;
case CV_LeafKind_ALIAS:{result = sizeof(CV_LeafAlias);}break;
case CV_LeafKind_MEMBER:{result = sizeof(CV_LeafMember);}break;
case CV_LeafKind_STMEMBER:{result = sizeof(CV_LeafStMember);}break;
case CV_LeafKind_METHOD:{result = sizeof(CV_LeafMethod);}break;
case CV_LeafKind_NESTTYPE:{result = sizeof(CV_LeafNestType);}break;
case CV_LeafKind_ONEMETHOD:{result = sizeof(CV_LeafOneMethod);}break;
case CV_LeafKind_NESTTYPEEX:{result = sizeof(CV_LeafNestTypeEx);}break;
case CV_LeafKind_TYPESERVER2:{result = sizeof(CV_LeafTypeServer2);}break;
case CV_LeafKind_INTERFACE:{result = sizeof(CV_LeafStruct);}break;
case CV_LeafKind_FUNC_ID:{result = sizeof(CV_LeafFuncId);}break;
case CV_LeafKind_MFUNC_ID:{result = sizeof(CV_LeafMFuncId);}break;
case CV_LeafKind_BUILDINFO:{result = sizeof(CV_LeafBuildInfo);}break;
case CV_LeafKind_SUBSTR_LIST:{result = sizeof(CV_LeafSubstrList);}break;
case CV_LeafKind_STRING_ID:{result = sizeof(CV_LeafStringId);}break;
case CV_LeafKind_UDT_SRC_LINE:{result = sizeof(CV_LeafUDTSrcLine);}break;
case CV_LeafKind_UDT_MOD_SRC_LINE:{result = sizeof(CV_LeafUDTModSrcLine);}break;
case CV_LeafKind_CLASS2:{result = sizeof(CV_LeafStruct2);}break;
case CV_LeafKind_STRUCT2:{result = sizeof(CV_LeafStruct2);}break;
}
return result;
}
+528
View File
@@ -0,0 +1,528 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
#ifndef CODEVIEW_META_H
#define CODEVIEW_META_H
typedef U16 CV_NumericKind;
typedef enum CV_NumericKindEnum
{
CV_NumericKind_CHAR = 0x8000,
CV_NumericKind_SHORT = 0x8001,
CV_NumericKind_USHORT = 0x8002,
CV_NumericKind_LONG = 0x8003,
CV_NumericKind_ULONG = 0x8004,
CV_NumericKind_FLOAT32 = 0x8005,
CV_NumericKind_FLOAT64 = 0x8006,
CV_NumericKind_FLOAT80 = 0x8007,
CV_NumericKind_FLOAT128 = 0x8008,
CV_NumericKind_QUADWORD = 0x8009,
CV_NumericKind_UQUADWORD = 0x800a,
CV_NumericKind_FLOAT48 = 0x800b,
CV_NumericKind_COMPLEX32 = 0x800c,
CV_NumericKind_COMPLEX64 = 0x800d,
CV_NumericKind_COMPLEX80 = 0x800e,
CV_NumericKind_COMPLEX128 = 0x800f,
CV_NumericKind_VARSTRING = 0x8010,
CV_NumericKind_OCTWORD = 0x8017,
CV_NumericKind_UOCTWORD = 0x8018,
CV_NumericKind_DECIMAL = 0x8019,
CV_NumericKind_DATE = 0x801a,
CV_NumericKind_UTF8STRING = 0x801b,
CV_NumericKind_FLOAT16 = 0x801c,
} CV_NumericKindEnum;
typedef U16 CV_Arch;
typedef enum CV_ArchEnum
{
CV_Arch_8080 = 0x00,
CV_Arch_8086 = 0x01,
CV_Arch_80286 = 0x02,
CV_Arch_80386 = 0x03,
CV_Arch_80486 = 0x04,
CV_Arch_PENTIUM = 0x05,
CV_Arch_PENTIUMII = 0x06,
CV_Arch_PENTIUMIII = 0x07,
CV_Arch_MIPS = 0x10,
CV_Arch_MIPS16 = 0x11,
CV_Arch_MIPS32 = 0x12,
CV_Arch_MIPS64 = 0x13,
CV_Arch_MIPSI = 0x14,
CV_Arch_MIPSII = 0x15,
CV_Arch_MIPSIII = 0x16,
CV_Arch_MIPSIV = 0x17,
CV_Arch_MIPSV = 0x18,
CV_Arch_M68000 = 0x20,
CV_Arch_M68010 = 0x21,
CV_Arch_M68020 = 0x22,
CV_Arch_M68030 = 0x23,
CV_Arch_M68040 = 0x24,
CV_Arch_ALPHA = 0x30,
CV_Arch_ALPHA_21164 = 0x31,
CV_Arch_ALPHA_21164A = 0x32,
CV_Arch_ALPHA_21264 = 0x33,
CV_Arch_ALPHA_21364 = 0x34,
CV_Arch_PPC601 = 0x40,
CV_Arch_PPC603 = 0x41,
CV_Arch_PPC604 = 0x42,
CV_Arch_PPC620 = 0x43,
CV_Arch_PPCFP = 0x44,
CV_Arch_PPCBE = 0x45,
CV_Arch_SH3 = 0x50,
CV_Arch_SH3E = 0x51,
CV_Arch_SH3DSP = 0x52,
CV_Arch_SH4 = 0x53,
CV_Arch_SHMEDIA = 0x54,
CV_Arch_ARM3 = 0x60,
CV_Arch_ARM4 = 0x61,
CV_Arch_ARM4T = 0x62,
CV_Arch_ARM5 = 0x63,
CV_Arch_ARM5T = 0x64,
CV_Arch_ARM6 = 0x65,
CV_Arch_ARM_XMAC = 0x66,
CV_Arch_ARM_WMMX = 0x67,
CV_Arch_ARM7 = 0x68,
CV_Arch_OMNI = 0x70,
CV_Arch_IA64_1 = 0x80,
CV_Arch_IA64_2 = 0x81,
CV_Arch_CEE = 0x90,
CV_Arch_AM33 = 0xA0,
CV_Arch_M32R = 0xB0,
CV_Arch_TRICORE = 0xC0,
CV_Arch_X64 = 0xD0,
CV_Arch_EBC = 0xE0,
CV_Arch_THUMB = 0xF0,
CV_Arch_ARMNT = 0xF4,
CV_Arch_ARM64 = 0xF6,
CV_Arch_D3D11_SHADER = 0x100,
CV_Arch_IA64 = CV_Arch_IA64_1,
CV_Arch_PENTIUMPRO = CV_Arch_PENTIUMII,
CV_Arch_MIPSR4000 = CV_Arch_MIPS,
CV_Arch_ALPHA_21064 = CV_Arch_ALPHA,
CV_Arch_AMD64 = CV_Arch_X64,
} CV_ArchEnum;
typedef U16 CV_AllReg;
typedef enum CV_AllRegEnum
{
CV_AllReg_ERR = 30000,
CV_AllReg_TEB = 30001,
CV_AllReg_TIMER = 30002,
CV_AllReg_EFAD1 = 30003,
CV_AllReg_EFAD2 = 30004,
CV_AllReg_EFAD3 = 30005,
CV_AllReg_VFRAME = 30006,
CV_AllReg_HANDLE = 30007,
CV_AllReg_PARAMS = 30008,
CV_AllReg_LOCALS = 30009,
CV_AllReg_TID = 30010,
CV_AllReg_ENV = 30011,
CV_AllReg_CMDLN = 30012,
} CV_AllRegEnum;
typedef U16 CV_SymKind;
typedef enum CV_SymKindEnum
{
CV_SymKind_COMPILE = 0x0001,
CV_SymKind_REGISTER_16t = 0x0002,
CV_SymKind_CONSTANT_16t = 0x0003,
CV_SymKind_UDT_16t = 0x0004,
CV_SymKind_SSEARCH = 0x0005,
CV_SymKind_END = 0x0006,
CV_SymKind_SKIP = 0x0007,
CV_SymKind_CVRESERVE = 0x0008,
CV_SymKind_OBJNAME_ST = 0x0009,
CV_SymKind_ENDARG = 0x000a,
CV_SymKind_COBOLUDT_16t = 0x000b,
CV_SymKind_MANYREG_16t = 0x000c,
CV_SymKind_RETURN = 0x000d,
CV_SymKind_ENTRYTHIS = 0x000e,
CV_SymKind_BPREL16 = 0x0100,
CV_SymKind_LDATA16 = 0x0101,
CV_SymKind_GDATA16 = 0x0102,
CV_SymKind_PUB16 = 0x0103,
CV_SymKind_LPROC16 = 0x0104,
CV_SymKind_GPROC16 = 0x0105,
CV_SymKind_THUNK16 = 0x0106,
CV_SymKind_BLOCK16 = 0x0107,
CV_SymKind_WITH16 = 0x0108,
CV_SymKind_LABEL16 = 0x0109,
CV_SymKind_CEXMODEL16 = 0x010a,
CV_SymKind_VFTABLE16 = 0x010b,
CV_SymKind_REGREL16 = 0x010c,
CV_SymKind_BPREL32_16t = 0x0200,
CV_SymKind_LDATA32_16t = 0x0201,
CV_SymKind_GDATA32_16t = 0x0202,
CV_SymKind_PUB32_16t = 0x0203,
CV_SymKind_LPROC32_16t = 0x0204,
CV_SymKind_GPROC32_16t = 0x0205,
CV_SymKind_THUNK32_ST = 0x0206,
CV_SymKind_BLOCK32_ST = 0x0207,
CV_SymKind_WITH32_ST = 0x0208,
CV_SymKind_LABEL32_ST = 0x0209,
CV_SymKind_CEXMODEL32 = 0x020a,
CV_SymKind_VFTABLE32_16t = 0x020b,
CV_SymKind_REGREL32_16t = 0x020c,
CV_SymKind_LTHREAD32_16t = 0x020d,
CV_SymKind_GTHREAD32_16t = 0x020e,
CV_SymKind_SLINK32 = 0x020f,
CV_SymKind_LPROCMIPS_16t = 0x0300,
CV_SymKind_GPROCMIPS_16t = 0x0301,
CV_SymKind_PROCREF_ST = 0x0400,
CV_SymKind_DATAREF_ST = 0x0401,
CV_SymKind_ALIGN = 0x0402,
CV_SymKind_LPROCREF_ST = 0x0403,
CV_SymKind_OEM = 0x0404,
CV_SymKind_TI16_MAX = 0x1000,
CV_SymKind_CONSTANT_ST = 0x1002,
CV_SymKind_UDT_ST = 0x1003,
CV_SymKind_COBOLUDT_ST = 0x1004,
CV_SymKind_MANYREG_ST = 0x1005,
CV_SymKind_BPREL32_ST = 0x1006,
CV_SymKind_LDATA32_ST = 0x1007,
CV_SymKind_GDATA32_ST = 0x1008,
CV_SymKind_PUB32_ST = 0x1009,
CV_SymKind_LPROC32_ST = 0x100a,
CV_SymKind_GPROC32_ST = 0x100b,
CV_SymKind_VFTABLE32 = 0x100c,
CV_SymKind_REGREL32_ST = 0x100d,
CV_SymKind_LTHREAD32_ST = 0x100e,
CV_SymKind_GTHREAD32_ST = 0x100f,
CV_SymKind_LPROCMIPS_ST = 0x1010,
CV_SymKind_GPROCMIPS_ST = 0x1011,
CV_SymKind_FRAMEPROC = 0x1012,
CV_SymKind_COMPILE2_ST = 0x1013,
CV_SymKind_MANYREG2_ST = 0x1014,
CV_SymKind_LPROCIA64_ST = 0x1015,
CV_SymKind_GPROCIA64_ST = 0x1016,
CV_SymKind_LOCALSLOT_ST = 0x1017,
CV_SymKind_PARAMSLOT_ST = 0x1018,
CV_SymKind_ANNOTATION = 0x1019,
CV_SymKind_GMANPROC_ST = 0x101a,
CV_SymKind_LMANPROC_ST = 0x101b,
CV_SymKind_RESERVED1 = 0x101c,
CV_SymKind_RESERVED2 = 0x101d,
CV_SymKind_RESERVED3 = 0x101e,
CV_SymKind_RESERVED4 = 0x101f,
CV_SymKind_LMANDATA_ST = 0x1020,
CV_SymKind_GMANDATA_ST = 0x1021,
CV_SymKind_MANFRAMEREL_ST = 0x1022,
CV_SymKind_MANREGISTER_ST = 0x1023,
CV_SymKind_MANSLOT_ST = 0x1024,
CV_SymKind_MANMANYREG_ST = 0x1025,
CV_SymKind_MANREGREL_ST = 0x1026,
CV_SymKind_MANMANYREG2_ST = 0x1027,
CV_SymKind_MANTYPREF = 0x1028,
CV_SymKind_UNAMESPACE_ST = 0x1029,
CV_SymKind_ST_MAX = 0x1100,
CV_SymKind_OBJNAME = 0x1101,
CV_SymKind_THUNK32 = 0x1102,
CV_SymKind_BLOCK32 = 0x1103,
CV_SymKind_WITH32 = 0x1104,
CV_SymKind_LABEL32 = 0x1105,
CV_SymKind_REGISTER = 0x1106,
CV_SymKind_CONSTANT = 0x1107,
CV_SymKind_UDT = 0x1108,
CV_SymKind_COBOLUDT = 0x1109,
CV_SymKind_MANYREG = 0x110a,
CV_SymKind_BPREL32 = 0x110b,
CV_SymKind_LDATA32 = 0x110c,
CV_SymKind_GDATA32 = 0x110d,
CV_SymKind_PUB32 = 0x110e,
CV_SymKind_LPROC32 = 0x110f,
CV_SymKind_GPROC32 = 0x1110,
CV_SymKind_REGREL32 = 0x1111,
CV_SymKind_LTHREAD32 = 0x1112,
CV_SymKind_GTHREAD32 = 0x1113,
CV_SymKind_LPROCMIPS = 0x1114,
CV_SymKind_GPROCMIPS = 0x1115,
CV_SymKind_COMPILE2 = 0x1116,
CV_SymKind_MANYREG2 = 0x1117,
CV_SymKind_LPROCIA64 = 0x1118,
CV_SymKind_GPROCIA64 = 0x1119,
CV_SymKind_LOCALSLOT = 0x111a,
CV_SymKind_PARAMSLOT = 0x111b,
CV_SymKind_LMANDATA = 0x111c,
CV_SymKind_GMANDATA = 0x111d,
CV_SymKind_MANFRAMEREL = 0x111e,
CV_SymKind_MANREGISTER = 0x111f,
CV_SymKind_MANSLOT = 0x1120,
CV_SymKind_MANMANYREG = 0x1121,
CV_SymKind_MANREGREL = 0x1122,
CV_SymKind_MANMANYREG2 = 0x1123,
CV_SymKind_UNAMESPACE = 0x1124,
CV_SymKind_PROCREF = 0x1125,
CV_SymKind_DATAREF = 0x1126,
CV_SymKind_LPROCREF = 0x1127,
CV_SymKind_ANNOTATIONREF = 0x1128,
CV_SymKind_TOKENREF = 0x1129,
CV_SymKind_GMANPROC = 0x112a,
CV_SymKind_LMANPROC = 0x112b,
CV_SymKind_TRAMPOLINE = 0x112c,
CV_SymKind_MANCONSTANT = 0x112d,
CV_SymKind_ATTR_FRAMEREL = 0x112e,
CV_SymKind_ATTR_REGISTER = 0x112f,
CV_SymKind_ATTR_REGREL = 0x1130,
CV_SymKind_ATTR_MANYREG = 0x1131,
CV_SymKind_SEPCODE = 0x1132,
CV_SymKind_DEFRANGE_2005 = 0x1134,
CV_SymKind_DEFRANGE2_2005 = 0x1135,
CV_SymKind_SECTION = 0x1136,
CV_SymKind_COFFGROUP = 0x1137,
CV_SymKind_EXPORT = 0x1138,
CV_SymKind_CALLSITEINFO = 0x1139,
CV_SymKind_FRAMECOOKIE = 0x113a,
CV_SymKind_DISCARDED = 0x113b,
CV_SymKind_COMPILE3 = 0x113c,
CV_SymKind_ENVBLOCK = 0x113d,
CV_SymKind_LOCAL = 0x113e,
CV_SymKind_DEFRANGE = 0x113f,
CV_SymKind_DEFRANGE_SUBFIELD = 0x1140,
CV_SymKind_DEFRANGE_REGISTER = 0x1141,
CV_SymKind_DEFRANGE_FRAMEPOINTER_REL = 0x1142,
CV_SymKind_DEFRANGE_SUBFIELD_REGISTER = 0x1143,
CV_SymKind_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144,
CV_SymKind_DEFRANGE_REGISTER_REL = 0x1145,
CV_SymKind_LPROC32_ID = 0x1146,
CV_SymKind_GPROC32_ID = 0x1147,
CV_SymKind_LPROCMIPS_ID = 0x1148,
CV_SymKind_GPROCMIPS_ID = 0x1149,
CV_SymKind_LPROCIA64_ID = 0x114a,
CV_SymKind_GPROCIA64_ID = 0x114b,
CV_SymKind_BUILDINFO = 0x114c,
CV_SymKind_INLINESITE = 0x114d,
CV_SymKind_INLINESITE_END = 0x114e,
CV_SymKind_PROC_ID_END = 0x114f,
CV_SymKind_DEFRANGE_HLSL = 0x1150,
CV_SymKind_GDATA_HLSL = 0x1151,
CV_SymKind_LDATA_HLSL = 0x1152,
CV_SymKind_FILESTATIC = 0x1153,
CV_SymKind_LPROC32_DPC = 0x1155,
CV_SymKind_LPROC32_DPC_ID = 0x1156,
CV_SymKind_DEFRANGE_DPC_PTR_TAG = 0x1157,
CV_SymKind_DPC_SYM_TAG_MAP = 0x1158,
CV_SymKind_ARMSWITCHTABLE = 0x1159,
CV_SymKind_CALLEES = 0x115a,
CV_SymKind_CALLERS = 0x115b,
CV_SymKind_POGODATA = 0x115c,
CV_SymKind_INLINESITE2 = 0x115d,
CV_SymKind_HEAPALLOCSITE = 0x115e,
CV_SymKind_MOD_TYPEREF = 0x115f,
CV_SymKind_REF_MINIPDB = 0x1160,
CV_SymKind_PDBMAP = 0x1161,
CV_SymKind_GDATA_HLSL32 = 0x1162,
CV_SymKind_LDATA_HLSL32 = 0x1163,
CV_SymKind_GDATA_HLSL32_EX = 0x1164,
CV_SymKind_LDATA_HLSL32_EX = 0x1165,
CV_SymKind_FASTLINK = 0x1167,
CV_SymKind_INLINEES = 0x1168,
} CV_SymKindEnum;
typedef U8 CV_BasicType;
typedef enum CV_BasicTypeEnum
{
CV_BasicType_NOTYPE = 0x00,
CV_BasicType_ABS = 0x01,
CV_BasicType_SEGMENT = 0x02,
CV_BasicType_VOID = 0x03,
CV_BasicType_CURRENCY = 0x04,
CV_BasicType_NBASICSTR = 0x05,
CV_BasicType_FBASICSTR = 0x06,
CV_BasicType_NOTTRANS = 0x07,
CV_BasicType_HRESULT = 0x08,
CV_BasicType_CHAR = 0x10,
CV_BasicType_SHORT = 0x11,
CV_BasicType_LONG = 0x12,
CV_BasicType_QUAD = 0x13,
CV_BasicType_OCT = 0x14,
CV_BasicType_UCHAR = 0x20,
CV_BasicType_USHORT = 0x21,
CV_BasicType_ULONG = 0x22,
CV_BasicType_UQUAD = 0x23,
CV_BasicType_UOCT = 0x24,
CV_BasicType_BOOL8 = 0x30,
CV_BasicType_BOOL16 = 0x31,
CV_BasicType_BOOL32 = 0x32,
CV_BasicType_BOOL64 = 0x33,
CV_BasicType_FLOAT32 = 0x40,
CV_BasicType_FLOAT64 = 0x41,
CV_BasicType_FLOAT80 = 0x42,
CV_BasicType_FLOAT128 = 0x43,
CV_BasicType_FLOAT48 = 0x44,
CV_BasicType_FLOAT32PP = 0x45,
CV_BasicType_FLOAT16 = 0x46,
CV_BasicType_COMPLEX32 = 0x50,
CV_BasicType_COMPLEX64 = 0x51,
CV_BasicType_COMPLEX80 = 0x52,
CV_BasicType_COMPLEX128 = 0x53,
CV_BasicType_BIT = 0x60,
CV_BasicType_PASCHAR = 0x61,
CV_BasicType_BOOL32FF = 0x62,
CV_BasicType_INT8 = 0x68,
CV_BasicType_UINT8 = 0x69,
CV_BasicType_RCHAR = 0x70,
CV_BasicType_WCHAR = 0x71,
CV_BasicType_INT16 = 0x72,
CV_BasicType_UINT16 = 0x73,
CV_BasicType_INT32 = 0x74,
CV_BasicType_UINT32 = 0x75,
CV_BasicType_INT64 = 0x76,
CV_BasicType_UINT64 = 0x77,
CV_BasicType_INT128 = 0x78,
CV_BasicType_UINT128 = 0x79,
CV_BasicType_CHAR16 = 0x7a,
CV_BasicType_CHAR32 = 0x7b,
CV_BasicType_CHAR8 = 0x7c,
CV_BasicType_PTR = 0xf0,
} CV_BasicTypeEnum;
typedef U16 CV_LeafKind;
typedef enum CV_LeafKindEnum
{
CV_LeafKind_NOTYPE = 0x0000,
CV_LeafKind_MODIFIER_16t = 0x0001,
CV_LeafKind_POINTER_16t = 0x0002,
CV_LeafKind_ARRAY_16t = 0x0003,
CV_LeafKind_CLASS_16t = 0x0004,
CV_LeafKind_STRUCTURE_16t = 0x0005,
CV_LeafKind_UNION_16t = 0x0006,
CV_LeafKind_ENUM_16t = 0x0007,
CV_LeafKind_PROCEDURE_16t = 0x0008,
CV_LeafKind_MFUNCTION_16t = 0x0009,
CV_LeafKind_VTSHAPE = 0x000a,
CV_LeafKind_COBOL0_16t = 0x000b,
CV_LeafKind_COBOL1 = 0x000c,
CV_LeafKind_BARRAY_16t = 0x000d,
CV_LeafKind_LABEL = 0x000e,
CV_LeafKind_NULL = 0x000f,
CV_LeafKind_NOTTRAN = 0x0010,
CV_LeafKind_DIMARRAY_16t = 0x0011,
CV_LeafKind_VFTPATH_16t = 0x0012,
CV_LeafKind_PRECOMP_16t = 0x0013,
CV_LeafKind_ENDPRECOMP = 0x0014,
CV_LeafKind_OEM_16t = 0x0015,
CV_LeafKind_TYPESERVER_ST = 0x0016,
CV_LeafKind_SKIP_16t = 0x0200,
CV_LeafKind_ARGLIST_16t = 0x0201,
CV_LeafKind_DEFARG_16t = 0x0202,
CV_LeafKind_LIST = 0x0203,
CV_LeafKind_FIELDLIST_16t = 0x0204,
CV_LeafKind_DERIVED_16t = 0x0205,
CV_LeafKind_BITFIELD_16t = 0x0206,
CV_LeafKind_METHODLIST_16t = 0x0207,
CV_LeafKind_DIMCONU_16t = 0x0208,
CV_LeafKind_DIMCONLU_16t = 0x0209,
CV_LeafKind_DIMVARU_16t = 0x020a,
CV_LeafKind_DIMVARLU_16t = 0x020b,
CV_LeafKind_REFSYM = 0x020c,
CV_LeafKind_BCLASS_16t = 0x0400,
CV_LeafKind_VBCLASS_16t = 0x0401,
CV_LeafKind_IVBCLASS_16t = 0x0402,
CV_LeafKind_ENUMERATE_ST = 0x0403,
CV_LeafKind_FRIENDFCN_16t = 0x0404,
CV_LeafKind_INDEX_16t = 0x0405,
CV_LeafKind_MEMBER_16t = 0x0406,
CV_LeafKind_STMEMBER_16t = 0x0407,
CV_LeafKind_METHOD_16t = 0x0408,
CV_LeafKind_NESTTYPE_16t = 0x0409,
CV_LeafKind_VFUNCTAB_16t = 0x040a,
CV_LeafKind_FRIENDCLS_16t = 0x040b,
CV_LeafKind_ONEMETHOD_16t = 0x040c,
CV_LeafKind_VFUNCOFF_16t = 0x040d,
CV_LeafKind_TI16_MAX = 0x1000,
CV_LeafKind_MODIFIER = 0x1001,
CV_LeafKind_POINTER = 0x1002,
CV_LeafKind_ARRAY_ST = 0x1003,
CV_LeafKind_CLASS_ST = 0x1004,
CV_LeafKind_STRUCTURE_ST = 0x1005,
CV_LeafKind_UNION_ST = 0x1006,
CV_LeafKind_ENUM_ST = 0x1007,
CV_LeafKind_PROCEDURE = 0x1008,
CV_LeafKind_MFUNCTION = 0x1009,
CV_LeafKind_COBOL0 = 0x100a,
CV_LeafKind_BARRAY = 0x100b,
CV_LeafKind_DIMARRAY_ST = 0x100c,
CV_LeafKind_VFTPATH = 0x100d,
CV_LeafKind_PRECOMP_ST = 0x100e,
CV_LeafKind_OEM = 0x100f,
CV_LeafKind_ALIAS_ST = 0x1010,
CV_LeafKind_OEM2 = 0x1011,
CV_LeafKind_SKIP = 0x1200,
CV_LeafKind_ARGLIST = 0x1201,
CV_LeafKind_DEFARG_ST = 0x1202,
CV_LeafKind_FIELDLIST = 0x1203,
CV_LeafKind_DERIVED = 0x1204,
CV_LeafKind_BITFIELD = 0x1205,
CV_LeafKind_METHODLIST = 0x1206,
CV_LeafKind_DIMCONU = 0x1207,
CV_LeafKind_DIMCONLU = 0x1208,
CV_LeafKind_DIMVARU = 0x1209,
CV_LeafKind_DIMVARLU = 0x120a,
CV_LeafKind_BCLASS = 0x1400,
CV_LeafKind_VBCLASS = 0x1401,
CV_LeafKind_IVBCLASS = 0x1402,
CV_LeafKind_FRIENDFCN_ST = 0x1403,
CV_LeafKind_INDEX = 0x1404,
CV_LeafKind_MEMBER_ST = 0x1405,
CV_LeafKind_STMEMBER_ST = 0x1406,
CV_LeafKind_METHOD_ST = 0x1407,
CV_LeafKind_NESTTYPE_ST = 0x1408,
CV_LeafKind_VFUNCTAB = 0x1409,
CV_LeafKind_FRIENDCLS = 0x140a,
CV_LeafKind_ONEMETHOD_ST = 0x140b,
CV_LeafKind_VFUNCOFF = 0x140c,
CV_LeafKind_NESTTYPEEX_ST = 0x140d,
CV_LeafKind_MEMBERMODIFY_ST = 0x140e,
CV_LeafKind_MANAGED_ST = 0x140f,
CV_LeafKind_ST_MAX = 0x1500,
CV_LeafKind_TYPESERVER = 0x1501,
CV_LeafKind_ENUMERATE = 0x1502,
CV_LeafKind_ARRAY = 0x1503,
CV_LeafKind_CLASS = 0x1504,
CV_LeafKind_STRUCTURE = 0x1505,
CV_LeafKind_UNION = 0x1506,
CV_LeafKind_ENUM = 0x1507,
CV_LeafKind_DIMARRAY = 0x1508,
CV_LeafKind_PRECOMP = 0x1509,
CV_LeafKind_ALIAS = 0x150a,
CV_LeafKind_DEFARG = 0x150b,
CV_LeafKind_FRIENDFCN = 0x150c,
CV_LeafKind_MEMBER = 0x150d,
CV_LeafKind_STMEMBER = 0x150e,
CV_LeafKind_METHOD = 0x150f,
CV_LeafKind_NESTTYPE = 0x1510,
CV_LeafKind_ONEMETHOD = 0x1511,
CV_LeafKind_NESTTYPEEX = 0x1512,
CV_LeafKind_MEMBERMODIFY = 0x1513,
CV_LeafKind_MANAGED = 0x1514,
CV_LeafKind_TYPESERVER2 = 0x1515,
CV_LeafKind_STRIDED_ARRAY = 0x1516,
CV_LeafKind_HLSL = 0x1517,
CV_LeafKind_MODIFIER_EX = 0x1518,
CV_LeafKind_INTERFACE = 0x1519,
CV_LeafKind_BINTERFACE = 0x151a,
CV_LeafKind_VECTOR = 0x151b,
CV_LeafKind_MATRIX = 0x151c,
CV_LeafKind_VFTABLE = 0x151d,
CV_LeafKind_FUNC_ID = 0x1601,
CV_LeafKind_MFUNC_ID = 0x1602,
CV_LeafKind_BUILDINFO = 0x1603,
CV_LeafKind_SUBSTR_LIST = 0x1604,
CV_LeafKind_STRING_ID = 0x1605,
CV_LeafKind_UDT_SRC_LINE = 0x1606,
CV_LeafKind_UDT_MOD_SRC_LINE = 0x1607,
CV_LeafKind_CLASS2 = 0x1608,
CV_LeafKind_STRUCT2 = 0x1609,
} CV_LeafKindEnum;
internal String8 cv_string_from_numeric_kind(CV_NumericKind v);
internal String8 cv_string_from_arch(CV_Arch v);
internal String8 cv_string_from_sym_kind(CV_SymKind v);
internal String8 cv_string_from_basic_type(CV_BasicType v);
internal String8 cv_type_name_from_basic_type(CV_BasicType v);
internal String8 cv_string_from_leaf_kind(CV_LeafKind v);
internal U64 cv_header_struct_size_from_sym_kind(CV_SymKind v);
internal U64 cv_header_struct_size_from_leaf_kind(CV_LeafKind v);
#endif // CODEVIEW_META_H
+1395 -1119
View File
File diff suppressed because it is too large. Load diff
+319 -287
View File
@@ -11,6 +11,16 @@ typedef U32 COFF_TimeStamp;
#pragma pack(push,1) #pragma pack(push,1)
typedef struct COFF_Guid COFF_Guid;
struct COFF_Guid
{
U32 data1;
U16 data2;
U16 data3;
U32 data4;
U32 data5;
};
typedef U16 COFF_Flags; typedef U16 COFF_Flags;
enum enum
{ {
@@ -38,7 +48,7 @@ enum
COFF_MachineType_UNKNOWN = 0x0, COFF_MachineType_UNKNOWN = 0x0,
COFF_MachineType_X86 = 0x14c, COFF_MachineType_X86 = 0x14c,
COFF_MachineType_X64 = 0x8664, COFF_MachineType_X64 = 0x8664,
COFF_MachineType_ARM33 = 0x1d3, COFF_MachineType_AM33 = 0x1d3,
COFF_MachineType_ARM = 0x1c0, COFF_MachineType_ARM = 0x1c0,
COFF_MachineType_ARM64 = 0xaa64, COFF_MachineType_ARM64 = 0xaa64,
COFF_MachineType_ARMNT = 0x1c4, COFF_MachineType_ARMNT = 0x1c4,
@@ -67,12 +77,12 @@ typedef struct COFF_Header COFF_Header;
struct COFF_Header struct COFF_Header
{ {
COFF_MachineType machine; COFF_MachineType machine;
U16 section_count; U16 section_count;
COFF_TimeStamp time_stamp; COFF_TimeStamp time_stamp;
U32 symbol_table_foff; U32 symbol_table_foff;
U32 symbol_count; U32 symbol_count;
U16 optional_header_size; U16 optional_header_size;
COFF_Flags flags; COFF_Flags flags;
}; };
typedef U32 COFF_SectionAlign; typedef U32 COFF_SectionAlign;
@@ -98,35 +108,36 @@ enum
typedef U32 COFF_SectionFlags; typedef U32 COFF_SectionFlags;
enum enum
{ {
COFF_SectionFlag_TYPE_NO_PAD = (1 << 3), COFF_SectionFlag_TYPE_NO_PAD = (1 << 3),
COFF_SectionFlag_CNT_CODE = (1 << 5), COFF_SectionFlag_CNT_CODE = (1 << 5),
COFF_SectionFlag_CNT_INITIALIZED_DATA = (1 << 6), COFF_SectionFlag_CNT_INITIALIZED_DATA = (1 << 6),
COFF_SectionFlag_CNT_UNINITIALIZED_DATA = (1 << 7), COFF_SectionFlag_CNT_UNINITIALIZED_DATA = (1 << 7),
COFF_SectionFlag_LNK_OTHER = (1 << 8), COFF_SectionFlag_LNK_OTHER = (1 << 8),
COFF_SectionFlag_LNK_INFO = (1 << 9), COFF_SectionFlag_LNK_INFO = (1 << 9),
COFF_SectionFlag_LNK_REMOVE = (1 << 11), COFF_SectionFlag_LNK_REMOVE = (1 << 11),
COFF_SectionFlag_LNK_COMDAT = (1 << 12), COFF_SectionFlag_LNK_COMDAT = (1 << 12),
COFF_SectionFlag_GPREL = (1 << 15), COFF_SectionFlag_GPREL = (1 << 15),
COFF_SectionFlag_MEM_16BIT = (1 << 17), COFF_SectionFlag_MEM_16BIT = (1 << 17),
COFF_SectionFlag_MEM_LOCKED = (1 << 18), COFF_SectionFlag_MEM_LOCKED = (1 << 18),
COFF_SectionFlag_MEM_PRELOAD = (1 << 19), COFF_SectionFlag_MEM_PRELOAD = (1 << 19),
COFF_SectionFlag_ALIGN_SHIFT = 20, COFF_SectionFlag_ALIGN_MASK = 0xf, COFF_SectionFlag_ALIGN_SHIFT = 20,
COFF_SectionFlag_LNK_NRELOC_OVFL = (1 << 24), COFF_SectionFlag_ALIGN_MASK = 0xf,
COFF_SectionFlag_MEM_DISCARDABLE = (1 << 25), COFF_SectionFlag_LNK_NRELOC_OVFL = (1 << 24),
COFF_SectionFlag_MEM_NOT_CACHED = (1 << 26), COFF_SectionFlag_MEM_DISCARDABLE = (1 << 25),
COFF_SectionFlag_MEM_NOT_PAGED = (1 << 27), COFF_SectionFlag_MEM_NOT_CACHED = (1 << 26),
COFF_SectionFlag_MEM_SHARED = (1 << 28), COFF_SectionFlag_MEM_NOT_PAGED = (1 << 27),
COFF_SectionFlag_MEM_EXECUTE = (1 << 29), COFF_SectionFlag_MEM_SHARED = (1 << 28),
COFF_SectionFlag_MEM_READ = (1 << 30), COFF_SectionFlag_MEM_EXECUTE = (1 << 29),
COFF_SectionFlag_MEM_WRITE = (1 << 31), COFF_SectionFlag_MEM_READ = (1 << 30),
COFF_SectionFlag_MEM_WRITE = (1 << 31),
}; };
#define COFF_SectionFlags_Extract_ALIGN(f) (COFF_SectionAlign)(((f) >> COFF_SectionFlag_ALIGN_SHIFT) & COFF_SectionFlag_ALIGN_MASK) #define COFF_SectionFlags_Extract_ALIGN(f) (COFF_SectionAlign)(((f) >> COFF_SectionFlag_ALIGN_SHIFT) & COFF_SectionFlag_ALIGN_MASK)
#define COFF_SectionFlags_LNK_FLAGS ((COFF_SectionFlag_ALIGN_MASK << COFF_SectionFlag_ALIGN_SHIFT) | COFF_SectionFlag_LNK_COMDAT | COFF_SectionFlag_LNK_INFO | COFF_SectionFlag_LNK_OTHER | COFF_SectionFlag_LNK_REMOVE | COFF_SectionFlag_LNK_NRELOC_OVFL) #define COFF_SectionFlags_LNK_FLAGS ((COFF_SectionFlag_ALIGN_MASK << COFF_SectionFlag_ALIGN_SHIFT) | COFF_SectionFlag_LNK_COMDAT | COFF_SectionFlag_LNK_INFO | COFF_SectionFlag_LNK_OTHER | COFF_SectionFlag_LNK_REMOVE | COFF_SectionFlag_LNK_NRELOC_OVFL)
typedef struct COFF_SectionHeader COFF_SectionHeader; typedef struct COFF_SectionHeader COFF_SectionHeader;
struct COFF_SectionHeader struct COFF_SectionHeader
{ {
U8 name[8]; U8 name[8];
U32 vsize; U32 vsize;
U32 voff; U32 voff;
U32 fsize; U32 fsize;
@@ -141,112 +152,99 @@ struct COFF_SectionHeader
typedef U16 COFF_RelocTypeX64; typedef U16 COFF_RelocTypeX64;
enum enum
{ {
COFF_RelocTypeX64_ABS = 0x0, COFF_RelocTypeX64_ABS = 0x0,
COFF_RelocTypeX64_ADDR64 = 0x1, COFF_RelocTypeX64_ADDR64 = 0x1,
COFF_RelocTypeX64_ADDR32 = 0x2, COFF_RelocTypeX64_ADDR32 = 0x2,
COFF_RelocTypeX64_ADDR32NB = 0x3, COFF_RelocTypeX64_ADDR32NB = 0x3, // NB => No Base
// NB => No Base COFF_RelocTypeX64_REL32 = 0x4,
COFF_RelocTypeX64_REL32 = 0x4, COFF_RelocTypeX64_REL32_1 = 0x5,
COFF_RelocTypeX64_REL32_1 = 0x5, COFF_RelocTypeX64_REL32_2 = 0x6,
COFF_RelocTypeX64_REL32_2 = 0x6, COFF_RelocTypeX64_REL32_3 = 0x7,
COFF_RelocTypeX64_REL32_3 = 0x7, COFF_RelocTypeX64_REL32_4 = 0x8,
COFF_RelocTypeX64_REL32_4 = 0x8, COFF_RelocTypeX64_REL32_5 = 0x9,
COFF_RelocTypeX64_REL32_5 = 0x9, COFF_RelocTypeX64_SECTION = 0xA,
COFF_RelocTypeX64_SECTION = 0xA, COFF_RelocTypeX64_SECREL = 0xB,
COFF_RelocTypeX64_SECREL = 0xB, COFF_RelocTypeX64_SECREL7 = 0xC, // TODO(nick): MSDN doesn't specify size for CLR token
COFF_RelocTypeX64_SECREL7 = 0xC, COFF_RelocTypeX64_TOKEN = 0xD,
// TODO(nick): MSDN doesn't specify size for CLR token COFF_RelocTypeX64_SREL32 = 0xE, // TODO(nick): MSDN doesn't specify size for PAIR
COFF_RelocTypeX64_TOKEN = 0xD, COFF_RelocTypeX64_PAIR = 0xF,
COFF_RelocTypeX64_SREL32 = 0xE, COFF_RelocTypeX64_SSPAN32 = 0x10,
// TODO(nick): MSDN doesn't specify size for PAIR COFF_RelocTypeX64_COUNT = 17
COFF_RelocTypeX64_PAIR = 0xF,
COFF_RelocTypeX64_SSPAN32 = 0x10,
COFF_RelocTypeX64_COUNT = 17
}; };
typedef U16 COFF_RelocTypeX86; typedef U16 COFF_RelocTypeX86;
enum enum
{ {
COFF_RelocTypeX86_ABS = 0x0, COFF_RelocTypeX86_ABS = 0x0, // relocation is ignored
// relocation is ignored COFF_RelocTypeX86_DIR16 = 0x1, // no support
COFF_RelocTypeX86_DIR16 = 0x1, COFF_RelocTypeX86_REL16 = 0x2, // no support
// no support COFF_RelocTypeX86_UNKNOWN0 = 0x3,
COFF_RelocTypeX86_REL16 = 0x2, COFF_RelocTypeX86_UNKNOWN2 = 0x4,
// no support COFF_RelocTypeX86_UNKNOWN3 = 0x5,
COFF_RelocTypeX86_UNKNOWN0 = 0x3, COFF_RelocTypeX86_DIR32 = 0x6, // 32-bit virtual address
COFF_RelocTypeX86_UNKNOWN2 = 0x4, COFF_RelocTypeX86_DIR32NB = 0x7, // 32-bit virtual offset
COFF_RelocTypeX86_UNKNOWN3 = 0x5, COFF_RelocTypeX86_SEG12 = 0x9, // no support
COFF_RelocTypeX86_DIR32 = 0x6, COFF_RelocTypeX86_SECTION = 0xA, // 16-bit section index, used for debug info purposes
// 32-bit virtual address COFF_RelocTypeX86_SECREL = 0xB, // 32-bit offset from start of a section
COFF_RelocTypeX86_DIR32NB = 0x7, COFF_RelocTypeX86_TOKEN = 0xC, // CLR token? (for managed languages)
// 32-bit virtual offset COFF_RelocTypeX86_SECREL7 = 0xD, // 7-bit offset from the base of the section that contains the target.
COFF_RelocTypeX86_SEG12 = 0x9, COFF_RelocTypeX86_UNKNOWN4 = 0xE,
// no support COFF_RelocTypeX86_UNKNOWN5 = 0xF,
COFF_RelocTypeX86_SECTION = 0xA, COFF_RelocTypeX86_UNKNOWN6 = 0x10,
// 16-bit section index, used for debug info purposes COFF_RelocTypeX86_UNKNOWN7 = 0x11,
COFF_RelocTypeX86_SECREL = 0xB, COFF_RelocTypeX86_UNKNOWN8 = 0x12,
// 32-bit offset from start of a section COFF_RelocTypeX86_UNKNOWN9 = 0x13,
COFF_RelocTypeX86_TOKEN = 0xC, COFF_RelocTypeX86_REL32 = 0x14,
// CLR token? (for managed languages) COFF_RelocTypeX86_COUNT = 20
COFF_RelocTypeX86_SECREL7 = 0xD,
// 7-bit offset from the base of the section that contains the target.
COFF_RelocTypeX86_UNKNOWN4 = 0xE,
COFF_RelocTypeX86_UNKNOWN5 = 0xF,
COFF_RelocTypeX86_UNKNOWN6 = 0x10,
COFF_RelocTypeX86_UNKNOWN7 = 0x11,
COFF_RelocTypeX86_UNKNOWN8 = 0x12,
COFF_RelocTypeX86_UNKNOWN9 = 0x13,
COFF_RelocTypeX86_REL32 = 0x14,
COFF_RelocTypeX86_COUNT = 20
}; };
typedef U16 COFF_RelocTypeARM; typedef U16 COFF_RelocTypeARM;
enum enum
{ {
COFF_RelocTypeARM_ABS = 0x0, COFF_RelocTypeARM_ABS = 0x0,
COFF_RelocTypeARM_ADDR32 = 0x1, COFF_RelocTypeARM_ADDR32 = 0x1,
COFF_RelocTypeARM_ADDR32NB = 0x2, COFF_RelocTypeARM_ADDR32NB = 0x2,
COFF_RelocTypeARM_BRANCH24 = 0x3, COFF_RelocTypeARM_BRANCH24 = 0x3,
COFF_RelocTypeARM_BRANCH11 = 0x4, COFF_RelocTypeARM_BRANCH11 = 0x4,
COFF_RelocTypeARM_UNKNOWN1 = 0x5, COFF_RelocTypeARM_UNKNOWN1 = 0x5,
COFF_RelocTypeARM_UNKNOWN2 = 0x6, COFF_RelocTypeARM_UNKNOWN2 = 0x6,
COFF_RelocTypeARM_UNKNOWN3 = 0x7, COFF_RelocTypeARM_UNKNOWN3 = 0x7,
COFF_RelocTypeARM_UNKNOWN4 = 0x8, COFF_RelocTypeARM_UNKNOWN4 = 0x8,
COFF_RelocTypeARM_UNKNOWN5 = 0x9, COFF_RelocTypeARM_UNKNOWN5 = 0x9,
COFF_RelocTypeARM_REL32 = 0xA, COFF_RelocTypeARM_REL32 = 0xA,
COFF_RelocTypeARM_SECTION = 0xE, COFF_RelocTypeARM_SECTION = 0xE,
COFF_RelocTypeARM_SECREL = 0xF, COFF_RelocTypeARM_SECREL = 0xF,
COFF_RelocTypeARM_MOV32 = 0x10, COFF_RelocTypeARM_MOV32 = 0x10,
COFF_RelocTypeARM_THUMB_MOV32 = 0x11, COFF_RelocTypeARM_THUMB_MOV32 = 0x11,
COFF_RelocTypeARM_THUMB_BRANCH20 = 0x12, COFF_RelocTypeARM_THUMB_BRANCH20 = 0x12,
COFF_RelocTypeARM_UNUSED = 0x13, COFF_RelocTypeARM_UNUSED = 0x13,
COFF_RelocTypeARM_THUMB_BRANCH24 = 0x14, COFF_RelocTypeARM_THUMB_BRANCH24 = 0x14,
COFF_RelocTypeARM_THUMB_BLX23 = 0x15, COFF_RelocTypeARM_THUMB_BLX23 = 0x15,
COFF_RelocTypeARM_PAIR = 0x16, COFF_RelocTypeARM_PAIR = 0x16,
COFF_RelocTypeARM_COUNT = 20 COFF_RelocTypeARM_COUNT = 20
}; };
typedef U16 COFF_RelocTypeARM64; typedef U16 COFF_RelocTypeARM64;
enum enum
{ {
COFF_RelocTypeARM64_ABS = 0x0, COFF_RelocTypeARM64_ABS = 0x0,
COFF_RelocTypeARM64_ADDR32 = 0x1, COFF_RelocTypeARM64_ADDR32 = 0x1,
COFF_RelocTypeARM64_ADDR32NB = 0x2, COFF_RelocTypeARM64_ADDR32NB = 0x2,
COFF_RelocTypeARM64_BRANCH26 = 0x3, COFF_RelocTypeARM64_BRANCH26 = 0x3,
COFF_RelocTypeARM64_PAGEBASE_REL21 = 0x4, COFF_RelocTypeARM64_PAGEBASE_REL21 = 0x4,
COFF_RelocTypeARM64_REL21 = 0x5, COFF_RelocTypeARM64_REL21 = 0x5,
COFF_RelocTypeARM64_PAGEOFFSET_12A = 0x6, COFF_RelocTypeARM64_PAGEOFFSET_12A = 0x6,
COFF_RelocTypeARM64_SECREL = 0x8, COFF_RelocTypeARM64_SECREL = 0x8,
COFF_RelocTypeARM64_SECREL_LOW12A = 0x9, COFF_RelocTypeARM64_SECREL_LOW12A = 0x9,
COFF_RelocTypeARM64_SECREL_HIGH12A = 0xA, COFF_RelocTypeARM64_SECREL_HIGH12A = 0xA,
COFF_RelocTypeARM64_SECREL_LOW12L = 0xB, COFF_RelocTypeARM64_SECREL_LOW12L = 0xB,
COFF_RelocTypeARM64_TOKEN = 0xC, COFF_RelocTypeARM64_TOKEN = 0xC,
COFF_RelocTypeARM64_SECTION = 0xD, COFF_RelocTypeARM64_SECTION = 0xD,
COFF_RelocTypeARM64_ADDR64 = 0xE, COFF_RelocTypeARM64_ADDR64 = 0xE,
COFF_RelocTypeARM64_BRANCH19 = 0xF, COFF_RelocTypeARM64_BRANCH19 = 0xF,
COFF_RelocTypeARM64_BRANCH14 = 0x10, COFF_RelocTypeARM64_BRANCH14 = 0x10,
COFF_RelocTypeARM64_REL32 = 0x11, COFF_RelocTypeARM64_REL32 = 0x11,
COFF_RelocTypeARM64_COUNT = 17 COFF_RelocTypeARM64_COUNT = 17
}; };
typedef U8 COFF_SymType; typedef U8 COFF_SymType;
@@ -263,8 +261,7 @@ enum
COFF_SymType_STRUCT, COFF_SymType_STRUCT,
COFF_SymType_UNION, COFF_SymType_UNION,
COFF_SymType_ENUM, COFF_SymType_ENUM,
COFF_SymType_MOE, COFF_SymType_MOE, // member of enumeration
// member of enumeration
COFF_SymType_BYTE, COFF_SymType_BYTE,
COFF_SymType_WORD, COFF_SymType_WORD,
COFF_SymType_UINT, COFF_SymType_UINT,
@@ -275,100 +272,100 @@ enum
typedef U8 COFF_SymStorageClass; typedef U8 COFF_SymStorageClass;
enum enum
{ {
COFF_SymStorageClass_END_OF_FUNCTION = 0xff, COFF_SymStorageClass_END_OF_FUNCTION = 0xff,
COFF_SymStorageClass_NULL = 0, COFF_SymStorageClass_NULL = 0,
COFF_SymStorageClass_AUTOMATIC = 1, COFF_SymStorageClass_AUTOMATIC = 1,
COFF_SymStorageClass_EXTERNAL = 2, COFF_SymStorageClass_EXTERNAL = 2,
COFF_SymStorageClass_STATIC = 3, COFF_SymStorageClass_STATIC = 3,
COFF_SymStorageClass_REGISTER = 4, COFF_SymStorageClass_REGISTER = 4,
COFF_SymStorageClass_EXTERNAL_DEF = 5, COFF_SymStorageClass_EXTERNAL_DEF = 5,
COFF_SymStorageClass_LABEL = 6, COFF_SymStorageClass_LABEL = 6,
COFF_SymStorageClass_UNDEFINED_LABEL = 7, COFF_SymStorageClass_UNDEFINED_LABEL = 7,
COFF_SymStorageClass_MEMBER_OF_STRUCT = 8, COFF_SymStorageClass_MEMBER_OF_STRUCT = 8,
COFF_SymStorageClass_ARGUMENT = 9, COFF_SymStorageClass_ARGUMENT = 9,
COFF_SymStorageClass_STRUCT_TAG = 10, COFF_SymStorageClass_STRUCT_TAG = 10,
COFF_SymStorageClass_MEMBER_OF_UNION = 11, COFF_SymStorageClass_MEMBER_OF_UNION = 11,
COFF_SymStorageClass_UNION_TAG = 12, COFF_SymStorageClass_UNION_TAG = 12,
COFF_SymStorageClass_TYPE_DEFINITION = 13, COFF_SymStorageClass_TYPE_DEFINITION = 13,
COFF_SymStorageClass_UNDEFINED_STATIC = 14, COFF_SymStorageClass_UNDEFINED_STATIC = 14,
COFF_SymStorageClass_ENUM_TAG = 15, COFF_SymStorageClass_ENUM_TAG = 15,
COFF_SymStorageClass_MEMBER_OF_ENUM = 16, COFF_SymStorageClass_MEMBER_OF_ENUM = 16,
COFF_SymStorageClass_REGISTER_PARAM = 17, COFF_SymStorageClass_REGISTER_PARAM = 17,
COFF_SymStorageClass_BIT_FIELD = 18, COFF_SymStorageClass_BIT_FIELD = 18,
COFF_SymStorageClass_BLOCK = 100, COFF_SymStorageClass_BLOCK = 100,
COFF_SymStorageClass_FUNCTION = 101, COFF_SymStorageClass_FUNCTION = 101,
COFF_SymStorageClass_END_OF_STRUCT = 102, COFF_SymStorageClass_END_OF_STRUCT = 102,
COFF_SymStorageClass_FILE = 103, COFF_SymStorageClass_FILE = 103,
COFF_SymStorageClass_SECTION = 104, COFF_SymStorageClass_SECTION = 104,
COFF_SymStorageClass_WEAK_EXTERNAL = 105, COFF_SymStorageClass_WEAK_EXTERNAL = 105,
COFF_SymStorageClass_CLR_TOKEN = 107, COFF_SymStorageClass_CLR_TOKEN = 107,
COFF_SymStorageClass_COUNT = 27 COFF_SymStorageClass_COUNT = 27
}; };
typedef U16 COFF_SymSecNumber; typedef U16 COFF_SymSecNumber;
enum enum
{ {
COFF_SymSecNumber_NUMBER_UNDEFINED = 0, COFF_SymSecNumber_NUMBER_UNDEFINED = 0,
COFF_SymSecNumber_ABSOLUTE = 0xffff, COFF_SymSecNumber_ABSOLUTE = 0xffff,
COFF_SymSecNumber_DEBUG = 0xfffe, COFF_SymSecNumber_DEBUG = 0xfffe,
COFF_SymSecNumber_COUNT = 3 COFF_SymSecNumber_COUNT = 3
}; };
typedef U8 COFF_SymDType; typedef U8 COFF_SymDType;
enum enum
{ {
COFF_SymDType_NULL = 0, COFF_SymDType_NULL = 0,
COFF_SymDType_PTR = 16, COFF_SymDType_PTR = 16,
COFF_SymDType_FUNC = 32, COFF_SymDType_FUNC = 32,
COFF_SymDType_ARRAY = 48, COFF_SymDType_ARRAY = 48,
COFF_SymDType_COUNT = 4 COFF_SymDType_COUNT = 4
}; };
typedef U32 COFF_WeakExtType; typedef U32 COFF_WeakExtType;
enum enum
{ {
COFF_WeakExtType_NOLIBRARY = 1, COFF_WeakExtType_NOLIBRARY = 1,
COFF_WeakExtType_SEARCH_LIBRARY = 2, COFF_WeakExtType_SEARCH_LIBRARY = 2,
COFF_WeakExtType_SEARCH_ALIAS = 3, COFF_WeakExtType_SEARCH_ALIAS = 3,
COFF_WeakExtType_COUNT = 3 COFF_WeakExtType_COUNT = 3
}; };
typedef U32 COFF_ImportHeaderType; typedef U32 COFF_ImportHeaderType;
enum enum
{ {
COFF_ImportHeaderType_CODE = 0, COFF_ImportHeaderType_CODE = 0,
COFF_ImportHeaderType_DATA = 1, COFF_ImportHeaderType_DATA = 1,
COFF_ImportHeaderType_CONST = 2, COFF_ImportHeaderType_CONST = 2,
COFF_ImportHeaderType_COUNT = 3 COFF_ImportHeaderType_COUNT = 3
}; };
typedef U32 COFF_ImportHeaderNameType; typedef U32 COFF_ImportHeaderNameType;
enum enum
{ {
COFF_ImportHeaderNameType_ORDINAL = 0, COFF_ImportHeaderNameType_ORDINAL = 0,
COFF_ImportHeaderNameType_NAME = 1, COFF_ImportHeaderNameType_NAME = 1,
COFF_ImportHeaderNameType_NAME_NOPREFIX = 2, COFF_ImportHeaderNameType_NAME_NOPREFIX = 2,
COFF_ImportHeaderNameType_UNDECORATE = 3, COFF_ImportHeaderNameType_UNDECORATE = 3,
COFF_ImportHeaderNameType_COUNT = 4 COFF_ImportHeaderNameType_COUNT = 4
}; };
#define COFF_IMPORT_HEADER_TYPE_MASK 0x03 #define COFF_IMPORT_HEADER_TYPE_MASK 0x03
#define COFF_IMPORT_HEADER_TYPE_SHIFT 0 #define COFF_IMPORT_HEADER_TYPE_SHIFT 0
#define COFF_IMPORT_HEADER_NAME_TYPE_MASK 0x1c #define COFF_IMPORT_HEADER_NAME_TYPE_MASK 0x1c
#define COFF_IMPORT_HEADER_NAME_TYPE_SHIFT 2 #define COFF_IMPORT_HEADER_NAME_TYPE_SHIFT 2
#define COFF_IMPORT_HEADER_GET_TYPE(x) (((x) & COFF_IMPORT_HEADER_TYPE_MASK) >> COFF_IMPORT_HEADER_TYPE_SHIFT) #define COFF_IMPORT_HEADER_GET_TYPE(x) (((x) & COFF_IMPORT_HEADER_TYPE_MASK) >> COFF_IMPORT_HEADER_TYPE_SHIFT)
#define COFF_IMPORT_HEADER_GET_NAME_TYPE(x) (((x) & COFF_IMPORT_HEADER_NAME_TYPE_MASK) >> COFF_IMPORT_HEADER_NAME_TYPE_SHIFT) #define COFF_IMPORT_HEADER_GET_NAME_TYPE(x) (((x) & COFF_IMPORT_HEADER_NAME_TYPE_MASK) >> COFF_IMPORT_HEADER_NAME_TYPE_SHIFT)
typedef struct COFF_ImportHeader typedef struct COFF_ImportHeader
{ {
U16 sig1; U16 sig1;
U16 sig2; U16 sig2;
U16 version; U16 version;
U16 machine; U16 machine;
COFF_TimeStamp time_stamp; COFF_TimeStamp time_stamp;
U32 data_size; U32 data_size;
U16 hint; U16 hint;
U16 type; U16 type;
U16 name_type; U16 name_type;
// type : 2 // type : 2
// name type : 3 // name type : 3
// reserved : 11 // reserved : 11
@@ -380,30 +377,18 @@ typedef struct COFF_ImportHeader
typedef U8 COFF_ComdatSelectType; typedef U8 COFF_ComdatSelectType;
enum enum
{ {
COFF_ComdatSelectType_NULL = 0, COFF_ComdatSelectType_NULL = 0, // Only one symbol is allowed to be in global symbol table, otherwise multiply defintion error is thrown.
// Only one symbol is allowed to be in global symbol table, otherwise multiply defintion error is thrown. COFF_ComdatSelectType_NODUPLICATES = 1, // Select any symbol, even if there are multiple definitions. (we default to first declaration)
COFF_ComdatSelectType_NODUPLICATES = 1, COFF_ComdatSelectType_ANY = 2, // Sections that symbols reference must match in size, otherwise multiply definition error is thrown.
// Select any symbol, even if there are multiple definitions. (we default to first declaration) COFF_ComdatSelectType_SAME_SIZE = 3, // Sections that symbols reference must have identical checksums, otherwise multiply defintion error is thrown.
COFF_ComdatSelectType_ANY = 2, COFF_ComdatSelectType_EXACT_MATCH = 4, // Symbols with associative type form a chain of sections are related to each other. (next link is indicated in COFF_SecDef in 'number')
// Sections that symbols reference must match in size, otherwise multiply definition error is thrown. COFF_ComdatSelectType_ASSOCIATIVE = 5, // Linker selects section with largest size.
COFF_ComdatSelectType_SAME_SIZE = 3, COFF_ComdatSelectType_LARGEST = 6,
// Sections that symbols reference must have identical checksums, otherwise multiply defintion error is thrown. COFF_ComdatSelectType_COUNT = 7
COFF_ComdatSelectType_EXACT_MATCH = 4,
// Symbols with associative type form a chain of sections are related to each other. (next link is indicated in COFF_SecDef in 'number')
COFF_ComdatSelectType_ASSOCIATIVE = 5,
// Linker selects section with largest size.
COFF_ComdatSelectType_LARGEST = 6,
COFF_ComdatSelectType_COUNT = 7
}; };
#define COFF_MIN_BIG_OBJ_VERSION 2 #define COFF_MIN_BIG_OBJ_VERSION 2
global U8 coff_big_obj_magic[] =
{
0xC7,0xA1,0xBA,0xD1,0xEE,0xBA,0xA9,0x4B,
0xAF,0x20,0xFA,0xF6,0x6A,0xA4,0xDC,0xB8,
};
typedef struct COFF_HeaderBigObj COFF_HeaderBigObj; typedef struct COFF_HeaderBigObj COFF_HeaderBigObj;
struct COFF_HeaderBigObj struct COFF_HeaderBigObj
{ {
@@ -412,7 +397,7 @@ struct COFF_HeaderBigObj
U16 version; U16 version;
U16 machine; U16 machine;
U32 time_stamp; U32 time_stamp;
U8 magic[16]; U8 magic[16];
U32 unused[4]; U32 unused[4];
U32 section_count; U32 section_count;
U32 pointer_to_symbol_table; U32 pointer_to_symbol_table;
@@ -444,8 +429,8 @@ typedef struct COFF_Symbol16 COFF_Symbol16;
struct COFF_Symbol16 struct COFF_Symbol16
{ {
COFF_SymbolName name; COFF_SymbolName name;
U32 value; U32 value;
U16 section_number; U16 section_number;
union union
{ {
struct struct
@@ -463,8 +448,8 @@ typedef struct COFF_Symbol32 COFF_Symbol32;
struct COFF_Symbol32 struct COFF_Symbol32
{ {
COFF_SymbolName name; COFF_SymbolName name;
U32 value; U32 value;
U32 section_number; U32 section_number;
union union
{ {
struct struct
@@ -484,11 +469,11 @@ struct COFF_Symbol32
// storage class: FUNCTION // storage class: FUNCTION
typedef struct COFF_SymbolFunc typedef struct COFF_SymbolFunc
{ {
U8 unused[4]; U8 unused[4];
U16 ln; U16 ln;
U8 unused2[2]; U8 unused2[2];
U32 ptr_to_next_func; U32 ptr_to_next_func;
U8 unused3[2]; U8 unused3[2];
} COFF_SymbolFunc; } COFF_SymbolFunc;
// storage class: WEAK_EXTERNAL // storage class: WEAK_EXTERNAL
@@ -496,7 +481,7 @@ typedef struct COFF_SymbolWeakExt
{ {
U32 tag_index; U32 tag_index;
U32 characteristics; U32 characteristics;
U8 unused[10]; U8 unused[10];
} COFF_SymbolWeakExt; } COFF_SymbolWeakExt;
typedef struct COFF_SymbolFile typedef struct COFF_SymbolFile
@@ -512,9 +497,10 @@ typedef struct COFF_SymbolSecDef
U16 number_of_relocations; U16 number_of_relocations;
U16 number_of_ln; U16 number_of_ln;
U32 check_sum; U32 check_sum;
U16 number; // one-based section index U16 number_lo; // one-based section index
U8 selection; U8 selection;
U8 unused[3]; U8 unused;
U16 number_hi;
} COFF_SymbolSecDef; } COFF_SymbolSecDef;
// specifies how section data should be modified when placed in the image file. // specifies how section data should be modified when placed in the image file.
@@ -574,7 +560,7 @@ typedef struct COFF_ResourceID_16
COFF_ResourceIDType type; COFF_ResourceIDType type;
union union
{ {
U16 number; U16 number;
String16 string; String16 string;
} u; } u;
} COFF_ResourceID_16; } COFF_ResourceID_16;
@@ -584,20 +570,21 @@ typedef struct COFF_ResourceID
COFF_ResourceIDType type; COFF_ResourceIDType type;
union union
{ {
U16 number; U16 number;
String8 string; String8 string;
} u; } u;
} COFF_ResourceID; } COFF_ResourceID;
typedef struct COFF_Resource typedef struct COFF_Resource
{ {
COFF_ResourceID type; COFF_ResourceID type;
COFF_ResourceID name; COFF_ResourceID name;
U16 language_id; U32 data_version;
U32 data_version;
U32 version;
COFF_ResourceMemoryFlags memory_flags; COFF_ResourceMemoryFlags memory_flags;
String8 data; U16 language_id;
U32 version;
U32 characteristics;
String8 data;
} COFF_Resource; } COFF_Resource;
typedef struct COFF_ResourceDataEntry typedef struct COFF_ResourceDataEntry
@@ -610,12 +597,12 @@ typedef struct COFF_ResourceDataEntry
typedef struct COFF_ResourceDirTable typedef struct COFF_ResourceDirTable
{ {
U32 characteristics; U32 characteristics;
COFF_TimeStamp time_stamp; COFF_TimeStamp time_stamp;
U16 major_version; U16 major_version;
U16 minor_version; U16 minor_version;
U16 name_entry_count; U16 name_entry_count;
U16 id_entry_count; U16 id_entry_count;
} COFF_ResourceDirTable; } COFF_ResourceDirTable;
#define COFF_RESOURCE_SUB_DIR_FLAG (1u << 31u) #define COFF_RESOURCE_SUB_DIR_FLAG (1u << 31u)
@@ -633,24 +620,19 @@ typedef struct COFF_ResourceDirEntry
//////////////////////////////// ////////////////////////////////
// !<arch>\n #define COFF_ARCHIVE_ALIGN 2
#define COFF_ARCHIVE_SIG 0x0A3E686372613C21ULL
// !<thin>\n
#define COFF_THIN_ARCHIVE_SIG 0xA3E6E6968743C21ULL
#define COFF_ARCHIVE_MAX_SHORT_NAME_SIZE 15 #define COFF_ARCHIVE_MAX_SHORT_NAME_SIZE 15
#define COFF_ARCHIVE_MEMBER_HEADER_SIZE 60
#define COFF_ARCHIVE_ALIGN 2
typedef struct COFF_ArchiveMemberHeader typedef struct COFF_ArchiveMemberHeader
{ {
String8 name; // padded to 16 bytes with spaces String8 name; // padded to 16 bytes with spaces
U32 date; // unix time U32 date; // unix time
U32 user_id; // unix artifact that does not have meaning on windows U32 user_id; // unix artifact that does not have meaning on windows
U32 group_id; // unix artifact that does not have meaning on windows U32 group_id; // unix artifact that does not have meaning on windows
String8 mode; // octal representation the members file mode String8 mode; // octal representation the members file mode
U32 size; // size of the member data, not including header U32 size; // size of the member data, not including header
B32 is_end_correct; // set to true if found correct signature after header B32 is_end_correct; // set to true if found correct signature after header
} COFF_ArchiveMemberHeader; } COFF_ArchiveMemberHeader;
//////////////////////////////// ////////////////////////////////
@@ -668,71 +650,61 @@ typedef U32 COFF_DataType;
typedef struct COFF_HeaderInfo typedef struct COFF_HeaderInfo
{ {
COFF_MachineType machine; COFF_MachineType machine;
U64 section_array_off; COFF_DataType type;
U64 section_count_no_null; U64 section_array_off;
U64 string_table_off; U64 section_count_no_null;
U64 symbol_size; U64 string_table_off;
U64 symbol_off; U64 symbol_size;
U64 symbol_count; U64 symbol_off;
U64 symbol_count;
} COFF_HeaderInfo; } COFF_HeaderInfo;
enum enum
{ {
// symbol has section and offset. COFF_SymbolValueInterp_REGULAR, // symbol has section and offset.
COFF_SymbolValueInterp_REGULAR, COFF_SymbolValueInterp_WEAK, // symbol is overridable
COFF_SymbolValueInterp_UNDEFINED, // symbol doesn't have a reference section.
// symbol is overridable COFF_SymbolValueInterp_COMMON, // symbol has no section but still has size.
COFF_SymbolValueInterp_WEAK, COFF_SymbolValueInterp_ABS, // symbol has an absolute (non-relocatable) value and is not an address.
COFF_SymbolValueInterp_DEBUG // symbol is used to provide general type of debugging information.
// symbol doesn't have a reference section.
COFF_SymbolValueInterp_UNDEFINED,
// symbol has no section but still has size.
COFF_SymbolValueInterp_COMMON,
// symbol has an absolute (non-relocatable) value and is not an address.
COFF_SymbolValueInterp_ABS,
// symbol is used to provide general type of debugging information.
COFF_SymbolValueInterp_DEBUG
}; };
typedef U32 COFF_SymbolValueInterpType; typedef U32 COFF_SymbolValueInterpType;
typedef struct COFF_Symbol16Node typedef struct COFF_Symbol16Node
{ {
struct COFF_Symbol16Node *next; struct COFF_Symbol16Node *next;
COFF_Symbol16 data; COFF_Symbol16 data;
} COFF_Symbol16Node; } COFF_Symbol16Node;
typedef struct COFF_Symbol16List typedef struct COFF_Symbol16List
{ {
U64 count; U64 count;
COFF_Symbol16Node *first; COFF_Symbol16Node *first;
COFF_Symbol16Node *last; COFF_Symbol16Node *last;
} COFF_Symbol16List; } COFF_Symbol16List;
typedef struct COFF_Symbol32Array typedef struct COFF_Symbol32Array
{ {
U64 count; U64 count;
COFF_Symbol32 *v; COFF_Symbol32 *v;
} COFF_Symbol32Array; } COFF_Symbol32Array;
typedef struct COFF_RelocNode typedef struct COFF_RelocNode
{ {
struct COFF_RelocNode *next; struct COFF_RelocNode *next;
COFF_Reloc data; COFF_Reloc data;
} COFF_RelocNode; } COFF_RelocNode;
typedef struct COFF_RelocList typedef struct COFF_RelocList
{ {
U64 count; U64 count;
COFF_RelocNode *first; COFF_RelocNode *first;
COFF_RelocNode *last; COFF_RelocNode *last;
} COFF_RelocList; } COFF_RelocList;
typedef struct COFF_RelocArray typedef struct COFF_RelocArray
{ {
U64 count; U64 count;
COFF_Reloc *v; COFF_Reloc *v;
} COFF_RelocArray; } COFF_RelocArray;
@@ -745,12 +717,12 @@ typedef struct COFF_RelocInfo
typedef struct COFF_ResourceNode typedef struct COFF_ResourceNode
{ {
struct COFF_ResourceNode *next; struct COFF_ResourceNode *next;
COFF_Resource data; COFF_Resource data;
} COFF_ResourceNode; } COFF_ResourceNode;
typedef struct COFF_ResourceList typedef struct COFF_ResourceList
{ {
U64 count; U64 count;
COFF_ResourceNode *first; COFF_ResourceNode *first;
COFF_ResourceNode *last; COFF_ResourceNode *last;
} COFF_ResourceList; } COFF_ResourceList;
@@ -760,21 +732,21 @@ typedef struct COFF_ResourceList
typedef struct COFF_ArchiveMember typedef struct COFF_ArchiveMember
{ {
COFF_ArchiveMemberHeader header; COFF_ArchiveMemberHeader header;
U64 offset; U64 offset;
String8 data; String8 data;
} COFF_ArchiveMember; } COFF_ArchiveMember;
typedef struct COFF_ArchiveFirstMember typedef struct COFF_ArchiveFirstMember
{ {
U32 symbol_count; U32 symbol_count;
String8 member_offsets; String8 member_offsets;
String8 string_table; String8 string_table;
} COFF_ArchiveFirstMember; } COFF_ArchiveFirstMember;
typedef struct COFF_ArchiveSecondMember typedef struct COFF_ArchiveSecondMember
{ {
U32 member_count; U32 member_count;
U32 symbol_count; U32 symbol_count;
String8 member_offsets; String8 member_offsets;
String8 symbol_indices; String8 symbol_indices;
String8 string_table; String8 string_table;
@@ -783,12 +755,12 @@ typedef struct COFF_ArchiveSecondMember
typedef struct COFF_ArchiveMemberNode typedef struct COFF_ArchiveMemberNode
{ {
struct COFF_ArchiveMemberNode *next; struct COFF_ArchiveMemberNode *next;
COFF_ArchiveMember data; COFF_ArchiveMember data;
} COFF_ArchiveMemberNode; } COFF_ArchiveMemberNode;
typedef struct COFF_ArchiveMemberList typedef struct COFF_ArchiveMemberList
{ {
U64 count; U64 count;
COFF_ArchiveMemberNode *first; COFF_ArchiveMemberNode *first;
COFF_ArchiveMemberNode *last; COFF_ArchiveMemberNode *last;
} COFF_ArchiveMemberList; } COFF_ArchiveMemberList;
@@ -802,14 +774,37 @@ typedef enum
typedef struct COFF_ArchiveParse typedef struct COFF_ArchiveParse
{ {
COFF_ArchiveFirstMember first_member; COFF_ArchiveFirstMember first_member;
COFF_ArchiveSecondMember second_member; COFF_ArchiveSecondMember second_member;
String8 long_names; String8 long_names;
} COFF_ArchiveParse; } COFF_ArchiveParse;
////////////////////////////////
typedef struct COFF_SectionHeaderArray
{
U64 count;
COFF_SectionHeader *v;
} COFF_SectionHeaderArray;
//////////////////////////////// ////////////////////////////////
//~ rjf: Globals //~ rjf: Globals
read_only global U8 coff_big_obj_magic[] =
{
0xC7,0xA1,0xBA,0xD1,0xEE,0xBA,0xA9,0x4B,
0xAF,0x20,0xFA,0xF6,0x6A,0xA4,0xDC,0xB8,
};
read_only global U8 g_coff_archive_sig[8] = "!<arch>\n";
read_only global U8 g_coff_thin_archive_sig[8] = "!<thin>\n";
read_only global U8 g_coff_res_magic[] =
{
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
read_only global COFF_SectionHeader coff_section_header_nil = {0}; read_only global COFF_SectionHeader coff_section_header_nil = {0};
//////////////////////////////// ////////////////////////////////
@@ -819,6 +814,7 @@ internal B32 coff_is_big_obj(String8 data);
internal B32 coff_is_obj(String8 data); internal B32 coff_is_obj(String8 data);
internal COFF_HeaderInfo coff_header_info_from_data(String8 data); internal COFF_HeaderInfo coff_header_info_from_data(String8 data);
internal U64 coff_align_size_from_section_flags(COFF_SectionFlags flags); internal U64 coff_align_size_from_section_flags(COFF_SectionFlags flags);
internal COFF_SectionFlags coff_section_flag_from_align_size(U64 align);
internal COFF_SymbolValueInterpType coff_interp_symbol(COFF_Symbol32 *symbol); internal COFF_SymbolValueInterpType coff_interp_symbol(COFF_Symbol32 *symbol);
internal U64 coff_foff_from_voff(COFF_SectionHeader *sections, U64 section_count, U64 voff); internal U64 coff_foff_from_voff(COFF_SectionHeader *sections, U64 section_count, U64 voff);
@@ -834,18 +830,47 @@ internal COFF_Symbol32Array coff_symbol_array_from_data(Arena *arena, String8 d
internal COFF_Symbol16Node * coff_symbol16_list_push(Arena *arena, COFF_Symbol16List *list, COFF_Symbol16 symbol); internal COFF_Symbol16Node * coff_symbol16_list_push(Arena *arena, COFF_Symbol16List *list, COFF_Symbol16 symbol);
internal COFF_RelocInfo coff_reloc_info_from_section_header(String8 data, COFF_SectionHeader *header); internal COFF_RelocInfo coff_reloc_info_from_section_header(String8 data, COFF_SectionHeader *header);
internal U64 coff_word_size_from_machine(COFF_MachineType machine); internal U64 coff_word_size_from_machine(COFF_MachineType machine);
internal U64 coff_default_exe_base_from_machine(COFF_MachineType machine);
internal U64 coff_default_dll_base_from_machine(COFF_MachineType machine);
internal String8 coff_make_import_lookup(Arena *arena, U16 hint, String8 name); internal String8 coff_make_import_lookup(Arena *arena, U16 hint, String8 name);
internal U32 coff_make_ordinal_32(U16 hint); internal U32 coff_make_ordinal_32(U16 hint);
internal U64 coff_make_ordinal_64(U16 hint); internal U64 coff_make_ordinal_64(U16 hint);
internal B32 coff_resource_id_is_equal(COFF_ResourceID a, COFF_ResourceID b); internal String8 coff_make_import_header_by_name(Arena *arena,
internal COFF_ResourceID coff_resource_id_copy(Arena *arena, COFF_ResourceID id); String8 dll_name,
internal COFF_ResourceID coff_convert_resource_id(Arena *arena, COFF_ResourceID_16 *id_16); COFF_MachineType machine,
internal U64 coff_read_resource_id(String8 res, U64 off, COFF_ResourceID_16 *id_out); COFF_TimeStamp time_stamp,
String8 name,
U16 hint,
COFF_ImportHeaderType type);
internal String8 coff_make_import_header_by_ordinal(Arena *arena,
String8 dll_name,
COFF_MachineType machine,
COFF_TimeStamp time_stamp,
U16 ordinal,
COFF_ImportHeaderType type);
////////////////////////////////
//~ Resources
internal String8 coff_resource_string_from_str16(Arena *arena, String16 string);
internal String8 coff_resource_string_from_str8(Arena *arena, String8 string);
internal String8 coff_resource_number_from_u16(Arena *arena, U16 number);
internal B32 coff_resource_id_is_equal(COFF_ResourceID a, COFF_ResourceID b);
internal COFF_ResourceID coff_utf8_resource_id_from_utf16(Arena *arena, COFF_ResourceID_16 *id_16);
internal U64 coff_read_resource_id_utf16(String8 res, U64 off, COFF_ResourceID_16 *id_out);
internal U64 coff_read_resource(String8 data, U64 off, Arena *arena, COFF_Resource *res_out); internal U64 coff_read_resource(String8 data, U64 off, Arena *arena, COFF_Resource *res_out);
internal COFF_ResourceList coff_resource_list_from_data(Arena *arena, String8 data); internal COFF_ResourceList coff_resource_list_from_data(Arena *arena, String8 data);
internal String8 coff_write_resource_id(Arena *arena, COFF_ResourceID id);
internal String8 coff_write_resource(Arena *arena, COFF_ResourceID type, COFF_ResourceID name, U32 data_version, COFF_ResourceMemoryFlags memory_flags, U16 language_id, U32 version, U32 characteristics, String8 data);
////////////////////////////////
internal COFF_DataType coff_data_type_from_data(String8 data); internal COFF_DataType coff_data_type_from_data(String8 data);
internal B32 coff_is_import(String8 data); internal B32 coff_is_import(String8 data);
internal B32 coff_is_archive(String8 data); internal B32 coff_is_archive(String8 data);
@@ -865,8 +890,15 @@ internal COFF_ArchiveParse coff_thin_archive_from_data(Arena *arena, String8 da
internal COFF_ArchiveType coff_archive_type_from_data(String8 data); internal COFF_ArchiveType coff_archive_type_from_data(String8 data);
internal COFF_ArchiveParse coff_archive_parse_from_data(Arena *arena, String8 data); internal COFF_ArchiveParse coff_archive_parse_from_data(Arena *arena, String8 data);
////////////////////////////////
// String <-> Enum
internal String8 coff_string_from_comdat_select_type(COFF_ComdatSelectType select); internal String8 coff_string_from_comdat_select_type(COFF_ComdatSelectType select);
internal String8 coff_string_from_machine_type(COFF_MachineType machine); internal String8 coff_string_from_machine_type(COFF_MachineType machine);
internal String8 coff_string_from_section_flags(Arena *arena, COFF_SectionFlags flags); internal String8 coff_string_from_section_flags(Arena *arena, COFF_SectionFlags flags);
internal String8 coff_string_from_import_header_type(COFF_ImportHeaderType type);
internal COFF_MachineType coff_machine_from_string(String8 string);
internal COFF_ImportHeaderType coff_import_header_type_from_string(String8 name);
#endif //COFF_H #endif //COFF_H
+106 -84
View File
@@ -1,84 +1,106 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
//~ rjf: Tables //~ rjf: Entity Kinds
@table(name lower_name code default display_string) @table(name display_string)
CTRL_ExceptionCodeKindTable: CTRL_EntityKindTable:
{ {
{Win32CtrlC win32_ctrl_c 0x40010005 1 "(Win32) Control-C" } {Root "Root" }
{Win32CtrlBreak win32_ctrl_break 0x40010008 1 "(Win32) Control-Break" } {Machine "Machine" }
{Win32WinRTOriginateError win32_win_rt_originate_error 0x40080201 0 "(Win32) WinRT Originate Error" } {Process "Process" }
{Win32WinRTTransformError win32_win_rt_transform_error 0x40080202 0 "(Win32) WinRT Transform Error" } {Thread "Thread" }
{Win32RPCCallCancelled win32_rpc_call_cancelled 0x0000071a 0 "(Win32) RPC Call Cancelled" } {Module "Module" }
{Win32DatatypeMisalignment win32_datatype_misalignment 0x80000002 0 "(Win32) Data Type Misalignment" } {EntryPoint "Entry Point" }
{Win32AccessViolation win32_access_violation 0xc0000005 1 "(Win32) Access Violation" } {DebugInfoPath "Debug Info Path" }
{Win32InPageError win32_in_page_error 0xc0000006 0 "(Win32) In Page Error" } }
{Win32InvalidHandle win32_invalid_handle 0xc0000008 1 "(Win32) Invalid Handle Specified" }
{Win32NotEnoughQuota win32_not_enough_quota 0xc0000017 0 "(Win32) Not Enough Quota" } @enum CTRL_EntityKind:
{Win32IllegalInstruction win32_illegal_instruction 0xc000001d 0 "(Win32) Illegal Instruction" } {
{Win32CannotContinueException win32_cannot_continue_exception 0xc0000025 0 "(Win32) Cannot Continue From Exception" } Null,
{Win32InvalidExceptionDisposition win32_invalid_exception_disposition 0xc0000026 0 "(Win32) Invalid Exception Disposition Returned By Handler" } @expand(CTRL_EntityKindTable a) `$(a.name)`,
{Win32ArrayBoundsExceeded win32_array_bounds_exceeded 0xc000008c 0 "(Win32) Array Bounds Exceeded" } COUNT,
{Win32FloatingPointDenormalOperand win32_floating_point_denormal_operand 0xc000008d 0 "(Win32) Floating-Point Denormal Operand" } }
{Win32FloatingPointDivisionByZero win32_floating_point_division_by_zero 0xc000008e 0 "(Win32) Floating-Point Division By Zero" }
{Win32FloatingPointInexactResult win32_floating_point_inexact_result 0xc000008f 0 "(Win32) Floating-Point Inexact Result" } @data(String8) ctrl_entity_kind_display_string_table:
{Win32FloatingPointInvalidOperation win32_floating_point_invalid_operation 0xc0000090 0 "(Win32) Floating-Point Invalid Operation" } {
{Win32FloatingPointOverflow win32_floating_point_overflow 0xc0000091 0 "(Win32) Floating-Point Overflow" } `{0}`,
{Win32FloatingPointStackCheck win32_floating_point_stack_check 0xc0000092 0 "(Win32) Floating-Point Stack Check" } @expand(CTRL_EntityKindTable a) `str8_lit_comp("$(a.display_name)")`
{Win32FloatingPointUnderflow win32_floating_point_underflow 0xc0000093 0 "(Win32) Floating-Point Underflow" } }
{Win32IntegerDivisionByZero win32_integer_division_by_zero 0xc0000094 0 "(Win32) Integer Division By Zero" }
{Win32IntegerOverflow win32_integer_overflow 0xc0000095 0 "(Win32) Integer Overflow" } ////////////////////////////////
{Win32PrivilegedInstruction win32_privileged_instruction 0xc0000096 0 "(Win32) Privileged Instruction" } //~ rjf: Exception Codes
{Win32StackOverflow win32_stack_overflow 0xc00000fd 0 "(Win32) Stack Overflow" }
{Win32UnableToLocateDLL win32_unable_to_locate_dll 0xc0000135 0 "(Win32) Unable To Locate DLL" } @table(name lower_name code default display_string)
{Win32OrdinalNotFound win32_ordinal_not_found 0xc0000138 0 "(Win32) Ordinal Not Found" } CTRL_ExceptionCodeKindTable:
{Win32EntryPointNotFound win32_entry_point_not_found 0xc0000139 0 "(Win32) Entry Point Not Found" } {
{Win32DLLInitializationFailed win32_dll_initialization_failed 0xc0000142 0 "(Win32) DLL Initialization Failed" } {Win32CtrlC win32_ctrl_c 0x40010005 1 "(Win32) Control-C" }
{Win32FloatingPointSSEMultipleFaults win32_floating_point_sse_multiple_faults 0xc00002b4 0 "(Win32) Floating Point SSE Multiple Faults" } {Win32CtrlBreak win32_ctrl_break 0x40010008 1 "(Win32) Control-Break" }
{Win32FloatingPointSSEMultipleTraps win32_floating_point_sse_multiple_traps 0xc00002b5 0 "(Win32) Floating Point SSE Multiple Traps" } {Win32WinRTOriginateError win32_win_rt_originate_error 0x40080201 0 "(Win32) WinRT Originate Error" }
{Win32AssertionFailed win32_assertion_failed 0xc0000420 1 "(Win32) Assertion Failed" } {Win32WinRTTransformError win32_win_rt_transform_error 0x40080202 0 "(Win32) WinRT Transform Error" }
{Win32ModuleNotFound win32_module_not_found 0xc06d007e 0 "(Win32) Module Not Found" } {Win32RPCCallCancelled win32_rpc_call_cancelled 0x0000071a 0 "(Win32) RPC Call Cancelled" }
{Win32ProcedureNotFound win32_procedure_not_found 0xc06d007f 0 "(Win32) Procedure Not Found" } {Win32DatatypeMisalignment win32_datatype_misalignment 0x80000002 0 "(Win32) Data Type Misalignment" }
{Win32SanitizerErrorDetected win32_sanitizer_error_detected 0xe073616e 1 "(Win32) Sanitizer Error Detected" } {Win32AccessViolation win32_access_violation 0xc0000005 1 "(Win32) Access Violation" }
{Win32SanitizerRawAccessViolation win32_sanitizer_raw_access_violation 0xe0736171 0 "(Win32) Sanitizer Raw Access Violation" } {Win32InPageError win32_in_page_error 0xc0000006 0 "(Win32) In Page Error" }
} {Win32InvalidHandle win32_invalid_handle 0xc0000008 1 "(Win32) Invalid Handle Specified" }
{Win32NotEnoughQuota win32_not_enough_quota 0xc0000017 0 "(Win32) Not Enough Quota" }
//////////////////////////////// {Win32IllegalInstruction win32_illegal_instruction 0xc000001d 0 "(Win32) Illegal Instruction" }
//~ rjf: Generators {Win32CannotContinueException win32_cannot_continue_exception 0xc0000025 0 "(Win32) Cannot Continue From Exception" }
{Win32InvalidExceptionDisposition win32_invalid_exception_disposition 0xc0000026 0 "(Win32) Invalid Exception Disposition Returned By Handler" }
@table_gen_enum CTRL_ExceptionCodeKind: {Win32ArrayBoundsExceeded win32_array_bounds_exceeded 0xc000008c 0 "(Win32) Array Bounds Exceeded" }
{ {Win32FloatingPointDenormalOperand win32_floating_point_denormal_operand 0xc000008d 0 "(Win32) Floating-Point Denormal Operand" }
`CTRL_ExceptionCodeKind_Null,`; {Win32FloatingPointDivisionByZero win32_floating_point_division_by_zero 0xc000008e 0 "(Win32) Floating-Point Division By Zero" }
@expand(CTRL_ExceptionCodeKindTable a) `CTRL_ExceptionCodeKind_$(a.name),`; {Win32FloatingPointInexactResult win32_floating_point_inexact_result 0xc000008f 0 "(Win32) Floating-Point Inexact Result" }
`CTRL_ExceptionCodeKind_COUNT`; {Win32FloatingPointInvalidOperation win32_floating_point_invalid_operation 0xc0000090 0 "(Win32) Floating-Point Invalid Operation" }
} {Win32FloatingPointOverflow win32_floating_point_overflow 0xc0000091 0 "(Win32) Floating-Point Overflow" }
{Win32FloatingPointStackCheck win32_floating_point_stack_check 0xc0000092 0 "(Win32) Floating-Point Stack Check" }
@table_gen_data(type:U32, fallback:0) {Win32FloatingPointUnderflow win32_floating_point_underflow 0xc0000093 0 "(Win32) Floating-Point Underflow" }
ctrl_exception_code_kind_code_table: {Win32IntegerDivisionByZero win32_integer_division_by_zero 0xc0000094 0 "(Win32) Integer Division By Zero" }
{ {Win32IntegerOverflow win32_integer_overflow 0xc0000095 0 "(Win32) Integer Overflow" }
`0,`; {Win32PrivilegedInstruction win32_privileged_instruction 0xc0000096 0 "(Win32) Privileged Instruction" }
@expand(CTRL_ExceptionCodeKindTable a) `$(a.code),`; {Win32StackOverflow win32_stack_overflow 0xc00000fd 0 "(Win32) Stack Overflow" }
} {Win32UnableToLocateDLL win32_unable_to_locate_dll 0xc0000135 0 "(Win32) Unable To Locate DLL" }
{Win32OrdinalNotFound win32_ordinal_not_found 0xc0000138 0 "(Win32) Ordinal Not Found" }
@table_gen_data(type:String8, fallback:`{0}`) {Win32EntryPointNotFound win32_entry_point_not_found 0xc0000139 0 "(Win32) Entry Point Not Found" }
ctrl_exception_code_kind_display_string_table: {Win32DLLInitializationFailed win32_dll_initialization_failed 0xc0000142 0 "(Win32) DLL Initialization Failed" }
{ {Win32FloatingPointSSEMultipleFaults win32_floating_point_sse_multiple_faults 0xc00002b4 0 "(Win32) Floating Point SSE Multiple Faults" }
`{0},`; {Win32FloatingPointSSEMultipleTraps win32_floating_point_sse_multiple_traps 0xc00002b5 0 "(Win32) Floating Point SSE Multiple Traps" }
@expand(CTRL_ExceptionCodeKindTable a) `str8_lit_comp("$(a.display_string)"),`; {Win32AssertionFailed win32_assertion_failed 0xc0000420 1 "(Win32) Assertion Failed" }
} {Win32ModuleNotFound win32_module_not_found 0xc06d007e 0 "(Win32) Module Not Found" }
{Win32ProcedureNotFound win32_procedure_not_found 0xc06d007f 0 "(Win32) Procedure Not Found" }
@table_gen_data(type:String8, fallback:`{0}`) {Win32SanitizerErrorDetected win32_sanitizer_error_detected 0xe073616e 1 "(Win32) Sanitizer Error Detected" }
ctrl_exception_code_kind_lowercase_code_string_table: {Win32SanitizerRawAccessViolation win32_sanitizer_raw_access_violation 0xe0736171 0 "(Win32) Sanitizer Raw Access Violation" }
{ {Win32DirectXDebugLayer win32_directx_debug_layer 0x0000087a 1 "(Win32) DirectX Debug Layer" }
`{0},`; }
@expand(CTRL_ExceptionCodeKindTable a) `str8_lit_comp("$(a.lower_name)"),`;
} @enum CTRL_ExceptionCodeKind:
{
@table_gen_data(type:B8, fallback:0) Null,
ctrl_exception_code_kind_default_enable_table: @expand(CTRL_ExceptionCodeKindTable a) `$(a.name)`,
{ COUNT,
`0,`; }
@expand(CTRL_ExceptionCodeKindTable a) `$(a.default),`;
} @data(U32) ctrl_exception_code_kind_code_table:
{
`0`;
@expand(CTRL_ExceptionCodeKindTable a) `$(a.code)`;
}
@data(String8) ctrl_exception_code_kind_display_string_table:
{
`{0}`;
@expand(CTRL_ExceptionCodeKindTable a) `str8_lit_comp("$(a.display_string)")`;
}
@data(String8) ctrl_exception_code_kind_lowercase_code_string_table:
{
`{0}`;
@expand(CTRL_ExceptionCodeKindTable a) `str8_lit_comp("$(a.lower_name)")`;
}
@data(B8) ctrl_exception_code_kind_default_enable_table:
{
`0`;
@expand(CTRL_ExceptionCodeKindTable a) `$(a.default)`;
}
+6114 -3021
View File
File diff suppressed because it is too large. Load diff
+1193 -601
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "ctrl_core.c" #include "ctrl_core.c"
+77 -77
View File
@@ -1,77 +1,77 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CTRL_INC_H #ifndef CTRL_INC_H
#define CTRL_INC_H #define CTRL_INC_H
//////////////////////////////// ////////////////////////////////
//~ NOTE(rjf): Control Layer Overview (2023/8/29) //~ NOTE(rjf): Control Layer Overview (2023/8/29)
// //
// This layer's purpose is to provide access to the asynchronously-running, low // This layer's purpose is to provide access to the asynchronously-running, low
// level parts of a debugger, running on the debugger client. This primarily // level parts of a debugger, running on the debugger client. This primarily
// consists of process control, using the Demon layer (the lower level // consists of process control, using the Demon layer (the lower level
// abstraction layer for process control, across multiple OSes), but including // abstraction layer for process control, across multiple OSes), but including
// higher-level concepts, like stepping, breakpoint resolution, conditional // higher-level concepts, like stepping, breakpoint resolution, conditional
// breakpoint evaluation, and so on. Right now, this just includes process // breakpoint evaluation, and so on. Right now, this just includes process
// control *local to the debugger client machine*. But in the future, this can // control *local to the debugger client machine*. But in the future, this can
// also include communication to multiple target machines, all running their // also include communication to multiple target machines, all running their
// own process controller, using the Demon layer. // own process controller, using the Demon layer.
// //
// This part of a debugger must run asynchronously to prevent blocking the UI - // This part of a debugger must run asynchronously to prevent blocking the UI -
// ideally our debugger is designed such that, if targets are running, the // ideally our debugger is designed such that, if targets are running, the
// debugger frontend is still usable for a variety of purposes. So, in short, // debugger frontend is still usable for a variety of purposes. So, in short,
// the asynchronously-running "control thread", implemented by this layer, is // the asynchronously-running "control thread", implemented by this layer, is
// tasked with communicating with a separately executing "user thread". This // tasked with communicating with a separately executing "user thread". This
// communication happens in two directions - `user -> ctrl`, and the reverse, // communication happens in two directions - `user -> ctrl`, and the reverse,
// `ctrl -> user`. // `ctrl -> user`.
// //
// In the case of `user -> ctrl` communication, this is done with a ring buffer // In the case of `user -> ctrl` communication, this is done with a ring buffer
// of "messages" (`CTRL_Msg`), pushed via `ctrl_u2c_push_msgs`. These messages // of "messages" (`CTRL_Msg`), pushed via `ctrl_u2c_push_msgs`. These messages
// include commands like: launching targets, attaching to targets, killing // include commands like: launching targets, attaching to targets, killing
// targets, detaching from targets, stepping/running, or single stepping. // targets, detaching from targets, stepping/running, or single stepping.
// //
// In the case of `ctrl -> user` communication, this is done with a ring buffer // In the case of `ctrl -> user` communication, this is done with a ring buffer
// of "events" (`CTRL_Event`), popped via `ctrl_c2u_pop_events`. These events // of "events" (`CTRL_Event`), popped via `ctrl_c2u_pop_events`. These events
// include information about what happened during the execution of targets - // include information about what happened during the execution of targets -
// including: process/module/thread creation, process/module/thread deletion, // including: process/module/thread creation, process/module/thread deletion,
// debug strings, thread name events, memory allocation events, and stop events // debug strings, thread name events, memory allocation events, and stop events
// (where stops can be caused by: user breakpoints, traps set for stepping, // (where stops can be caused by: user breakpoints, traps set for stepping,
// exceptions, halts, or errors). // exceptions, halts, or errors).
// //
// The various stepping algorithms are implemented with two concepts: (a) the // The various stepping algorithms are implemented with two concepts: (a) the
// "trap net", and (b) "spoofs". // "trap net", and (b) "spoofs".
// //
// A "trap net" is a term which refers to a set of addresses paired with a set // A "trap net" is a term which refers to a set of addresses paired with a set
// of behavioral flags. Before targets run, trap instructions are written to // of behavioral flags. Before targets run, trap instructions are written to
// these addresses. After targets stop, these addresses are reset to their // these addresses. After targets stop, these addresses are reset to their
// original bytes. These trap instructions cause the debugger's targets to // original bytes. These trap instructions cause the debugger's targets to
// stop executing, and based on which behavioral flags are associated with // stop executing, and based on which behavioral flags are associated with
// the instruction causing the stop, the control thread may adjust parameters // the instruction causing the stop, the control thread may adjust parameters
// used for running, then continue execution, or it will not resume target // used for running, then continue execution, or it will not resume target
// execution, and will report stopped events. These behavioral flags can // execution, and will report stopped events. These behavioral flags can
// include: single-stepping the stopped thread to execute the instruction at // include: single-stepping the stopped thread to execute the instruction at
// the trap location, saving a stack pointer "check value" (where this check // the trap location, saving a stack pointer "check value" (where this check
// value is compared against when making decisions about whether to continue // value is compared against when making decisions about whether to continue
// running or not), and so on. It's complicated to unpack why exactly these // running or not), and so on. It's complicated to unpack why exactly these
// behaviors are useful, but the TL;DR of it is that they are used for a // behaviors are useful, but the TL;DR of it is that they are used for a
// variety of stepping behaviors. For example, when doing a "step into" step, // variety of stepping behaviors. For example, when doing a "step into" step,
// a `call` instruction can have a trap set at it, and will be marked with // a `call` instruction can have a trap set at it, and will be marked with
// a "single-step-after" trap flag, as well as the "end stepping" trap flag, // a "single-step-after" trap flag, as well as the "end stepping" trap flag,
// such that the step operation will complete after the `call` has executed. // such that the step operation will complete after the `call` has executed.
// //
// A "spoof" is a feature the control layer uses to detect when some thread // A "spoof" is a feature the control layer uses to detect when some thread
// returns from a particular sub-callstack. This is useful when implementing // returns from a particular sub-callstack. This is useful when implementing
// "step over" in functions that may be recursive. In short, unlike a trap, // "step over" in functions that may be recursive. In short, unlike a trap,
// which writes a trap instruction (like `int3`) into an instruction stream, // which writes a trap instruction (like `int3`) into an instruction stream,
// a spoof overwrites a *return address* on some thread's *stack*. This return // a spoof overwrites a *return address* on some thread's *stack*. This return
// address is not a valid address for executing code -- it is simply a value // address is not a valid address for executing code -- it is simply a value
// that the debugger can recognize, such that it is notified when the thread // that the debugger can recognize, such that it is notified when the thread
// returns from some level in a callstack. When the thread exits some function, // returns from some level in a callstack. When the thread exits some function,
// it will return to the "spoofed" address, and it will immediately hit an // it will return to the "spoofed" address, and it will immediately hit an
// exception, because the spoofed address will not be a valid address for // exception, because the spoofed address will not be a valid address for
// code execution. At that point, the debugger can move the thread back to // code execution. At that point, the debugger can move the thread back to
// the pre-spoof return address, and resume execution. // the pre-spoof return address, and resume execution.
#include "ctrl_core.h" #include "ctrl_core.h"
#endif //CTRL_INC_H #endif // CTRL_INC_H
+188 -5
View File
@@ -1,5 +1,188 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
C_LINKAGE_BEGIN
String8 ctrl_entity_kind_display_string_table[8] =
{
{0},
str8_lit_comp("Root"),
str8_lit_comp("Machine"),
str8_lit_comp("Process"),
str8_lit_comp("Thread"),
str8_lit_comp("Module"),
str8_lit_comp("EntryPoint"),
str8_lit_comp("DebugInfoPath"),
};
U32 ctrl_exception_code_kind_code_table[38] =
{
0,
0x40010005,
0x40010008,
0x40080201,
0x40080202,
0x0000071a,
0x80000002,
0xc0000005,
0xc0000006,
0xc0000008,
0xc0000017,
0xc000001d,
0xc0000025,
0xc0000026,
0xc000008c,
0xc000008d,
0xc000008e,
0xc000008f,
0xc0000090,
0xc0000091,
0xc0000092,
0xc0000093,
0xc0000094,
0xc0000095,
0xc0000096,
0xc00000fd,
0xc0000135,
0xc0000138,
0xc0000139,
0xc0000142,
0xc00002b4,
0xc00002b5,
0xc0000420,
0xc06d007e,
0xc06d007f,
0xe073616e,
0xe0736171,
0x0000087a,
};
String8 ctrl_exception_code_kind_display_string_table[38] =
{
{0},
str8_lit_comp("(Win32) Control-C"),
str8_lit_comp("(Win32) Control-Break"),
str8_lit_comp("(Win32) WinRT Originate Error"),
str8_lit_comp("(Win32) WinRT Transform Error"),
str8_lit_comp("(Win32) RPC Call Cancelled"),
str8_lit_comp("(Win32) Data Type Misalignment"),
str8_lit_comp("(Win32) Access Violation"),
str8_lit_comp("(Win32) In Page Error"),
str8_lit_comp("(Win32) Invalid Handle Specified"),
str8_lit_comp("(Win32) Not Enough Quota"),
str8_lit_comp("(Win32) Illegal Instruction"),
str8_lit_comp("(Win32) Cannot Continue From Exception"),
str8_lit_comp("(Win32) Invalid Exception Disposition Returned By Handler"),
str8_lit_comp("(Win32) Array Bounds Exceeded"),
str8_lit_comp("(Win32) Floating-Point Denormal Operand"),
str8_lit_comp("(Win32) Floating-Point Division By Zero"),
str8_lit_comp("(Win32) Floating-Point Inexact Result"),
str8_lit_comp("(Win32) Floating-Point Invalid Operation"),
str8_lit_comp("(Win32) Floating-Point Overflow"),
str8_lit_comp("(Win32) Floating-Point Stack Check"),
str8_lit_comp("(Win32) Floating-Point Underflow"),
str8_lit_comp("(Win32) Integer Division By Zero"),
str8_lit_comp("(Win32) Integer Overflow"),
str8_lit_comp("(Win32) Privileged Instruction"),
str8_lit_comp("(Win32) Stack Overflow"),
str8_lit_comp("(Win32) Unable To Locate DLL"),
str8_lit_comp("(Win32) Ordinal Not Found"),
str8_lit_comp("(Win32) Entry Point Not Found"),
str8_lit_comp("(Win32) DLL Initialization Failed"),
str8_lit_comp("(Win32) Floating Point SSE Multiple Faults"),
str8_lit_comp("(Win32) Floating Point SSE Multiple Traps"),
str8_lit_comp("(Win32) Assertion Failed"),
str8_lit_comp("(Win32) Module Not Found"),
str8_lit_comp("(Win32) Procedure Not Found"),
str8_lit_comp("(Win32) Sanitizer Error Detected"),
str8_lit_comp("(Win32) Sanitizer Raw Access Violation"),
str8_lit_comp("(Win32) DirectX Debug Layer"),
};
String8 ctrl_exception_code_kind_lowercase_code_string_table[38] =
{
{0},
str8_lit_comp("win32_ctrl_c"),
str8_lit_comp("win32_ctrl_break"),
str8_lit_comp("win32_win_rt_originate_error"),
str8_lit_comp("win32_win_rt_transform_error"),
str8_lit_comp("win32_rpc_call_cancelled"),
str8_lit_comp("win32_datatype_misalignment"),
str8_lit_comp("win32_access_violation"),
str8_lit_comp("win32_in_page_error"),
str8_lit_comp("win32_invalid_handle"),
str8_lit_comp("win32_not_enough_quota"),
str8_lit_comp("win32_illegal_instruction"),
str8_lit_comp("win32_cannot_continue_exception"),
str8_lit_comp("win32_invalid_exception_disposition"),
str8_lit_comp("win32_array_bounds_exceeded"),
str8_lit_comp("win32_floating_point_denormal_operand"),
str8_lit_comp("win32_floating_point_division_by_zero"),
str8_lit_comp("win32_floating_point_inexact_result"),
str8_lit_comp("win32_floating_point_invalid_operation"),
str8_lit_comp("win32_floating_point_overflow"),
str8_lit_comp("win32_floating_point_stack_check"),
str8_lit_comp("win32_floating_point_underflow"),
str8_lit_comp("win32_integer_division_by_zero"),
str8_lit_comp("win32_integer_overflow"),
str8_lit_comp("win32_privileged_instruction"),
str8_lit_comp("win32_stack_overflow"),
str8_lit_comp("win32_unable_to_locate_dll"),
str8_lit_comp("win32_ordinal_not_found"),
str8_lit_comp("win32_entry_point_not_found"),
str8_lit_comp("win32_dll_initialization_failed"),
str8_lit_comp("win32_floating_point_sse_multiple_faults"),
str8_lit_comp("win32_floating_point_sse_multiple_traps"),
str8_lit_comp("win32_assertion_failed"),
str8_lit_comp("win32_module_not_found"),
str8_lit_comp("win32_procedure_not_found"),
str8_lit_comp("win32_sanitizer_error_detected"),
str8_lit_comp("win32_sanitizer_raw_access_violation"),
str8_lit_comp("win32_directx_debug_layer"),
};
B8 ctrl_exception_code_kind_default_enable_table[38] =
{
0,
1,
1,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1,
};
C_LINKAGE_END
+74 -216
View File
@@ -1,216 +1,74 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
#ifndef CTRL_META_H #ifndef CTRL_META_H
#define CTRL_META_H #define CTRL_META_H
typedef enum CTRL_ExceptionCodeKind typedef enum CTRL_EntityKind
{ {
CTRL_ExceptionCodeKind_Null, CTRL_EntityKind_Null,
CTRL_ExceptionCodeKind_Win32CtrlC, CTRL_EntityKind_Root,
CTRL_ExceptionCodeKind_Win32CtrlBreak, CTRL_EntityKind_Machine,
CTRL_ExceptionCodeKind_Win32WinRTOriginateError, CTRL_EntityKind_Process,
CTRL_ExceptionCodeKind_Win32WinRTTransformError, CTRL_EntityKind_Thread,
CTRL_ExceptionCodeKind_Win32RPCCallCancelled, CTRL_EntityKind_Module,
CTRL_ExceptionCodeKind_Win32DatatypeMisalignment, CTRL_EntityKind_EntryPoint,
CTRL_ExceptionCodeKind_Win32AccessViolation, CTRL_EntityKind_DebugInfoPath,
CTRL_ExceptionCodeKind_Win32InPageError, CTRL_EntityKind_COUNT,
CTRL_ExceptionCodeKind_Win32InvalidHandle, } CTRL_EntityKind;
CTRL_ExceptionCodeKind_Win32NotEnoughQuota,
CTRL_ExceptionCodeKind_Win32IllegalInstruction, typedef enum CTRL_ExceptionCodeKind
CTRL_ExceptionCodeKind_Win32CannotContinueException, {
CTRL_ExceptionCodeKind_Win32InvalidExceptionDisposition, CTRL_ExceptionCodeKind_Null,
CTRL_ExceptionCodeKind_Win32ArrayBoundsExceeded, CTRL_ExceptionCodeKind_Win32CtrlC,
CTRL_ExceptionCodeKind_Win32FloatingPointDenormalOperand, CTRL_ExceptionCodeKind_Win32CtrlBreak,
CTRL_ExceptionCodeKind_Win32FloatingPointDivisionByZero, CTRL_ExceptionCodeKind_Win32WinRTOriginateError,
CTRL_ExceptionCodeKind_Win32FloatingPointInexactResult, CTRL_ExceptionCodeKind_Win32WinRTTransformError,
CTRL_ExceptionCodeKind_Win32FloatingPointInvalidOperation, CTRL_ExceptionCodeKind_Win32RPCCallCancelled,
CTRL_ExceptionCodeKind_Win32FloatingPointOverflow, CTRL_ExceptionCodeKind_Win32DatatypeMisalignment,
CTRL_ExceptionCodeKind_Win32FloatingPointStackCheck, CTRL_ExceptionCodeKind_Win32AccessViolation,
CTRL_ExceptionCodeKind_Win32FloatingPointUnderflow, CTRL_ExceptionCodeKind_Win32InPageError,
CTRL_ExceptionCodeKind_Win32IntegerDivisionByZero, CTRL_ExceptionCodeKind_Win32InvalidHandle,
CTRL_ExceptionCodeKind_Win32IntegerOverflow, CTRL_ExceptionCodeKind_Win32NotEnoughQuota,
CTRL_ExceptionCodeKind_Win32PrivilegedInstruction, CTRL_ExceptionCodeKind_Win32IllegalInstruction,
CTRL_ExceptionCodeKind_Win32StackOverflow, CTRL_ExceptionCodeKind_Win32CannotContinueException,
CTRL_ExceptionCodeKind_Win32UnableToLocateDLL, CTRL_ExceptionCodeKind_Win32InvalidExceptionDisposition,
CTRL_ExceptionCodeKind_Win32OrdinalNotFound, CTRL_ExceptionCodeKind_Win32ArrayBoundsExceeded,
CTRL_ExceptionCodeKind_Win32EntryPointNotFound, CTRL_ExceptionCodeKind_Win32FloatingPointDenormalOperand,
CTRL_ExceptionCodeKind_Win32DLLInitializationFailed, CTRL_ExceptionCodeKind_Win32FloatingPointDivisionByZero,
CTRL_ExceptionCodeKind_Win32FloatingPointSSEMultipleFaults, CTRL_ExceptionCodeKind_Win32FloatingPointInexactResult,
CTRL_ExceptionCodeKind_Win32FloatingPointSSEMultipleTraps, CTRL_ExceptionCodeKind_Win32FloatingPointInvalidOperation,
CTRL_ExceptionCodeKind_Win32AssertionFailed, CTRL_ExceptionCodeKind_Win32FloatingPointOverflow,
CTRL_ExceptionCodeKind_Win32ModuleNotFound, CTRL_ExceptionCodeKind_Win32FloatingPointStackCheck,
CTRL_ExceptionCodeKind_Win32ProcedureNotFound, CTRL_ExceptionCodeKind_Win32FloatingPointUnderflow,
CTRL_ExceptionCodeKind_Win32SanitizerErrorDetected, CTRL_ExceptionCodeKind_Win32IntegerDivisionByZero,
CTRL_ExceptionCodeKind_Win32SanitizerRawAccessViolation, CTRL_ExceptionCodeKind_Win32IntegerOverflow,
CTRL_ExceptionCodeKind_COUNT CTRL_ExceptionCodeKind_Win32PrivilegedInstruction,
} CTRL_ExceptionCodeKind; CTRL_ExceptionCodeKind_Win32StackOverflow,
CTRL_ExceptionCodeKind_Win32UnableToLocateDLL,
U32 ctrl_exception_code_kind_code_table[] = CTRL_ExceptionCodeKind_Win32OrdinalNotFound,
{ CTRL_ExceptionCodeKind_Win32EntryPointNotFound,
0, CTRL_ExceptionCodeKind_Win32DLLInitializationFailed,
0x40010005, CTRL_ExceptionCodeKind_Win32FloatingPointSSEMultipleFaults,
0x40010008, CTRL_ExceptionCodeKind_Win32FloatingPointSSEMultipleTraps,
0x40080201, CTRL_ExceptionCodeKind_Win32AssertionFailed,
0x40080202, CTRL_ExceptionCodeKind_Win32ModuleNotFound,
0x0000071a, CTRL_ExceptionCodeKind_Win32ProcedureNotFound,
0x80000002, CTRL_ExceptionCodeKind_Win32SanitizerErrorDetected,
0xc0000005, CTRL_ExceptionCodeKind_Win32SanitizerRawAccessViolation,
0xc0000006, CTRL_ExceptionCodeKind_Win32DirectXDebugLayer,
0xc0000008, CTRL_ExceptionCodeKind_COUNT,
0xc0000017, } CTRL_ExceptionCodeKind;
0xc000001d,
0xc0000025, C_LINKAGE_BEGIN
0xc0000026, extern String8 ctrl_entity_kind_display_string_table[8];
0xc000008c, extern U32 ctrl_exception_code_kind_code_table[38];
0xc000008d, extern String8 ctrl_exception_code_kind_display_string_table[38];
0xc000008e, extern String8 ctrl_exception_code_kind_lowercase_code_string_table[38];
0xc000008f, extern B8 ctrl_exception_code_kind_default_enable_table[38];
0xc0000090,
0xc0000091, C_LINKAGE_END
0xc0000092,
0xc0000093, #endif // CTRL_META_H
0xc0000094,
0xc0000095,
0xc0000096,
0xc00000fd,
0xc0000135,
0xc0000138,
0xc0000139,
0xc0000142,
0xc00002b4,
0xc00002b5,
0xc0000420,
0xc06d007e,
0xc06d007f,
0xe073616e,
0xe0736171,
};
String8 ctrl_exception_code_kind_display_string_table[] =
{
{0},
str8_lit_comp("(Win32) Control-C"),
str8_lit_comp("(Win32) Control-Break"),
str8_lit_comp("(Win32) WinRT Originate Error"),
str8_lit_comp("(Win32) WinRT Transform Error"),
str8_lit_comp("(Win32) RPC Call Cancelled"),
str8_lit_comp("(Win32) Data Type Misalignment"),
str8_lit_comp("(Win32) Access Violation"),
str8_lit_comp("(Win32) In Page Error"),
str8_lit_comp("(Win32) Invalid Handle Specified"),
str8_lit_comp("(Win32) Not Enough Quota"),
str8_lit_comp("(Win32) Illegal Instruction"),
str8_lit_comp("(Win32) Cannot Continue From Exception"),
str8_lit_comp("(Win32) Invalid Exception Disposition Returned By Handler"),
str8_lit_comp("(Win32) Array Bounds Exceeded"),
str8_lit_comp("(Win32) Floating-Point Denormal Operand"),
str8_lit_comp("(Win32) Floating-Point Division By Zero"),
str8_lit_comp("(Win32) Floating-Point Inexact Result"),
str8_lit_comp("(Win32) Floating-Point Invalid Operation"),
str8_lit_comp("(Win32) Floating-Point Overflow"),
str8_lit_comp("(Win32) Floating-Point Stack Check"),
str8_lit_comp("(Win32) Floating-Point Underflow"),
str8_lit_comp("(Win32) Integer Division By Zero"),
str8_lit_comp("(Win32) Integer Overflow"),
str8_lit_comp("(Win32) Privileged Instruction"),
str8_lit_comp("(Win32) Stack Overflow"),
str8_lit_comp("(Win32) Unable To Locate DLL"),
str8_lit_comp("(Win32) Ordinal Not Found"),
str8_lit_comp("(Win32) Entry Point Not Found"),
str8_lit_comp("(Win32) DLL Initialization Failed"),
str8_lit_comp("(Win32) Floating Point SSE Multiple Faults"),
str8_lit_comp("(Win32) Floating Point SSE Multiple Traps"),
str8_lit_comp("(Win32) Assertion Failed"),
str8_lit_comp("(Win32) Module Not Found"),
str8_lit_comp("(Win32) Procedure Not Found"),
str8_lit_comp("(Win32) Sanitizer Error Detected"),
str8_lit_comp("(Win32) Sanitizer Raw Access Violation"),
};
String8 ctrl_exception_code_kind_lowercase_code_string_table[] =
{
{0},
str8_lit_comp("win32_ctrl_c"),
str8_lit_comp("win32_ctrl_break"),
str8_lit_comp("win32_win_rt_originate_error"),
str8_lit_comp("win32_win_rt_transform_error"),
str8_lit_comp("win32_rpc_call_cancelled"),
str8_lit_comp("win32_datatype_misalignment"),
str8_lit_comp("win32_access_violation"),
str8_lit_comp("win32_in_page_error"),
str8_lit_comp("win32_invalid_handle"),
str8_lit_comp("win32_not_enough_quota"),
str8_lit_comp("win32_illegal_instruction"),
str8_lit_comp("win32_cannot_continue_exception"),
str8_lit_comp("win32_invalid_exception_disposition"),
str8_lit_comp("win32_array_bounds_exceeded"),
str8_lit_comp("win32_floating_point_denormal_operand"),
str8_lit_comp("win32_floating_point_division_by_zero"),
str8_lit_comp("win32_floating_point_inexact_result"),
str8_lit_comp("win32_floating_point_invalid_operation"),
str8_lit_comp("win32_floating_point_overflow"),
str8_lit_comp("win32_floating_point_stack_check"),
str8_lit_comp("win32_floating_point_underflow"),
str8_lit_comp("win32_integer_division_by_zero"),
str8_lit_comp("win32_integer_overflow"),
str8_lit_comp("win32_privileged_instruction"),
str8_lit_comp("win32_stack_overflow"),
str8_lit_comp("win32_unable_to_locate_dll"),
str8_lit_comp("win32_ordinal_not_found"),
str8_lit_comp("win32_entry_point_not_found"),
str8_lit_comp("win32_dll_initialization_failed"),
str8_lit_comp("win32_floating_point_sse_multiple_faults"),
str8_lit_comp("win32_floating_point_sse_multiple_traps"),
str8_lit_comp("win32_assertion_failed"),
str8_lit_comp("win32_module_not_found"),
str8_lit_comp("win32_procedure_not_found"),
str8_lit_comp("win32_sanitizer_error_detected"),
str8_lit_comp("win32_sanitizer_raw_access_violation"),
};
B8 ctrl_exception_code_kind_default_enable_table[] =
{
0,
1,
1,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
};
#endif // CTRL_META_H
-539
View File
@@ -1,539 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Main Layer Initialization
internal void
dasm_init(void)
{
Arena *arena = arena_alloc();
dasm_shared = push_array(arena, DASM_Shared, 1);
dasm_shared->arena = arena;
dasm_shared->entity_map.slots_count = 1024;
dasm_shared->entity_map.slots = push_array(arena, DASM_EntitySlot, dasm_shared->entity_map.slots_count);
dasm_shared->entity_map_stripes.count = 64;
dasm_shared->entity_map_stripes.v = push_array(arena, DASM_Stripe, dasm_shared->entity_map_stripes.count);
for(U64 idx = 0; idx < dasm_shared->entity_map_stripes.count; idx += 1)
{
dasm_shared->entity_map_stripes.v[idx].arena = arena_alloc();
dasm_shared->entity_map_stripes.v[idx].rw_mutex = os_rw_mutex_alloc();
dasm_shared->entity_map_stripes.v[idx].cv = os_condition_variable_alloc();
}
dasm_shared->u2d_ring_mutex = os_mutex_alloc();
dasm_shared->u2d_ring_cv = os_condition_variable_alloc();
dasm_shared->u2d_ring_size = KB(64);
dasm_shared->u2d_ring_base = push_array_no_zero(arena, U8, dasm_shared->u2d_ring_size);
dasm_shared->decode_thread_count = Max(1, os_logical_core_count()-1);
dasm_shared->decode_threads = push_array(arena, OS_Handle, dasm_shared->decode_thread_count);
for(U64 idx = 0; idx < dasm_shared->decode_thread_count; idx += 1)
{
dasm_shared->decode_threads[idx] = os_launch_thread(dasm_decode_thread_entry_point, (void *)idx, 0);
}
}
////////////////////////////////
//~ rjf: Basic Helpers
internal U64
dasm_hash_from_string(String8 string)
{
U64 result = 5381;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
}
return result;
}
////////////////////////////////
//~ rjf: Instruction Type Functions
internal void
dasm_inst_chunk_list_push(Arena *arena, DASM_InstChunkList *list, U64 cap, DASM_Inst *inst)
{
DASM_InstChunkNode *node = list->last;
if(node == 0 || node->count >= node->cap)
{
node = push_array(arena, DASM_InstChunkNode, 1);
node->v = push_array_no_zero(arena, DASM_Inst, cap);
node->cap = cap;
SLLQueuePush(list->first, list->last, node);
list->node_count += 1;
}
MemoryCopyStruct(&node->v[node->count], inst);
node->count += 1;
list->inst_count += 1;
}
internal DASM_InstArray
dasm_inst_array_from_chunk_list(Arena *arena, DASM_InstChunkList *list)
{
DASM_InstArray array = {0};
array.count = list->inst_count;
array.v = push_array_no_zero(arena, DASM_Inst, array.count);
U64 idx = 0;
for(DASM_InstChunkNode *n = list->first; n != 0; n = n->next)
{
MemoryCopy(array.v+idx, n->v, sizeof(DASM_Inst)*n->count);
idx += n->count;
}
return array;
}
internal U64
dasm_inst_array_idx_from_off__linear_scan(DASM_InstArray *array, U64 off)
{
U64 result = 0;
for(U64 idx = 0; idx < array->count; idx += 1)
{
if(array->v[idx].off == off)
{
result = idx;
break;
}
}
return result;
}
internal U64
dasm_inst_array_off_from_idx(DASM_InstArray *array, U64 idx)
{
U64 off = 0;
if(idx < array->count)
{
off = array->v[idx].off;
}
return off;
}
////////////////////////////////
//~ rjf: Disassembly Functions
#include "third_party/udis86/config.h"
#include "third_party/udis86/udis86.h"
#include "third_party/udis86/libudis86/decode.c"
#include "third_party/udis86/libudis86/itab.c"
#include "third_party/udis86/libudis86/syn-att.c"
#include "third_party/udis86/libudis86/syn-intel.c"
#include "third_party/udis86/libudis86/syn.c"
#include "third_party/udis86/libudis86/udis86.c"
internal DASM_InstChunkList
dasm_inst_chunk_list_from_arch_addr_data(Arena *arena, U64 *bytes_processed_counter, Architecture arch, U64 addr, String8 data)
{
DASM_InstChunkList inst_list = {0};
switch(arch)
{
default:{}break;
//- rjf: x86/x64 decoding
case Architecture_x64:
case Architecture_x86:
{
// rjf: grab context
struct ud udc;
ud_init(&udc);
ud_set_mode(&udc, bit_size_from_arch(arch));
ud_set_pc(&udc, addr);
ud_set_input_buffer(&udc, data.str, data.size);
ud_set_vendor(&udc, UD_VENDOR_ANY);
ud_set_syntax(&udc, UD_SYN_INTEL);
// rjf: disassemble
U64 byte_process_start_off = 0;
for(U64 off = 0; off < data.size;)
{
// rjf: disassemble one instruction
U64 size = ud_disassemble(&udc);
if(size == 0)
{
break;
}
// rjf: analyze
struct ud_operand *first_op = (struct ud_operand *)ud_insn_opr(&udc, 0);
U64 rel_voff = (first_op != 0 && first_op->type == UD_OP_JIMM) ? ud_syn_rel_target(&udc, first_op) : 0;
// rjf: push
String8 string = push_str8f(arena, "%s", udc.asm_buf);
DASM_Inst inst = {string, off, rel_voff};
dasm_inst_chunk_list_push(arena, &inst_list, 1024, &inst);
// rjf: increment
off += size;
if(bytes_processed_counter != 0 && (off-byte_process_start_off >= 1000))
{
ins_atomic_u64_add_eval(bytes_processed_counter, (off-byte_process_start_off));
byte_process_start_off = off;
}
}
}break;
}
return inst_list;
}
////////////////////////////////
//~ rjf: Cache Lookups
//- rjf: opening handles & correllation with module
internal DASM_Handle
dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, CTRL_Handle process, Rng1U64 vaddr_range)
{
DASM_Handle result = {0};
if(machine != 0 && process.u64[0] != 0)
{
U64 hash = dasm_hash_from_string(str8_struct(&process));
U64 slot_idx = hash%dasm_shared->entity_map.slots_count;
U64 stripe_idx = slot_idx%dasm_shared->entity_map_stripes.count;
DASM_EntitySlot *slot = &dasm_shared->entity_map.slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->entity_map_stripes.v[stripe_idx];
OS_MutexScopeW(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->machine_id == machine &&
ctrl_handle_match(e->process, process) &&
MemoryMatchStruct(&e->vaddr_range, &vaddr_range))
{
entity = e;
break;
}
}
if(entity == 0)
{
entity = push_array(stripe->arena, DASM_Entity, 1);
SLLQueuePush(slot->first, slot->last, entity);
entity->machine_id = machine;
entity->process = process;
entity->vaddr_range= vaddr_range;
entity->id = ins_atomic_u64_inc_eval(&dasm_shared->entity_id_gen);
entity->decode_inst_arena = arena_alloc__sized(MB(256), KB(64));
entity->decode_string_arena = arena_alloc__sized(GB(1), KB(64));
}
result.u64[0] = hash;
result.u64[1] = entity->id;
}
}
return result;
}
//- rjf: asking for top-level info of a handle
internal DASM_BinaryInfo
dasm_binary_info_from_handle(Arena *arena, DASM_Handle handle)
{
DASM_BinaryInfo info = {0};
{
U64 hash = handle.u64[0];
U64 id = handle.u64[1];
U64 slot_idx = hash%dasm_shared->entity_map.slots_count;
U64 stripe_idx = slot_idx%dasm_shared->entity_map_stripes.count;
DASM_EntitySlot *slot = &dasm_shared->entity_map.slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->entity_map_stripes.v[stripe_idx];
OS_MutexScopeR(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
if(entity != 0)
{
info.machine_id = entity->machine_id;
info.process = entity->process;
info.vaddr_range = entity->vaddr_range;
info.bytes_processed = ins_atomic_u64_eval(&entity->bytes_processed);
info.bytes_to_process = ins_atomic_u64_eval(&entity->bytes_to_process);
}
}
}
return info;
}
//- rjf: asking for decoded instructions
internal DASM_InstArray
dasm_inst_array_from_handle(Arena *arena, DASM_Handle handle, U64 endt_us)
{
DASM_InstArray result = {0};
{
U64 hash = handle.u64[0];
U64 id = handle.u64[1];
U64 slot_idx = hash%dasm_shared->entity_map.slots_count;
U64 stripe_idx = slot_idx%dasm_shared->entity_map_stripes.count;
DASM_EntitySlot *slot = &dasm_shared->entity_map.slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->entity_map_stripes.v[stripe_idx];
B32 sent = 0;
OS_MutexScopeR(stripe->rw_mutex) for(;;)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
U64 last_time_sent_us = 0;
if(entity != 0)
{
U64 bytes_processed = ins_atomic_u64_eval(&entity->bytes_processed);
U64 bytes_to_process = ins_atomic_u64_eval(&entity->bytes_to_process);
last_time_sent_us = ins_atomic_u64_eval(&entity->last_time_sent_us);
if(bytes_processed == bytes_to_process && bytes_processed != 0)
{
result.count = entity->decode_inst_array.count;
result.v = push_array_no_zero(arena, DASM_Inst, result.count);
MemoryCopy(result.v, entity->decode_inst_array.v, sizeof(DASM_Inst)*result.count);
for(U64 idx = 0; idx < result.count; idx += 1)
{
result.v[idx].string = push_str8_copy(arena, result.v[idx].string);
}
break;
}
}
if(!sent && entity != 0 && last_time_sent_us+10000 <= os_now_microseconds())
{
DASM_DecodeRequest req = {handle};
sent = dasm_u2d_enqueue_request(&req, endt_us);
ins_atomic_u64_eval_assign(&entity->last_time_sent_us, os_now_microseconds());
}
if(os_now_microseconds() >= endt_us)
{
break;
}
os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us);
}
}
return result;
}
////////////////////////////////
//~ rjf: Decode Threads
internal B32
dasm_u2d_enqueue_request(DASM_DecodeRequest *req, U64 endt_us)
{
B32 result = 0;
OS_MutexScope(dasm_shared->u2d_ring_mutex) for(;;)
{
U64 unconsumed_size = (dasm_shared->u2d_ring_write_pos-dasm_shared->u2d_ring_read_pos);
U64 available_size = (dasm_shared->u2d_ring_size-unconsumed_size);
if(available_size >= sizeof(*req))
{
result = 1;
dasm_shared->u2d_ring_write_pos += ring_write_struct(dasm_shared->u2d_ring_base, dasm_shared->u2d_ring_size, dasm_shared->u2d_ring_write_pos, req);
dasm_shared->u2d_ring_write_pos += 7;
dasm_shared->u2d_ring_write_pos -= dasm_shared->u2d_ring_write_pos%8;
break;
}
if(os_now_microseconds() >= endt_us)
{
break;
}
os_condition_variable_wait(dasm_shared->u2d_ring_cv, dasm_shared->u2d_ring_mutex, endt_us);
}
if(result)
{
os_condition_variable_broadcast(dasm_shared->u2d_ring_cv);
}
return result;
}
internal DASM_DecodeRequest
dasm_u2d_dequeue_request(void)
{
DASM_DecodeRequest req = {0};
OS_MutexScope(dasm_shared->u2d_ring_mutex) for(;;)
{
U64 unconsumed_size = (dasm_shared->u2d_ring_write_pos-dasm_shared->u2d_ring_read_pos);
if(unconsumed_size >= sizeof(DASM_DecodeRequest))
{
dasm_shared->u2d_ring_read_pos += ring_read_struct(dasm_shared->u2d_ring_base, dasm_shared->u2d_ring_size, dasm_shared->u2d_ring_read_pos, &req);
dasm_shared->u2d_ring_read_pos += 7;
dasm_shared->u2d_ring_read_pos -= dasm_shared->u2d_ring_read_pos%8;
break;
}
os_condition_variable_wait(dasm_shared->u2d_ring_cv, dasm_shared->u2d_ring_mutex, max_U64);
}
os_condition_variable_broadcast(dasm_shared->u2d_ring_cv);
return req;
}
internal void
dasm_decode_thread_entry_point(void *p)
{
TCTX tctx_;
tctx_init_and_equip(&tctx_);
for(;;)
{
Temp scratch = scratch_begin(0, 0);
//- rjf: get next request & unpack
DASM_DecodeRequest req = dasm_u2d_dequeue_request();
DASM_Handle handle = req.handle;
U64 hash = handle.u64[0];
U64 id = handle.u64[1];
U64 slot_idx = hash%dasm_shared->entity_map.slots_count;
U64 stripe_idx = slot_idx%dasm_shared->entity_map_stripes.count;
DASM_EntitySlot *slot = &dasm_shared->entity_map.slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->entity_map_stripes.v[stripe_idx];
//- rjf: request -> ctrl info
B32 is_first_to_task = 0;
CTRL_MachineID ctrl_machine_id = 0;
CTRL_Handle ctrl_process = {0};
Rng1U64 vaddr_range = {0};
Architecture arch = Architecture_Null;
U64 *bytes_processed_counter = 0;
OS_MutexScopeR(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
if(entity != 0)
{
U64 initial_working_count = ins_atomic_u32_eval_cond_assign(&entity->working_count, 1, 0);
if(initial_working_count == 0)
{
is_first_to_task = 1;
ctrl_machine_id = entity->machine_id;
ctrl_process = entity->process;
vaddr_range = entity->vaddr_range;
arch = ctrl_arch_from_handle(ctrl_machine_id, ctrl_process);
bytes_processed_counter = &entity->bytes_processed;
U64 bytes_to_process = dim_1u64(vaddr_range);
ins_atomic_u64_eval_assign(&entity->bytes_processed, 0);
ins_atomic_u64_eval_assign(&entity->bytes_to_process, bytes_to_process);
}
}
}
//- rjf: bad handle or machine id -> bad task
B32 good_task = (is_first_to_task && ctrl_process.u64[0] != 0 && ctrl_machine_id != 0 && arch != Architecture_Null && bytes_processed_counter != 0);
//- rjf: good task -> clear entity's info
if(good_task)
{
OS_MutexScopeW(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
if(entity != 0)
{
arena_clear(entity->decode_inst_arena);
arena_clear(entity->decode_string_arena);
MemoryZeroStruct(&entity->decode_inst_array);
}
}
}
//- rjf: good task -> read process memory & decode instructions - stop each
// 4k and write into cache, so users can read incremental results
if(good_task)
{
U64 chunk_size = KB(4);
for(U64 off = 0; vaddr_range.min+off < vaddr_range.max; off += chunk_size)
{
Rng1U64 chunk_vaddr_range = r1u64(vaddr_range.min+off, vaddr_range.min+off+chunk_size);
chunk_vaddr_range.min = ClampTop(chunk_vaddr_range.min, vaddr_range.max);
chunk_vaddr_range.max = ClampTop(chunk_vaddr_range.max, vaddr_range.max);
//- rjf: read next chunk & decode
String8 data = {0};
DASM_InstChunkList inst_list = {0};
if(good_task)
{
data.str = push_array_no_zero(scratch.arena, U8, dim_1u64(chunk_vaddr_range));
data.size = ctrl_process_read(ctrl_machine_id, ctrl_process, chunk_vaddr_range, data.str);
if(data.size != 0)
{
inst_list = dasm_inst_chunk_list_from_arch_addr_data(scratch.arena, bytes_processed_counter, arch, chunk_vaddr_range.min, data);
}
}
//- rjf: write into cache
{
OS_MutexScopeW(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
if(entity != 0)
{
DASM_Inst *new_chunk_base = push_array(entity->decode_inst_arena, DASM_Inst, inst_list.inst_count);
U64 off = 0;
for(DASM_InstChunkNode *node = inst_list.first; node != 0; node = node->next)
{
MemoryCopy(new_chunk_base+off, node->v, sizeof(DASM_Inst)*node->count);
off += node->count;
}
for(U64 idx = 0; idx < inst_list.inst_count; idx += 1)
{
new_chunk_base[idx].string = push_str8_copy(entity->decode_string_arena, new_chunk_base[idx].string);
}
entity->decode_inst_array.count += inst_list.inst_count;
if(entity->decode_inst_array.v == 0)
{
entity->decode_inst_array.v = new_chunk_base;
}
}
}
os_condition_variable_broadcast(stripe->cv);
}
}
}
//- rjf: mark task as complete
if(good_task)
{
OS_MutexScopeR(stripe->rw_mutex)
{
DASM_Entity *entity = 0;
for(DASM_Entity *e = slot->first; e != 0; e = e->next)
{
if(e->id == id)
{
entity = e;
break;
}
}
if(entity != 0)
{
U64 bytes_to_process = ins_atomic_u64_eval(&entity->bytes_to_process);
ins_atomic_u64_eval_assign(&entity->bytes_processed, bytes_to_process);
ins_atomic_u64_eval_assign(&entity->working_count, 0);
}
}
}
scratch_end(scratch);
}
}
-206
View File
@@ -1,206 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DASM_H
#define DASM_H
////////////////////////////////
//~ rjf: Handle Type
typedef struct DASM_Handle DASM_Handle;
struct DASM_Handle
{
U64 u64[2];
};
////////////////////////////////
//~ rjf: Instruction Types
typedef struct DASM_Inst DASM_Inst;
struct DASM_Inst
{
String8 string;
U64 off;
U64 addr;
};
typedef struct DASM_InstChunkNode DASM_InstChunkNode;
struct DASM_InstChunkNode
{
DASM_InstChunkNode *next;
DASM_Inst *v;
U64 cap;
U64 count;
};
typedef struct DASM_InstChunkNode DASM_InstChunkNode;
struct DASM_InstChunkList
{
DASM_InstChunkNode *first;
DASM_InstChunkNode *last;
U64 node_count;
U64 inst_count;
};
typedef struct DASM_InstArray DASM_InstArray;
struct DASM_InstArray
{
DASM_Inst *v;
U64 count;
};
////////////////////////////////
//~ rjf: Striped Access Types
typedef struct DASM_Stripe DASM_Stripe;
struct DASM_Stripe
{
Arena *arena;
OS_Handle cv;
OS_Handle rw_mutex;
};
typedef struct DASM_StripeTable DASM_StripeTable;
struct DASM_StripeTable
{
U64 count;
DASM_Stripe *v;
};
////////////////////////////////
//~ rjf: Entity Cache Types
typedef struct DASM_Entity DASM_Entity;
struct DASM_Entity
{
DASM_Entity *next;
// rjf: key info
CTRL_MachineID machine_id;
CTRL_Handle process;
Rng1U64 vaddr_range;
U64 id;
// rjf: top-level info
U64 last_time_sent_us;
U64 working_count;
U64 bytes_processed;
U64 bytes_to_process;
// rjf: decoded instruction data
Arena *decode_inst_arena;
Arena *decode_string_arena;
DASM_InstArray decode_inst_array;
};
typedef struct DASM_EntitySlot DASM_EntitySlot;
struct DASM_EntitySlot
{
DASM_Entity *first;
DASM_Entity *last;
};
typedef struct DASM_EntityMap DASM_EntityMap;
struct DASM_EntityMap
{
U64 slots_count;
DASM_EntitySlot *slots;
};
////////////////////////////////
//~ rjf: Introspection Info Types
typedef struct DASM_BinaryInfo DASM_BinaryInfo;
struct DASM_BinaryInfo
{
CTRL_MachineID machine_id;
CTRL_Handle process;
Rng1U64 vaddr_range;
U64 bytes_processed;
U64 bytes_to_process;
};
////////////////////////////////
//~ rjf: Decode Request Types
typedef struct DASM_DecodeRequest DASM_DecodeRequest;
struct DASM_DecodeRequest
{
DASM_Handle handle;
};
////////////////////////////////
//~ rjf: Shared State
typedef struct DASM_Shared DASM_Shared;
struct DASM_Shared
{
Arena *arena;
// rjf: entity table
DASM_EntityMap entity_map;
DASM_StripeTable entity_map_stripes;
U64 entity_id_gen;
// rjf: user -> decode ring
OS_Handle u2d_ring_mutex;
OS_Handle u2d_ring_cv;
U64 u2d_ring_size;
U8 *u2d_ring_base;
U64 u2d_ring_write_pos;
U64 u2d_ring_read_pos;
// rjf: decode threads
U64 decode_thread_count;
OS_Handle *decode_threads;
};
////////////////////////////////
//~ rjf: Globals
global DASM_Shared *dasm_shared = 0;
////////////////////////////////
//~ rjf: Main Layer Initialization
internal void dasm_init(void);
////////////////////////////////
//~ rjf: Basic Helpers
internal U64 dasm_hash_from_string(String8 string);
////////////////////////////////
//~ rjf: Instruction Type Functions
internal void dasm_inst_chunk_list_push(Arena *arena, DASM_InstChunkList *list, U64 cap, DASM_Inst *inst);
internal DASM_InstArray dasm_inst_array_from_chunk_list(Arena *arena, DASM_InstChunkList *list);
internal U64 dasm_inst_array_idx_from_off__linear_scan(DASM_InstArray *array, U64 off);
internal U64 dasm_inst_array_off_from_idx(DASM_InstArray *array, U64 idx);
////////////////////////////////
//~ rjf: Disassembly Functions
internal DASM_InstChunkList dasm_inst_chunk_list_from_arch_addr_data(Arena *arena, U64 *bytes_processed_counter, Architecture arch, U64 addr, String8 data);
////////////////////////////////
//~ rjf: Cache Lookups
//- rjf: opening handles & correllation with module
internal DASM_Handle dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, CTRL_Handle process, Rng1U64 vaddr_range);
//- rjf: asking for top-level info of a handle
internal DASM_BinaryInfo dasm_binary_info_from_handle(Arena *arena, DASM_Handle handle);
//- rjf: asking for decoded instructions
internal DASM_InstArray dasm_inst_array_from_handle(Arena *arena, DASM_Handle handle, U64 endt_us);
////////////////////////////////
//~ rjf: Decode Threads
internal B32 dasm_u2d_enqueue_request(DASM_DecodeRequest *req, U64 endt_us);
internal DASM_DecodeRequest dasm_u2d_dequeue_request(void);
internal void dasm_decode_thread_entry_point(void *p);
#endif //DASM_H
+856
View File
@@ -0,0 +1,856 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Instruction Decoding/Disassembling Type Functions
#if !defined(ZYDIS_H)
#include "third_party/zydis/zydis.h"
#include "third_party/zydis/zydis.c"
#endif
internal DASM_Inst
dasm_inst_from_code(Arena *arena, Arch arch, U64 vaddr, String8 code, DASM_Syntax syntax)
{
DASM_Inst inst = {0};
switch(arch)
{
default:{}break;
//- rjf: x86/x64 disassembly
case Arch_x86:
case Arch_x64:
{
// rjf: determine zydis formatter style
ZydisFormatterStyle style = ZYDIS_FORMATTER_STYLE_INTEL;
switch(syntax)
{
default:{}break;
case DASM_Syntax_Intel:{style = ZYDIS_FORMATTER_STYLE_INTEL;}break;
case DASM_Syntax_ATT: {style = ZYDIS_FORMATTER_STYLE_ATT;}break;
}
// rjf: disassemble one instruction
ZydisDisassembledInstruction zinst = {0};
ZyanStatus status = ZydisDisassemble(ZYDIS_MACHINE_MODE_LONG_64, vaddr, code.str, code.size, &zinst, style);
// rjf: analyze
DASM_InstFlags flags = 0;
U64 jump_dest_vaddr = 0;
{
ZydisDecodedOperand *first_visible_op = (zinst.info.operand_count_visible > 0 ? &zinst.operands[0] : 0);
ZydisDecodedOperand *first_op = (zinst.info.operand_count > 0 ? &zinst.operands[0] : 0);
ZydisDecodedOperand *second_op = (zinst.info.operand_count > 1 ? &zinst.operands[1] : 0);
if(first_visible_op != 0 &&
(first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM8 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM16 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM32 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM64 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM16_32_64 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM32_32_64 ||
first_visible_op->encoding == ZYDIS_OPERAND_ENCODING_JIMM16_32_32))
{
ZydisCalcAbsoluteAddress(&zinst.info, first_visible_op, vaddr, &jump_dest_vaddr);
}
if(first_op != 0 && second_op != 0 && first_op->type == ZYDIS_OPERAND_TYPE_REGISTER &&
(first_op->reg.value == ZYDIS_REGISTER_RSP ||
first_op->reg.value == ZYDIS_REGISTER_ESP ||
first_op->reg.value == ZYDIS_REGISTER_SP))
{
flags |= DASM_InstFlag_ChangesStackPointer;
if(second_op->type != ZYDIS_OPERAND_TYPE_IMMEDIATE)
{
flags |= DASM_InstFlag_ChangesStackPointerVariably;
}
}
if(zinst.info.attributes & (ZYDIS_ATTRIB_HAS_REP|
ZYDIS_ATTRIB_HAS_REPE|
ZYDIS_ATTRIB_HAS_REPZ|
ZYDIS_ATTRIB_HAS_REPNZ|
ZYDIS_ATTRIB_HAS_REPNE))
{
flags |= DASM_InstFlag_Repeats;
}
switch(zinst.info.mnemonic)
{
case ZYDIS_MNEMONIC_CALL:
{
flags |= DASM_InstFlag_Call;
}break;
case ZYDIS_MNEMONIC_JB:
case ZYDIS_MNEMONIC_JBE:
case ZYDIS_MNEMONIC_JCXZ:
case ZYDIS_MNEMONIC_JECXZ:
case ZYDIS_MNEMONIC_JKNZD:
case ZYDIS_MNEMONIC_JKZD:
case ZYDIS_MNEMONIC_JL:
case ZYDIS_MNEMONIC_JLE:
case ZYDIS_MNEMONIC_JNB:
case ZYDIS_MNEMONIC_JNBE:
case ZYDIS_MNEMONIC_JNL:
case ZYDIS_MNEMONIC_JNLE:
case ZYDIS_MNEMONIC_JNO:
case ZYDIS_MNEMONIC_JNP:
case ZYDIS_MNEMONIC_JNS:
case ZYDIS_MNEMONIC_JNZ:
case ZYDIS_MNEMONIC_JO:
case ZYDIS_MNEMONIC_JP:
case ZYDIS_MNEMONIC_JRCXZ:
case ZYDIS_MNEMONIC_JS:
case ZYDIS_MNEMONIC_JZ:
case ZYDIS_MNEMONIC_LOOP:
case ZYDIS_MNEMONIC_LOOPE:
case ZYDIS_MNEMONIC_LOOPNE:
{
flags |= DASM_InstFlag_Branch;
}break;
case ZYDIS_MNEMONIC_JMP:
{
flags |= DASM_InstFlag_UnconditionalJump;
}break;
case ZYDIS_MNEMONIC_RET:
{
flags |= DASM_InstFlag_Return;
}break;
case ZYDIS_MNEMONIC_PUSH:
case ZYDIS_MNEMONIC_POP:
{
flags |= DASM_InstFlag_ChangesStackPointer;
}break;
default:
{
flags |= DASM_InstFlag_NonFlow;
}break;
}
}
// rjf: convert
{
inst.flags = flags;
inst.size = zinst.info.length;
inst.string = push_str8_copy(arena, str8_cstring(zinst.text));
inst.jump_dest_vaddr = jump_dest_vaddr;
}
}break;
}
return inst;
}
////////////////////////////////
//~ rjf: Control Flow Analysis
internal DASM_CtrlFlowInfo
dasm_ctrl_flow_info_from_arch_vaddr_code(Arena *arena, DASM_InstFlags exit_points_mask, Arch arch, U64 vaddr, String8 code)
{
Temp scratch = scratch_begin(&arena, 1);
DASM_CtrlFlowInfo info = {0};
for(U64 offset = 0; offset < code.size;)
{
DASM_Inst inst = dasm_inst_from_code(scratch.arena, arch, vaddr+offset, str8_skip(code, offset), DASM_Syntax_Intel);
U64 inst_vaddr = vaddr+offset;
offset += inst.size;
info.total_size += inst.size;
if(inst.flags & exit_points_mask)
{
DASM_CtrlFlowPoint point = {0};
point.inst_flags = inst.flags;
point.vaddr = inst_vaddr;
point.jump_dest_vaddr = inst.jump_dest_vaddr;
DASM_CtrlFlowPointNode *node = push_array(arena, DASM_CtrlFlowPointNode, 1);
node->v = point;
SLLQueuePush(info.exit_points.first, info.exit_points.last, node);
info.exit_points.count += 1;
}
}
scratch_end(scratch);
return info;
}
////////////////////////////////
//~ rjf: Parameter Type Functions
internal B32
dasm_params_match(DASM_Params *a, DASM_Params *b)
{
B32 result = (a->vaddr == b->vaddr &&
a->arch == b->arch &&
a->style_flags == b->style_flags &&
a->syntax == b->syntax &&
a->base_vaddr == b->base_vaddr &&
di_key_match(&a->dbgi_key, &b->dbgi_key));
return result;
}
////////////////////////////////
//~ rjf: Line Type Functions
internal void
dasm_line_chunk_list_push(Arena *arena, DASM_LineChunkList *list, U64 cap, DASM_Line *inst)
{
DASM_LineChunkNode *node = list->last;
if(node == 0 || node->count >= node->cap)
{
node = push_array(arena, DASM_LineChunkNode, 1);
node->v = push_array_no_zero(arena, DASM_Line, cap);
node->cap = cap;
SLLQueuePush(list->first, list->last, node);
list->node_count += 1;
}
MemoryCopyStruct(&node->v[node->count], inst);
node->count += 1;
list->line_count += 1;
}
internal DASM_LineArray
dasm_line_array_from_chunk_list(Arena *arena, DASM_LineChunkList *list)
{
DASM_LineArray array = {0};
array.count = list->line_count;
array.v = push_array_no_zero(arena, DASM_Line, array.count);
U64 idx = 0;
for(DASM_LineChunkNode *n = list->first; n != 0; n = n->next)
{
MemoryCopy(array.v+idx, n->v, sizeof(DASM_Line)*n->count);
idx += n->count;
}
return array;
}
internal U64
dasm_line_array_idx_from_code_off__linear_scan(DASM_LineArray *array, U64 off)
{
U64 result = 0;
for(U64 idx = 0; idx < array->count; idx += 1)
{
U64 next_off = (idx+1 < array->count ? array->v[idx+1].code_off : max_U64);
if(array->v[idx].code_off <= off && off < next_off)
{
result = idx;
if(!(array->v[idx].flags & DASM_LineFlag_Decorative))
{
break;
}
}
}
return result;
}
internal U64
dasm_line_array_code_off_from_idx(DASM_LineArray *array, U64 idx)
{
U64 off = 0;
if(idx < array->count)
{
off = array->v[idx].code_off;
}
return off;
}
////////////////////////////////
//~ rjf: Main Layer Initialization
internal void
dasm_init(void)
{
Arena *arena = arena_alloc();
dasm_shared = push_array(arena, DASM_Shared, 1);
dasm_shared->arena = arena;
dasm_shared->slots_count = 1024;
dasm_shared->stripes_count = Min(dasm_shared->slots_count, os_get_system_info()->logical_processor_count);
dasm_shared->slots = push_array(arena, DASM_Slot, dasm_shared->slots_count);
dasm_shared->stripes = push_array(arena, DASM_Stripe, dasm_shared->stripes_count);
for(U64 idx = 0; idx < dasm_shared->stripes_count; idx += 1)
{
dasm_shared->stripes[idx].arena = arena_alloc();
dasm_shared->stripes[idx].rw_mutex = os_rw_mutex_alloc();
dasm_shared->stripes[idx].cv = os_condition_variable_alloc();
}
dasm_shared->u2p_ring_size = KB(64);
dasm_shared->u2p_ring_base = push_array_no_zero(arena, U8, dasm_shared->u2p_ring_size);
dasm_shared->u2p_ring_cv = os_condition_variable_alloc();
dasm_shared->u2p_ring_mutex = os_mutex_alloc();
dasm_shared->evictor_detector_thread = os_thread_launch(dasm_evictor_detector_thread__entry_point, 0, 0);
}
////////////////////////////////
//~ rjf: Scoped Access
internal DASM_Scope *
dasm_scope_open(void)
{
if(dasm_tctx == 0)
{
Arena *arena = arena_alloc();
dasm_tctx = push_array(arena, DASM_TCTX, 1);
dasm_tctx->arena = arena;
}
U64 base_pos = arena_pos(dasm_tctx->arena);
DASM_Scope *scope = push_array(dasm_tctx->arena, DASM_Scope, 1);
scope->base_pos = base_pos;
return scope;
}
internal void
dasm_scope_close(DASM_Scope *scope)
{
for(DASM_Touch *t = scope->top_touch, *next = 0; t != 0; t = next)
{
next = t->next;
U64 slot_idx = t->hash.u64[1]%dasm_shared->slots_count;
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
DASM_Slot *slot = &dasm_shared->slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx];
OS_MutexScopeR(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(u128_match(t->hash, n->hash) && dasm_params_match(&t->params, &n->params))
{
ins_atomic_u64_dec_eval(&n->scope_ref_count);
break;
}
}
}
}
arena_pop_to(dasm_tctx->arena, scope->base_pos);
}
internal void
dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node)
{
DASM_Touch *touch = push_array(dasm_tctx->arena, DASM_Touch, 1);
ins_atomic_u64_inc_eval(&node->scope_ref_count);
ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds());
ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx());
touch->hash = node->hash;
MemoryCopyStruct(&touch->params, &node->params);
touch->params.dbgi_key = di_key_copy(dasm_tctx->arena, &touch->params.dbgi_key);
SLLStackPush(scope->top_touch, touch);
}
////////////////////////////////
//~ rjf: Cache Lookups
internal DASM_Info
dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params)
{
DASM_Info info = {0};
if(!u128_match(hash, u128_zero()))
{
U64 slot_idx = hash.u64[1]%dasm_shared->slots_count;
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
DASM_Slot *slot = &dasm_shared->slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx];
B32 found = 0;
OS_MutexScopeR(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(u128_match(hash, n->hash) && dasm_params_match(params, &n->params))
{
MemoryCopyStruct(&info, &n->info);
found = 1;
dasm_scope_touch_node__stripe_r_guarded(scope, n);
break;
}
}
}
B32 node_is_new = 0;
if(!found)
{
OS_MutexScopeW(stripe->rw_mutex)
{
DASM_Node *node = 0;
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(u128_match(hash, n->hash) && dasm_params_match(params, &n->params))
{
node = n;
break;
}
}
if(node == 0)
{
LogInfoNamedBlockF("dasm_new_node")
{
log_infof("hash: [0x%I64x 0x%I64x]\n", hash.u64[0], hash.u64[1]);
log_infof("vaddr: 0x%I64x\n", params->vaddr);
log_infof("arch: %S\n", string_from_arch(params->arch));
log_infof("style_flags: 0x%x\n", params->style_flags);
log_infof("syntax: %i\n", params->syntax);
log_infof("base_vaddr: 0x%I64x\n", params->base_vaddr);
log_infof("dbgi_key: [%S 0x%I64x]\n", params->dbgi_key.path, params->dbgi_key.min_timestamp);
}
node = stripe->free_node;
if(node)
{
SLLStackPop(stripe->free_node);
}
else
{
node = push_array_no_zero(stripe->arena, DASM_Node, 1);
}
MemoryZeroStruct(node);
DLLPushBack(slot->first, slot->last, node);
node->hash = hash;
MemoryCopyStruct(&node->params, params);
// TODO(rjf): need to make this releasable - currently all exe_paths just leak
node->params.dbgi_key = di_key_copy(stripe->arena, &node->params.dbgi_key);
node_is_new = 1;
}
}
}
if(node_is_new)
{
dasm_u2p_enqueue_req(hash, params, max_U64);
async_push_work(dasm_parse_work);
}
}
return info;
}
internal DASM_Info
dasm_info_from_key_params(DASM_Scope *scope, U128 key, DASM_Params *params, U128 *hash_out)
{
DASM_Info result = {0};
for(U64 rewind_idx = 0; rewind_idx < HS_KEY_HASH_HISTORY_COUNT; rewind_idx += 1)
{
U128 hash = hs_hash_from_key(key, rewind_idx);
result = dasm_info_from_hash_params(scope, hash, params);
if(result.lines.count != 0)
{
if(hash_out)
{
*hash_out = hash;
}
break;
}
}
return result;
}
////////////////////////////////
//~ rjf: Parse Threads
internal B32
dasm_u2p_enqueue_req(U128 hash, DASM_Params *params, U64 endt_us)
{
B32 good = 0;
OS_MutexScope(dasm_shared->u2p_ring_mutex) for(;;)
{
U64 unconsumed_size = dasm_shared->u2p_ring_write_pos - dasm_shared->u2p_ring_read_pos;
U64 available_size = dasm_shared->u2p_ring_size - unconsumed_size;
if(available_size >= sizeof(hash)+sizeof(U64)+sizeof(Arch)+sizeof(DASM_StyleFlags)+sizeof(DASM_Syntax)+sizeof(U64)+sizeof(U64)+params->dbgi_key.path.size+sizeof(U64))
{
good = 1;
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &hash);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->vaddr);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->arch);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->style_flags);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->syntax);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->base_vaddr);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->dbgi_key.path.size);
dasm_shared->u2p_ring_write_pos += ring_write(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, params->dbgi_key.path.str, params->dbgi_key.path.size);
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &params->dbgi_key.min_timestamp);
break;
}
if(os_now_microseconds() >= endt_us)
{
break;
}
os_condition_variable_wait(dasm_shared->u2p_ring_cv, dasm_shared->u2p_ring_mutex, endt_us);
}
if(good)
{
os_condition_variable_broadcast(dasm_shared->u2p_ring_cv);
}
return good;
}
internal void
dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out)
{
OS_MutexScope(dasm_shared->u2p_ring_mutex) for(;;)
{
U64 unconsumed_size = dasm_shared->u2p_ring_write_pos - dasm_shared->u2p_ring_read_pos;
if(unconsumed_size >= sizeof(*hash_out)+sizeof(U64)+sizeof(Arch)+sizeof(DASM_StyleFlags)+sizeof(DASM_Syntax)+sizeof(U64)+sizeof(U64)+sizeof(U64))
{
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, hash_out);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->vaddr);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->arch);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->style_flags);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->syntax);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->base_vaddr);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->dbgi_key.path.size);
params_out->dbgi_key.path.str = push_array(arena, U8, params_out->dbgi_key.path.size);
dasm_shared->u2p_ring_read_pos += ring_read(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, params_out->dbgi_key.path.str, params_out->dbgi_key.path.size);
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, &params_out->dbgi_key.min_timestamp);
break;
}
os_condition_variable_wait(dasm_shared->u2p_ring_cv, dasm_shared->u2p_ring_mutex, max_U64);
}
os_condition_variable_broadcast(dasm_shared->u2p_ring_cv);
}
ASYNC_WORK_DEF(dasm_parse_work)
{
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
HS_Scope *hs_scope = hs_scope_open();
DI_Scope *di_scope = di_scope_open();
TXT_Scope *txt_scope = txt_scope_open();
//- rjf: get next request
U128 hash = {0};
DASM_Params params = {0};
dasm_u2p_dequeue_req(scratch.arena, &hash, &params);
U64 change_gen = fs_change_gen();
//- rjf: unpack hash
U64 slot_idx = hash.u64[1]%dasm_shared->slots_count;
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
DASM_Slot *slot = &dasm_shared->slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx];
//- rjf: take task
B32 got_task = 0;
OS_MutexScopeR(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(u128_match(n->hash, hash) && dasm_params_match(&n->params, &params))
{
got_task = !ins_atomic_u32_eval_cond_assign(&n->is_working, 1, 0);
break;
}
}
}
//- rjf: get dbg info
RDI_Parsed *rdi = &di_rdi_parsed_nil;
if(got_task && params.dbgi_key.path.size != 0)
{
rdi = di_rdi_from_key(di_scope, &params.dbgi_key, max_U64);
}
//- rjf: hash -> data
String8 data = {0};
if(got_task)
{
data = hs_data_from_hash(hs_scope, hash);
}
//- rjf: data * arch * addr * dbg -> decode artifacts
DASM_LineChunkList line_list = {0};
String8List inst_strings = {0};
if(got_task)
{
switch(params.arch)
{
default:{}break;
//- rjf: x86/x64 decoding
case Arch_x64:
case Arch_x86:
{
// rjf: disassemble
RDI_SourceFile *last_file = &rdi_nil_element_union.source_file;
RDI_Line *last_line = 0;
for(U64 off = 0; off < data.size;)
{
// rjf: disassemble one instruction
DASM_Inst inst = dasm_inst_from_code(scratch.arena, params.arch, params.vaddr+off, str8_skip(data, off), params.syntax);
if(inst.size == 0)
{
break;
}
// rjf: push strings derived from voff -> line info
if(params.style_flags & (DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines))
{
if(rdi != &di_rdi_parsed_nil)
{
U64 voff = (params.vaddr+off) - params.base_vaddr;
U32 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, voff);
RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx);
RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx);
RDI_ParsedLineTable unit_line_info = {0};
rdi_parsed_from_line_table(rdi, line_table, &unit_line_info);
U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, voff);
if(line_info_idx < unit_line_info.count)
{
RDI_Line *line = &unit_line_info.lines[line_info_idx];
RDI_SourceFile *file = rdi_element_from_name_idx(rdi, SourceFiles, line->file_idx);
String8 file_normalized_full_path = {0};
file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size);
if(file != last_file)
{
if(params.style_flags & DASM_StyleFlag_SourceFilesNames &&
file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0)
{
String8 inst_string = push_str8f(scratch.arena, "> %S", file_normalized_full_path);
DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count,
inst_strings.total_size + inst_strings.node_count + inst_string.size)};
dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst);
str8_list_push(scratch.arena, &inst_strings, inst_string);
}
if(params.style_flags & DASM_StyleFlag_SourceFilesNames && file->normal_full_path_string_idx == 0)
{
String8 inst_string = str8_lit(">");
DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count,
inst_strings.total_size + inst_strings.node_count + inst_string.size)};
dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst);
str8_list_push(scratch.arena, &inst_strings, inst_string);
}
last_file = file;
}
if(line && line != last_line && file->normal_full_path_string_idx != 0 &&
params.style_flags & DASM_StyleFlag_SourceLines &&
file_normalized_full_path.size != 0)
{
FileProperties props = os_properties_from_file_path(file_normalized_full_path);
if(props.modified != 0)
{
// TODO(rjf): need redirection path - this may map to a different path on the local machine,
// need frontend to communicate path remapping info to this layer
U128 key = fs_key_from_path_range(file_normalized_full_path, r1u64(0, max_U64));
TXT_LangKind lang_kind = txt_lang_kind_from_extension(file_normalized_full_path);
U64 endt_us = max_U64;
U128 hash = {0};
TXT_TextInfo text_info = {0};
for(;os_now_microseconds() <= endt_us;)
{
text_info = txt_text_info_from_key_lang(txt_scope, key, lang_kind, &hash);
if(!u128_match(hash, u128_zero()))
{
break;
}
}
if(0 < line->line_num && line->line_num < text_info.lines_count)
{
String8 data = hs_data_from_hash(hs_scope, hash);
String8 line_text = str8_skip_chop_whitespace(str8_substr(data, text_info.lines_ranges[line->line_num-1]));
if(line_text.size != 0)
{
String8 inst_string = push_str8f(scratch.arena, "> %S", line_text);
DASM_Line inst = {u32_from_u64_saturate(off), DASM_LineFlag_Decorative, 0, r1u64(inst_strings.total_size + inst_strings.node_count,
inst_strings.total_size + inst_strings.node_count + inst_string.size)};
dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &inst);
str8_list_push(scratch.arena, &inst_strings, inst_string);
}
}
}
last_line = line;
}
}
}
}
// rjf: push line
String8 addr_part = {0};
if(params.style_flags & DASM_StyleFlag_Addresses)
{
addr_part = push_str8f(scratch.arena, "%s0x%016I64x ", rdi != &di_rdi_parsed_nil ? " " : "", params.vaddr+off);
}
String8 code_bytes_part = {0};
if(params.style_flags & DASM_StyleFlag_CodeBytes)
{
String8List code_bytes_strings = {0};
str8_list_push(scratch.arena, &code_bytes_strings, str8_lit("{"));
for(U64 byte_idx = 0; byte_idx < inst.size || byte_idx < 16; byte_idx += 1)
{
if(byte_idx < inst.size)
{
str8_list_pushf(scratch.arena, &code_bytes_strings, "%02x%s ", (U32)data.str[off+byte_idx], byte_idx == inst.size-1 ? "}" : "");
}
else if(byte_idx < 8)
{
str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" "));
}
}
str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" "));
code_bytes_part = str8_list_join(scratch.arena, &code_bytes_strings, 0);
}
String8 symbol_part = {0};
if(inst.jump_dest_vaddr != 0 && rdi != &di_rdi_parsed_nil && params.style_flags & DASM_StyleFlag_SymbolNames)
{
RDI_U32 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, inst.jump_dest_vaddr-params.base_vaddr);
if(scope_idx != 0)
{
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
RDI_U32 procedure_idx = scope->proc_idx;
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, procedure_idx);
String8 procedure_name = {0};
procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size);
if(procedure_name.size != 0)
{
symbol_part = push_str8f(scratch.arena, " (%S)", procedure_name);
}
}
}
String8 inst_string = push_str8f(scratch.arena, "%S%S%S%S", addr_part, code_bytes_part, inst.string, symbol_part);
DASM_Line line = {u32_from_u64_saturate(off), 0, inst.jump_dest_vaddr, r1u64(inst_strings.total_size + inst_strings.node_count,
inst_strings.total_size + inst_strings.node_count + inst_string.size)};
dasm_line_chunk_list_push(scratch.arena, &line_list, 1024, &line);
str8_list_push(scratch.arena, &inst_strings, inst_string);
// rjf: increment
off += inst.size;
}
}break;
}
}
//- rjf: artifacts -> value bundle
Arena *info_arena = 0;
DASM_Info info = {0};
if(got_task)
{
//- rjf: produce joined text
Arena *text_arena = arena_alloc();
StringJoin text_join = {0};
text_join.sep = str8_lit("\n");
String8 text = str8_list_join(text_arena, &inst_strings, &text_join);
//- rjf: produce unique key for this disassembly's text
U128 text_key = {0};
{
U64 hash_data[] =
{
hash.u64[0],
hash.u64[1],
params.vaddr,
(U64)params.arch,
(U64)params.style_flags,
(U64)params.syntax,
(U64)rdi,
0x4d534144,
};
text_key = hs_hash_from_data(str8((U8 *)hash_data, sizeof(hash_data)));
}
//- rjf: submit text data to hash store
U128 text_hash = hs_submit_data(text_key, &text_arena, text);
//- rjf: produce value bundle
info_arena = arena_alloc();
info.text_key = text_key;
info.lines = dasm_line_array_from_chunk_list(info_arena, &line_list);
}
//- rjf: commit results to cache
if(got_task) OS_MutexScopeW(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(u128_match(n->hash, hash) && dasm_params_match(&n->params, &params))
{
n->info_arena = info_arena;
MemoryCopyStruct(&n->info, &info);
if(rdi != &di_rdi_parsed_nil && params.style_flags & (DASM_StyleFlag_SourceLines|DASM_StyleFlag_SourceFilesNames))
{
n->change_gen = change_gen;
}
else
{
n->change_gen = 0;
}
ins_atomic_u32_eval_assign(&n->is_working, 0);
ins_atomic_u64_inc_eval(&n->load_count);
break;
}
}
}
txt_scope_close(txt_scope);
di_scope_close(di_scope);
hs_scope_close(hs_scope);
scratch_end(scratch);
ProfEnd();
return 0;
}
////////////////////////////////
//~ rjf: Evictor/Detector Thread
internal void
dasm_evictor_detector_thread__entry_point(void *p)
{
ThreadNameF("[dasm] evictor/detector thread");
for(;;)
{
U64 change_gen = fs_change_gen();
U64 check_time_us = os_now_microseconds();
U64 check_time_user_clocks = update_tick_idx();
U64 evict_threshold_us = 10*1000000;
U64 retry_threshold_us = 1*1000000;
U64 evict_threshold_user_clocks = 10;
U64 retry_threshold_user_clocks = 10;
for(U64 slot_idx = 0; slot_idx < dasm_shared->slots_count; slot_idx += 1)
{
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
DASM_Slot *slot = &dasm_shared->slots[slot_idx];
DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx];
B32 slot_has_work = 0;
OS_MutexScopeR(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first; n != 0; n = n->next)
{
if(n->scope_ref_count == 0 &&
n->last_time_touched_us+evict_threshold_us <= check_time_us &&
n->last_user_clock_idx_touched+evict_threshold_user_clocks <= check_time_user_clocks &&
n->load_count != 0 &&
n->is_working == 0)
{
slot_has_work = 1;
break;
}
if(n->change_gen != 0 && n->change_gen != change_gen &&
n->last_time_requested_us+retry_threshold_us <= check_time_us &&
n->last_user_clock_idx_requested+retry_threshold_user_clocks <= check_time_user_clocks)
{
slot_has_work = 1;
break;
}
}
}
if(slot_has_work) OS_MutexScopeW(stripe->rw_mutex)
{
for(DASM_Node *n = slot->first, *next = 0; n != 0; n = next)
{
next = n->next;
if(n->scope_ref_count == 0 &&
n->last_time_touched_us+evict_threshold_us <= check_time_us &&
n->last_user_clock_idx_touched+evict_threshold_user_clocks <= check_time_user_clocks &&
n->load_count != 0 &&
n->is_working == 0)
{
DLLRemove(slot->first, slot->last, n);
if(n->info_arena != 0)
{
arena_release(n->info_arena);
}
SLLStackPush(stripe->free_node, n);
}
if(n->change_gen != 0 && n->change_gen != change_gen &&
n->last_time_requested_us+retry_threshold_us <= check_time_us &&
n->last_user_clock_idx_requested+retry_threshold_user_clocks <= check_time_user_clocks)
{
if(dasm_u2p_enqueue_req(n->hash, &n->params, max_U64))
{
async_push_work(dasm_parse_work);
n->last_time_requested_us = os_now_microseconds();
n->last_user_clock_idx_requested = check_time_user_clocks;
}
}
}
}
}
os_sleep_milliseconds(100);
}
}
+326
View File
@@ -0,0 +1,326 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DASM_CACHE_H
#define DASM_CACHE_H
////////////////////////////////
//~ rjf: Disassembly Syntax Types
typedef enum DASM_Syntax
{
DASM_Syntax_Intel,
DASM_Syntax_ATT,
DASM_Syntax_COUNT
}
DASM_Syntax;
////////////////////////////////
//~ rjf: Disassembly Instruction Info Types
typedef U32 DASM_InstFlags;
enum
{
DASM_InstFlag_Call = (1<<0),
DASM_InstFlag_Branch = (1<<1),
DASM_InstFlag_UnconditionalJump = (1<<2),
DASM_InstFlag_Return = (1<<3),
DASM_InstFlag_NonFlow = (1<<4),
DASM_InstFlag_Repeats = (1<<5),
DASM_InstFlag_ChangesStackPointer = (1<<6),
DASM_InstFlag_ChangesStackPointerVariably = (1<<7),
};
typedef struct DASM_Inst DASM_Inst;
struct DASM_Inst
{
DASM_InstFlags flags;
U32 size;
String8 string;
U64 jump_dest_vaddr;
};
////////////////////////////////
//~ rjf: Control Flow Analysis Types
typedef struct DASM_CtrlFlowPoint DASM_CtrlFlowPoint;
struct DASM_CtrlFlowPoint
{
U64 vaddr;
U64 jump_dest_vaddr;
DASM_InstFlags inst_flags;
};
typedef struct DASM_CtrlFlowPointNode DASM_CtrlFlowPointNode;
struct DASM_CtrlFlowPointNode
{
DASM_CtrlFlowPointNode *next;
DASM_CtrlFlowPoint v;
};
typedef struct DASM_CtrlFlowPointList DASM_CtrlFlowPointList;
struct DASM_CtrlFlowPointList
{
DASM_CtrlFlowPointNode *first;
DASM_CtrlFlowPointNode *last;
U64 count;
};
typedef struct DASM_CtrlFlowInfo DASM_CtrlFlowInfo;
struct DASM_CtrlFlowInfo
{
DASM_CtrlFlowPointList exit_points;
U64 total_size;
};
////////////////////////////////
//~ rjf: Disassembly Text Decoration Types
typedef U32 DASM_StyleFlags;
enum
{
DASM_StyleFlag_Addresses = (1<<0),
DASM_StyleFlag_CodeBytes = (1<<1),
DASM_StyleFlag_SourceFilesNames = (1<<2),
DASM_StyleFlag_SourceLines = (1<<3),
DASM_StyleFlag_SymbolNames = (1<<4),
};
////////////////////////////////
//~ rjf: Disassembling Parameters Bundle
typedef struct DASM_Params DASM_Params;
struct DASM_Params
{
U64 vaddr;
Arch arch;
DASM_StyleFlags style_flags;
DASM_Syntax syntax;
U64 base_vaddr;
DI_Key dbgi_key;
};
////////////////////////////////
//~ rjf: Disassembly Text Line Types
typedef U32 DASM_LineFlags;
enum
{
DASM_LineFlag_Decorative = (1<<0),
};
typedef struct DASM_Line DASM_Line;
struct DASM_Line
{
U32 code_off;
DASM_LineFlags flags;
U64 addr;
Rng1U64 text_range;
};
typedef struct DASM_LineChunkNode DASM_LineChunkNode;
struct DASM_LineChunkNode
{
DASM_LineChunkNode *next;
DASM_Line *v;
U64 cap;
U64 count;
};
typedef struct DASM_LineChunkList DASM_LineChunkList;
struct DASM_LineChunkList
{
DASM_LineChunkNode *first;
DASM_LineChunkNode *last;
U64 node_count;
U64 line_count;
};
typedef struct DASM_LineArray DASM_LineArray;
struct DASM_LineArray
{
DASM_Line *v;
U64 count;
};
////////////////////////////////
//~ rjf: Disassembly Result Bundle
typedef struct DASM_Result DASM_Result;
struct DASM_Result
{
String8 text;
DASM_LineArray lines;
};
////////////////////////////////
//~ rjf: Value Bundle Type
typedef struct DASM_Info DASM_Info;
struct DASM_Info
{
U128 text_key;
DASM_LineArray lines;
};
////////////////////////////////
//~ rjf: Cache Types
typedef struct DASM_Node DASM_Node;
struct DASM_Node
{
// rjf: links
DASM_Node *next;
DASM_Node *prev;
// rjf: key
U128 hash;
DASM_Params params;
// rjf: generations
U64 change_gen;
// rjf: value
Arena *info_arena;
DASM_Info info;
// rjf: metadata
B32 is_working;
U64 scope_ref_count;
U64 last_time_touched_us;
U64 last_user_clock_idx_touched;
U64 load_count;
U64 last_time_requested_us;
U64 last_user_clock_idx_requested;
};
typedef struct DASM_Slot DASM_Slot;
struct DASM_Slot
{
DASM_Node *first;
DASM_Node *last;
};
typedef struct DASM_Stripe DASM_Stripe;
struct DASM_Stripe
{
Arena *arena;
OS_Handle rw_mutex;
OS_Handle cv;
DASM_Node *free_node;
};
////////////////////////////////
//~ rjf: Scoped Access Types
typedef struct DASM_Touch DASM_Touch;
struct DASM_Touch
{
DASM_Touch *next;
U128 hash;
DASM_Params params;
};
typedef struct DASM_Scope DASM_Scope;
struct DASM_Scope
{
DASM_Scope *next;
DASM_Touch *top_touch;
U64 base_pos;
};
////////////////////////////////
//~ rjf: Thread Context
typedef struct DASM_TCTX DASM_TCTX;
struct DASM_TCTX
{
Arena *arena;
};
////////////////////////////////
//~ rjf: Shared State
typedef struct DASM_Shared DASM_Shared;
struct DASM_Shared
{
Arena *arena;
// rjf: cache
U64 slots_count;
U64 stripes_count;
DASM_Slot *slots;
DASM_Stripe *stripes;
// rjf: user -> parse thread
U64 u2p_ring_size;
U8 *u2p_ring_base;
U64 u2p_ring_write_pos;
U64 u2p_ring_read_pos;
OS_Handle u2p_ring_cv;
OS_Handle u2p_ring_mutex;
// rjf: evictor/detector thread
OS_Handle evictor_detector_thread;
};
////////////////////////////////
//~ rjf: Globals
thread_static DASM_TCTX *dasm_tctx = 0;
global DASM_Shared *dasm_shared = 0;
////////////////////////////////
//~ rjf: Instruction Decoding/Disassembling Type Functions
internal DASM_Inst dasm_inst_from_code(Arena *arena, Arch arch, U64 vaddr, String8 code, DASM_Syntax syntax);
////////////////////////////////
//~ rjf: Control Flow Analysis
internal DASM_CtrlFlowInfo dasm_ctrl_flow_info_from_arch_vaddr_code(Arena *arena, DASM_InstFlags exit_points_mask, Arch arch, U64 vaddr, String8 code);
////////////////////////////////
//~ rjf: Parameter Type Functions
internal B32 dasm_params_match(DASM_Params *a, DASM_Params *b);
////////////////////////////////
//~ rjf: Line Type Functions
internal void dasm_line_chunk_list_push(Arena *arena, DASM_LineChunkList *list, U64 cap, DASM_Line *line);
internal DASM_LineArray dasm_line_array_from_chunk_list(Arena *arena, DASM_LineChunkList *list);
internal U64 dasm_line_array_idx_from_code_off__linear_scan(DASM_LineArray *array, U64 off);
internal U64 dasm_line_array_code_off_from_idx(DASM_LineArray *array, U64 idx);
////////////////////////////////
//~ rjf: Main Layer Initialization
internal void dasm_init(void);
////////////////////////////////
//~ rjf: Scoped Access
internal DASM_Scope *dasm_scope_open(void);
internal void dasm_scope_close(DASM_Scope *scope);
internal void dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node);
////////////////////////////////
//~ rjf: Cache Lookups
internal DASM_Info dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params);
internal DASM_Info dasm_info_from_key_params(DASM_Scope *scope, U128 key, DASM_Params *params, U128 *hash_out);
////////////////////////////////
//~ rjf: Parse Threads
internal B32 dasm_u2p_enqueue_req(U128 hash, DASM_Params *params, U64 endt_us);
internal void dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out);
ASYNC_WORK_DEF(dasm_parse_work);
////////////////////////////////
//~ rjf: Evictor/Detector Thread
internal void dasm_evictor_detector_thread__entry_point(void *p);
#endif // DASM_CACHE_H
+132
View File
@@ -0,0 +1,132 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Built-In Command Tables
@table(name ui_vis ipc_docs_vis q_slot q_view q_ent_kind q_ctrl_ent_kind q_allow_files q_allow_folders q_keep_oi q_select_oi q_is_code q_required canonical_icon string display_name desc search_tags )
// / | | | \___ _________________________________/ | | | | |
// / | | | \ / | | | | |
D_CmdTable: // | | | | | | | | | |
{
//- rjf: low-level target control operations
{LaunchAndRun 1 1 Entity null Target Null 0 0 0 0 0 1 Play "launch_and_run" "Launch and Run" "Starts debugging a new instance of a target, then runs." "launch,start,run,target" }
{LaunchAndInit 1 1 Entity null Target Null 0 0 0 0 0 1 PlayStepForward "launch_and_init" "Launch and Initialize" "Starts debugging a new instance of a target, then stops at the program's entry point." "launch,start,entry,point" }
{Kill 1 1 Process null Nil Process 0 0 0 0 0 1 X "kill" "Kill" "Kills the specified existing attached process(es)." "stop,kill" }
{KillAll 1 1 Null null Nil Null 0 0 0 0 0 0 Stop "kill_all" "Kill All" "Kills all attached processes." "stop,kill,all" }
{Detach 1 1 Process null Nil Process 0 0 0 0 0 1 Null "detach" "Detach" "Detaches the specified attached process(es)." "detach" }
{Continue 1 1 Null null Nil Null 0 0 0 0 0 0 Play "continue" "Continue" "Continues executing all attached processes." "" }
{StepIntoInst 1 1 Null null Nil Null 0 0 0 0 0 0 StepInto "step_into_inst" "Step Into (Assembly)" "Performs a step that goes into calls, at the instruction level." "single,step,thread" }
{StepOverInst 1 1 Null null Nil Null 0 0 0 0 0 0 StepOver "step_over_inst" "Step Over (Assembly)" "Performs a step that skips calls, at the instruction level." "single,step,thread" }
{StepIntoLine 1 1 Null null Nil Null 0 0 0 0 0 0 StepInto "step_into_line" "Step Into (Line)" "Performs a step that goes into calls, at the source code line level." "step,thread" }
{StepOverLine 1 1 Null null Nil Null 0 0 0 0 0 0 StepOver "step_over_line" "Step Over (Line)" "Performs a step that skips calls, at the source code line level." "step,thread" }
{StepOut 1 1 Null null Nil Null 0 0 0 0 0 0 StepOut "step_out" "Step Out" "Runs to the end of the current function and exits it." "" }
{Halt 1 1 Null null Nil Null 0 0 0 0 0 0 Pause "halt" "Halt" "Halts all attached processes." "pause" }
{SoftHaltRefresh 1 1 Null null Nil Null 0 0 0 0 0 0 Refresh "soft_halt_refresh" "Soft Halt Refresh" "Interrupts all attached processes to collect data, and then resumes them." "" }
{SetThreadIP 0 1 Vaddr null Nil Null 0 0 0 0 1 1 Null "set_thread_ip" "Set Thread IP" "Sets the specified thread's instruction pointer at the specified address." "" }
//- rjf: high-level composite target control operations
{RunToLine 0 1 Null null Nil Null 0 0 0 0 0 0 Play "run_to_line" "Run To Line" "Runs until a particular source line is hit." "" }
{RunToAddress 1 1 Vaddr null Nil Null 0 0 0 0 1 1 PlayStepForward "run_to_address" "Run To Address" "Runs until a particular address is hit." "" }
{Run 1 1 Null null Nil Null 0 0 0 0 0 0 Play "run" "Run" "Runs all targets after starting them if they have not been started yet." "play" }
{Restart 1 1 Null null Nil Null 0 0 0 0 0 0 Redo "restart" "Restart" "Kills all attached processes, then launches all active targets." "restart,retry" }
{StepInto 1 1 Null null Nil Null 0 0 0 0 0 0 StepInto "step_into" "Step Into" "Steps once, possibly into function calls, for either source lines or instructions (whichever is selected)." "" }
{StepOver 1 1 Null null Nil Null 0 0 0 0 0 0 StepOver "step_over" "Step Over" "Steps once, always over function calls, for either source lines or instructions." "" }
//- rjf: debug control context management operations
{FreezeThread 1 1 Thread null Nil Thread 0 0 0 0 0 1 Locked "freeze_thread" "Freeze Thread" "Freezes the passed thread." "callstack,unwind" }
{ThawThread 1 1 Thread null Nil Thread 0 0 0 0 0 1 Unlocked "thaw_thread" "Thaw Thread" "Thaws the passed thread." "" }
{FreezeProcess 1 1 Process null Nil Process 0 0 0 0 0 1 Locked "freeze_process" "Freeze Process" "Freezes the passed process." "" }
{ThawProcess 1 1 Process null Nil Process 0 0 0 0 0 1 Unlocked "thaw_process" "Thaw Process" "Thaws the passed process." "" }
{FreezeMachine 0 1 Machine null Nil Machine 0 0 0 0 0 1 Locked "freeze_machine" "Freeze Machine" "Freezes the passed machine." "" }
{ThawMachine 0 1 Machine null Nil Machine 0 0 0 0 0 1 Unlocked "thaw_machine" "Thaw Machine" "Thaws the passed machine." "" }
{FreezeLocalMachine 1 1 Null null Nil Null 0 0 0 0 0 0 Machine "freeze_local_machine" "Freeze Local Machine" "Freezes the local machine." "" }
{ThawLocalMachine 1 1 Null null Nil Null 0 0 0 0 0 0 Machine "thaw_local_machine" "Thaw Local Machine" "Thaws the local machine." "" }
{FreezeEntity 0 0 Null null Nil Null 0 0 0 0 0 0 Null "freeze_entity" "Freeze Entity" "Freezes an entity." "" }
{ThawEntity 0 0 Null null Nil Null 0 0 0 0 0 0 Null "thaw_entity" "Thaw Entity" "Thaws an entity." "" }
//- rjf: entity decoration
{SetEntityColor 0 0 Null null Nil Null 0 0 0 0 0 0 Null "set_entity_color" "Set Entity Color" "Sets the passed entity's color." "" }
{SetEntityName 0 0 Null null Nil Null 0 0 0 0 0 0 Null "set_entity_name" "Set Entity Name" "Sets the passed entity's name." "" }
//- rjf: attaching
{Attach 1 1 PID null Nil Null 0 0 0 0 0 1 Null "attach" "Attach" "Attaches to a process that is already running on the local machine." "" }
}
@enum D_CmdKind:
{
Null,
@expand(D_CmdTable, a) `$(a.name)`,
COUNT,
}
////////////////////////////////
//~ rjf: Built-In VieNull w Rules
@table(coverage_check name name_lower string ih ex xp vb display_name docs schema description)
D_ViewRuleTable:
{
{x Default default "default" - - - x "Default" - "" "" }
{x Array array "array" - - x - "Array" x "x:{expr}" "Specifies that a pointer points to N elements, rather than only 1." }
{x Slice slice "slice" - - x - "Slice" x "" "Specifies that a pointer within a struct, also containing an integer, points to the number of elements encoded by the integer." }
{- List list "list" - - - x "List" - "x:{member}" "Specifies that some struct, union, or class forms the top of a linked list, and the member which points at the following element in the list." }
{x ByteSwap bswap "bswap" x - x - "Byte Swap" x "" "Specifies that all integral evaluations should be byte-swapped, such that their endianness is reversed." }
{x Cast cast "cast" - - x - "Cast" x "x:{type}" "Specifies that the expression to which the view rule is applied should be casted to the provided type." }
{- BaseDec base_dec "dec" x - - - "Decimal Base (Base 10)" x "" "Specifies that all integral evaluations should appear in base-10 form." }
{- BaseBin base_bin "bin" x - - - "Binary Base (Base 2)" x "" "Specifies that all integral evaluations should appear in base-2 form." }
{- BaseOct base_oct "oct" x - - - "Octal Base (Base 8)" x "" "Specifies that all integral evaluations should appear in base-8 form." }
{- BaseHex base_hex "hex" x - - - "Hexadecimal Base (Base 16)" x "" "Specifies that all integral evaluations should appear in base-16 form." }
{- Only only "only" x - - x "Only Specified Members" x "x:{member}" "Specifies that only the specified members should appear in struct, union, or class evaluations." }
{- Omit omit "omit" x - - x "Omit Specified Members" x "x:{member}" "Omits a list of member names from appearing in struct, union, or class evaluations." }
{- NoAddr no_addr "no_addr" x - - - "Disable Address Values" x "" "Displays only what pointers point to, if possible, without the pointer's address value." }
{x Checkbox checkbox "checkbox" - - - - "Checkbox" x "" "Displays simple integer values as checkboxes, encoding zero or nonzero values." }
{- ColorRGBA color_rgba "color_rgba" - x - x "Color (RGBA)" x "" "Displays as a color, interpreting the data as encoding R, G, B, and A values." }
{x Text text "text" - x - x "Text" x "x:{'lang':lang, 'size':expr}" "Displays as text." }
{x Disasm disasm "disasm" - x - x "Disassembly" x "x:{'arch':arch, 'size':expr}" "Displays as disassembled instructions, interpreting the data as raw machine code." }
{x Memory memory "memory" - x - x "Memory" x "x:{'size':expr}" "Displays as a raw memory grid." }
{- Graph graph "graph" - x - x "Graph" x "" "Displays as a pointer graph, visualizing nodes and edges formed by pointers directly." }
{x Bitmap bitmap "bitmap" - x - x "Bitmap" x "x:{'w':expr, 'h':expr, 'fmt':tex2dformat}" "Displays as a bitmap, interpreting the data as raw pixel data." }
{- Geo3D geo3d "geo3d" - x - x "Geometry (3D)" x "x:{'count':expr, 'vtx':expr, 'vtx_size':expr}" "Displays as geometry, interpreting the data as index or vertex data." }
}
@enum D_ViewRuleKind:
{
@expand(D_ViewRuleTable a) `$(a.name)`,
COUNT,
}
@data(D_ViewRuleSpecInfo) @c_file d_core_view_rule_spec_info_table:
{
@expand(D_ViewRuleTable a)
```{str8_lit_comp("$(a.string)"), str8_lit_comp("$(a.display_name)"), str8_lit_comp("$(a.schema)"), str8_lit_comp("$(a.description)"), (D_ViewRuleSpecInfoFlag_Inherited*$(a.ih == "x"))|(D_ViewRuleSpecInfoFlag_Expandable*$(a.ex == "x"))|(D_ViewRuleSpecInfoFlag_ExprResolution*$(a.xp == "x"))|(D_ViewRuleSpecInfoFlag_VizBlockProd*$(a.vb == "x")), }```;
}
////////////////////////////////
//~ rjf: Developer Toggles
@table(name)
D_DevToggleTable:
{
{simulate_lag}
{draw_ui_text_pos}
{draw_ui_focus_debug}
{draw_ui_box_heatmap}
{eval_compiler_tooltips}
{eval_watch_key_tooltips}
{cmd_context_tooltips}
{scratch_mouse_draw}
{updating_indicator}
}
@gen
{
@expand(D_DevToggleTable a) `global B32 DEV_$(a.name) = 0;`
}
@gen
{
`struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =`;
`{`;
@expand(D_DevToggleTable a) `{&DEV_$(a.name), str8_lit_comp("$(a.name)")},`
`};`;
}
File diff suppressed because it is too large. Load diff
+499
View File
@@ -0,0 +1,499 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBG_ENGINE_CORE_H
#define DBG_ENGINE_CORE_H
////////////////////////////////
//~ rjf: Tick Input Types
typedef struct D_Target D_Target;
struct D_Target
{
String8 exe;
String8 args;
String8 working_directory;
String8 custom_entry_point_name;
String8 stdout_path;
String8 stderr_path;
String8 stdin_path;
B32 debug_subprocesses;
String8List env;
};
typedef struct D_TargetArray D_TargetArray;
struct D_TargetArray
{
D_Target *v;
U64 count;
};
typedef struct D_Breakpoint D_Breakpoint;
struct D_Breakpoint
{
String8 file_path;
TxtPt pt;
String8 symbol_name;
U64 vaddr;
String8 condition;
};
typedef struct D_BreakpointArray D_BreakpointArray;
struct D_BreakpointArray
{
D_Breakpoint *v;
U64 count;
};
typedef struct D_PathMap D_PathMap;
struct D_PathMap
{
String8 src;
String8 dst;
};
typedef struct D_PathMapArray D_PathMapArray;
struct D_PathMapArray
{
D_PathMap *v;
U64 count;
};
////////////////////////////////
//~ rjf: Tick Output Types
typedef enum D_EventKind
{
D_EventKind_Null,
D_EventKind_ProcessEnd,
D_EventKind_Stop,
D_EventKind_COUNT
}
D_EventKind;
typedef enum D_EventCause
{
D_EventCause_Null,
D_EventCause_UserBreakpoint,
D_EventCause_Halt,
D_EventCause_COUNT
}
D_EventCause;
typedef struct D_Event D_Event;
struct D_Event
{
D_EventKind kind;
D_EventCause cause;
CTRL_Handle thread;
U64 vaddr;
U64 code;
};
typedef struct D_EventNode D_EventNode;
struct D_EventNode
{
D_EventNode *next;
D_Event v;
};
typedef struct D_EventList D_EventList;
struct D_EventList
{
D_EventNode *first;
D_EventNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Line Info Types
typedef struct D_Line D_Line;
struct D_Line
{
String8 file_path;
TxtPt pt;
Rng1U64 voff_range;
DI_Key dbgi_key;
};
typedef struct D_LineNode D_LineNode;
struct D_LineNode
{
D_LineNode *next;
D_Line v;
};
typedef struct D_LineList D_LineList;
struct D_LineList
{
D_LineNode *first;
D_LineNode *last;
U64 count;
};
typedef struct D_LineListArray D_LineListArray;
struct D_LineListArray
{
D_LineList *v;
U64 count;
DI_KeyList dbgi_keys;
};
////////////////////////////////
//~ rjf: Debug Engine Control Communication Types
typedef enum D_RunKind
{
D_RunKind_Run,
D_RunKind_SingleStep,
D_RunKind_Step,
D_RunKind_COUNT
}
D_RunKind;
////////////////////////////////
//~ rjf: Generated Code
#include "dbg_engine/generated/dbg_engine.meta.h"
////////////////////////////////
//~ rjf: View Rules
typedef U32 D_ViewRuleSpecInfoFlags; // NOTE(rjf): see @view_rule_info
enum
{
D_ViewRuleSpecInfoFlag_Inherited = (1<<0),
D_ViewRuleSpecInfoFlag_Expandable = (1<<1),
D_ViewRuleSpecInfoFlag_ExprResolution = (1<<2),
D_ViewRuleSpecInfoFlag_VizBlockProd = (1<<3),
};
typedef struct D_ViewRuleSpecInfo D_ViewRuleSpecInfo;
struct D_ViewRuleSpecInfo
{
String8 string;
String8 display_string;
String8 schema;
String8 description;
D_ViewRuleSpecInfoFlags flags;
};
typedef struct D_ViewRuleSpecInfoArray D_ViewRuleSpecInfoArray;
struct D_ViewRuleSpecInfoArray
{
D_ViewRuleSpecInfo *v;
U64 count;
};
typedef struct D_ViewRuleSpec D_ViewRuleSpec;
struct D_ViewRuleSpec
{
D_ViewRuleSpec *hash_next;
D_ViewRuleSpecInfo info;
};
////////////////////////////////
//~ rjf: Command Types
typedef struct D_CmdParams D_CmdParams;
struct D_CmdParams
{
CTRL_Handle machine;
CTRL_Handle process;
CTRL_Handle thread;
CTRL_Handle entity;
String8 string;
String8 file_path;
TxtPt cursor;
U64 vaddr;
B32 prefer_disasm;
U32 pid;
U32 rgba;
D_TargetArray targets;
};
typedef struct D_Cmd D_Cmd;
struct D_Cmd
{
D_CmdKind kind;
D_CmdParams params;
};
typedef struct D_CmdNode D_CmdNode;
struct D_CmdNode
{
D_CmdNode *next;
D_CmdNode *prev;
D_Cmd cmd;
};
typedef struct D_CmdList D_CmdList;
struct D_CmdList
{
D_CmdNode *first;
D_CmdNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Main State Caches
//- rjf: per-thread unwind cache
typedef struct D_UnwindCacheNode D_UnwindCacheNode;
struct D_UnwindCacheNode
{
D_UnwindCacheNode *next;
D_UnwindCacheNode *prev;
U64 reggen;
U64 memgen;
Arena *arena;
CTRL_Handle thread;
CTRL_Unwind unwind;
};
typedef struct D_UnwindCacheSlot D_UnwindCacheSlot;
struct D_UnwindCacheSlot
{
D_UnwindCacheNode *first;
D_UnwindCacheNode *last;
};
typedef struct D_UnwindCache D_UnwindCache;
struct D_UnwindCache
{
U64 slots_count;
D_UnwindCacheSlot *slots;
D_UnwindCacheNode *free_node;
};
//- rjf: per-run tls-base-vaddr cache
typedef struct D_RunTLSBaseCacheNode D_RunTLSBaseCacheNode;
struct D_RunTLSBaseCacheNode
{
D_RunTLSBaseCacheNode *hash_next;
CTRL_Handle process;
U64 root_vaddr;
U64 rip_vaddr;
U64 tls_base_vaddr;
};
typedef struct D_RunTLSBaseCacheSlot D_RunTLSBaseCacheSlot;
struct D_RunTLSBaseCacheSlot
{
D_RunTLSBaseCacheNode *first;
D_RunTLSBaseCacheNode *last;
};
typedef struct D_RunTLSBaseCache D_RunTLSBaseCache;
struct D_RunTLSBaseCache
{
Arena *arena;
U64 slots_count;
D_RunTLSBaseCacheSlot *slots;
};
//- rjf: per-run locals cache
typedef struct D_RunLocalsCacheNode D_RunLocalsCacheNode;
struct D_RunLocalsCacheNode
{
D_RunLocalsCacheNode *hash_next;
DI_Key dbgi_key;
U64 voff;
E_String2NumMap *locals_map;
};
typedef struct D_RunLocalsCacheSlot D_RunLocalsCacheSlot;
struct D_RunLocalsCacheSlot
{
D_RunLocalsCacheNode *first;
D_RunLocalsCacheNode *last;
};
typedef struct D_RunLocalsCache D_RunLocalsCache;
struct D_RunLocalsCache
{
Arena *arena;
U64 table_size;
D_RunLocalsCacheSlot *table;
};
////////////////////////////////
//~ rjf: Main State Types
typedef struct D_State D_State;
struct D_State
{
// rjf: top-level state
Arena *arena;
U64 frame_index;
U64 frame_eval_memread_endt_us;
// rjf: commands
Arena *cmds_arena;
D_CmdList cmds;
// rjf: output log key
U128 output_log_key;
// rjf: per-run caches
D_UnwindCache unwind_cache;
U64 tls_base_cache_reggen_idx;
U64 tls_base_cache_memgen_idx;
D_RunTLSBaseCache tls_base_caches[2];
U64 tls_base_cache_gen;
U64 locals_cache_reggen_idx;
D_RunLocalsCache locals_caches[2];
U64 locals_cache_gen;
U64 member_cache_reggen_idx;
D_RunLocalsCache member_caches[2];
U64 member_cache_gen;
// rjf: view rule specification table
U64 view_rule_spec_table_size;
D_ViewRuleSpec **view_rule_spec_table;
// rjf: user -> ctrl driving state
Arena *ctrl_last_run_arena;
D_RunKind ctrl_last_run_kind;
U64 ctrl_last_run_frame_idx;
CTRL_Handle ctrl_last_run_thread_handle;
CTRL_RunFlags ctrl_last_run_flags;
CTRL_TrapList ctrl_last_run_traps;
D_BreakpointArray ctrl_last_run_extra_bps;
U128 ctrl_last_run_param_state_hash;
B32 ctrl_is_running;
B32 ctrl_thread_run_state;
B32 ctrl_soft_halt_issued;
Arena *ctrl_msg_arena;
CTRL_MsgList ctrl_msgs;
// rjf: ctrl -> user reading state
CTRL_EntityStore *ctrl_entity_store;
Arena *ctrl_stop_arena;
CTRL_Event ctrl_last_stop_event;
};
////////////////////////////////
//~ rjf: Globals
read_only global D_ViewRuleSpec d_nil_core_view_rule_spec = {0};
global D_State *d_state = 0;
////////////////////////////////
//~ rjf: Basic Helpers
internal U64 d_hash_from_seed_string(U64 seed, String8 string);
internal U64 d_hash_from_string(String8 string);
internal U64 d_hash_from_seed_string__case_insensitive(U64 seed, String8 string);
internal U64 d_hash_from_string__case_insensitive(String8 string);
////////////////////////////////
//~ rjf: Breakpoints
internal D_BreakpointArray d_breakpoint_array_copy(Arena *arena, D_BreakpointArray *src);
////////////////////////////////
//~ rjf: Path Map Application
internal String8List d_possible_path_overrides_from_maps_path(Arena *arena, D_PathMapArray *path_maps, String8 file_path);
////////////////////////////////
//~ rjf: Debug Info Extraction Type Pure Functions
internal D_LineList d_line_list_copy(Arena *arena, D_LineList *list);
////////////////////////////////
//~ rjf: Command Type Functions
//- rjf: command parameters
internal D_CmdParams d_cmd_params_copy(Arena *arena, D_CmdParams *src);
//- rjf: command lists
internal void d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *params);
////////////////////////////////
//~ rjf: View Rule Spec Stateful Functions
internal void d_register_view_rule_specs(D_ViewRuleSpecInfoArray specs);
internal D_ViewRuleSpec *d_view_rule_spec_from_string(String8 string);
////////////////////////////////
//~ rjf: Stepping "Trap Net" Builders
internal CTRL_TrapList d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread);
internal CTRL_TrapList d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread);
internal CTRL_TrapList d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread);
////////////////////////////////
//~ rjf: Debug Info Lookups
//- rjf: voff|vaddr -> symbol lookups
internal String8 d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 decorated);
internal String8 d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, B32 decorated);
//- rjf: symbol -> voff lookups
internal U64 d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name);
internal U64 d_type_num_from_dbgi_key_name(DI_Key *dbgi_key, String8 name);
//- rjf: voff -> line info
internal D_LineList d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff);
//- rjf: file:line -> line info
// TODO(rjf): this depends on file path maps, needs to move
// TODO(rjf): need to clean this up & dedup
internal D_LineListArray d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key, String8 file_path, Rng1S64 line_num_range);
internal D_LineListArray d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64 line_num_range);
internal D_LineList d_lines_from_dbgi_key_file_path_line_num(Arena *arena, DI_Key dbgi_key, String8 file_path, S64 line_num);
internal D_LineList d_lines_from_file_path_line_num(Arena *arena, String8 file_path, S64 line_num);
////////////////////////////////
//~ rjf: Process/Thread/Module Info Lookups
internal U64 d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr);
////////////////////////////////
//~ rjf: Target Controls
//- rjf: stopped info from the control thread
internal CTRL_Event d_ctrl_last_stop_event(void);
////////////////////////////////
//~ rjf: Main State Accessors/Mutators
//- rjf: frame data
internal U64 d_frame_index(void);
//- rjf: control state
internal D_RunKind d_ctrl_last_run_kind(void);
internal U64 d_ctrl_last_run_frame_idx(void);
internal B32 d_ctrl_targets_running(void);
//- rjf: active entity based queries
internal DI_KeyList d_push_active_dbgi_key_list(Arena *arena);
//- rjf: per-run caches
internal CTRL_Unwind d_query_cached_unwind_from_thread(CTRL_Entity *thread);
internal U64 d_query_cached_rip_from_thread(CTRL_Entity *thread);
internal U64 d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr);
internal E_String2NumMap *d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff);
internal E_String2NumMap *d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff);
//- rjf: top-level command dispatch
internal void d_push_cmd(D_CmdKind kind, D_CmdParams *params);
#define d_cmd(kind, ...) d_push_cmd((kind), &(D_CmdParams){.thread = {0}, __VA_ARGS__})
//- rjf: command iteration
internal B32 d_next_cmd(D_Cmd **cmd);
////////////////////////////////
//~ rjf: Main Layer Top-Level Calls
internal void d_init(void);
internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64], CTRL_MetaEvalArray *meta_evals);
#endif // DBG_ENGINE_CORE_H
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "regs/raddbg/generated/regs_raddbg.meta.c" #include "dbg_engine_core.c"
+9
View File
@@ -0,0 +1,9 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBG_ENGINE_INC_H
#define DBG_ENGINE_INC_H
#include "dbg_engine_core.h"
#endif // DBG_ENGINE_INC_H
@@ -0,0 +1,33 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
C_LINKAGE_BEGIN
D_ViewRuleSpecInfo d_core_view_rule_spec_info_table[21] =
{
{str8_lit_comp("default"), str8_lit_comp("Default"), str8_lit_comp(""), str8_lit_comp(""), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("array"), str8_lit_comp("Array"), str8_lit_comp("x:{expr}"), str8_lit_comp("Specifies that a pointer points to N elements, rather than only 1."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*1)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("slice"), str8_lit_comp("Slice"), str8_lit_comp(""), str8_lit_comp("Specifies that a pointer within a struct, also containing an integer, points to the number of elements encoded by the integer."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*1)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("list"), str8_lit_comp("List"), str8_lit_comp("x:{member}"), str8_lit_comp("Specifies that some struct, union, or class forms the top of a linked list, and the member which points at the following element in the list."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("bswap"), str8_lit_comp("Byte Swap"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should be byte-swapped, such that their endianness is reversed."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*1)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("cast"), str8_lit_comp("Cast"), str8_lit_comp("x:{type}"), str8_lit_comp("Specifies that the expression to which the view rule is applied should be casted to the provided type."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*1)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("dec"), str8_lit_comp("Decimal Base (Base 10)"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should appear in base-10 form."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("bin"), str8_lit_comp("Binary Base (Base 2)"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should appear in base-2 form."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("oct"), str8_lit_comp("Octal Base (Base 8)"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should appear in base-8 form."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("hex"), str8_lit_comp("Hexadecimal Base (Base 16)"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should appear in base-16 form."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("only"), str8_lit_comp("Only Specified Members"), str8_lit_comp("x:{member}"), str8_lit_comp("Specifies that only the specified members should appear in struct, union, or class evaluations."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("omit"), str8_lit_comp("Omit Specified Members"), str8_lit_comp("x:{member}"), str8_lit_comp("Omits a list of member names from appearing in struct, union, or class evaluations."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("no_addr"), str8_lit_comp("Disable Address Values"), str8_lit_comp(""), str8_lit_comp("Displays only what pointers point to, if possible, without the pointer's address value."), (D_ViewRuleSpecInfoFlag_Inherited*1)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("checkbox"), str8_lit_comp("Checkbox"), str8_lit_comp(""), str8_lit_comp("Displays simple integer values as checkboxes, encoding zero or nonzero values."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*0), },
{str8_lit_comp("color_rgba"), str8_lit_comp("Color (RGBA)"), str8_lit_comp(""), str8_lit_comp("Displays as a color, interpreting the data as encoding R, G, B, and A values."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("text"), str8_lit_comp("Text"), str8_lit_comp("x:{'lang':lang, 'size':expr}"), str8_lit_comp("Displays as text."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("disasm"), str8_lit_comp("Disassembly"), str8_lit_comp("x:{'arch':arch, 'size':expr}"), str8_lit_comp("Displays as disassembled instructions, interpreting the data as raw machine code."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("memory"), str8_lit_comp("Memory"), str8_lit_comp("x:{'size':expr}"), str8_lit_comp("Displays as a raw memory grid."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("graph"), str8_lit_comp("Graph"), str8_lit_comp(""), str8_lit_comp("Displays as a pointer graph, visualizing nodes and edges formed by pointers directly."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("bitmap"), str8_lit_comp("Bitmap"), str8_lit_comp("x:{'w':expr, 'h':expr, 'fmt':tex2dformat}"), str8_lit_comp("Displays as a bitmap, interpreting the data as raw pixel data."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
{str8_lit_comp("geo3d"), str8_lit_comp("Geometry (3D)"), str8_lit_comp("x:{'count':expr, 'vtx':expr, 'vtx_size':expr}"), str8_lit_comp("Displays as geometry, interpreting the data as index or vertex data."), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*1)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
};
C_LINKAGE_END
@@ -0,0 +1,95 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
#ifndef DBG_ENGINE_META_H
#define DBG_ENGINE_META_H
typedef enum D_CmdKind
{
D_CmdKind_Null,
D_CmdKind_LaunchAndRun,
D_CmdKind_LaunchAndInit,
D_CmdKind_Kill,
D_CmdKind_KillAll,
D_CmdKind_Detach,
D_CmdKind_Continue,
D_CmdKind_StepIntoInst,
D_CmdKind_StepOverInst,
D_CmdKind_StepIntoLine,
D_CmdKind_StepOverLine,
D_CmdKind_StepOut,
D_CmdKind_Halt,
D_CmdKind_SoftHaltRefresh,
D_CmdKind_SetThreadIP,
D_CmdKind_RunToLine,
D_CmdKind_RunToAddress,
D_CmdKind_Run,
D_CmdKind_Restart,
D_CmdKind_StepInto,
D_CmdKind_StepOver,
D_CmdKind_FreezeThread,
D_CmdKind_ThawThread,
D_CmdKind_FreezeProcess,
D_CmdKind_ThawProcess,
D_CmdKind_FreezeMachine,
D_CmdKind_ThawMachine,
D_CmdKind_FreezeLocalMachine,
D_CmdKind_ThawLocalMachine,
D_CmdKind_FreezeEntity,
D_CmdKind_ThawEntity,
D_CmdKind_SetEntityColor,
D_CmdKind_SetEntityName,
D_CmdKind_Attach,
D_CmdKind_COUNT,
} D_CmdKind;
typedef enum D_ViewRuleKind
{
D_ViewRuleKind_Default,
D_ViewRuleKind_Array,
D_ViewRuleKind_Slice,
D_ViewRuleKind_List,
D_ViewRuleKind_ByteSwap,
D_ViewRuleKind_Cast,
D_ViewRuleKind_BaseDec,
D_ViewRuleKind_BaseBin,
D_ViewRuleKind_BaseOct,
D_ViewRuleKind_BaseHex,
D_ViewRuleKind_Only,
D_ViewRuleKind_Omit,
D_ViewRuleKind_NoAddr,
D_ViewRuleKind_Checkbox,
D_ViewRuleKind_ColorRGBA,
D_ViewRuleKind_Text,
D_ViewRuleKind_Disasm,
D_ViewRuleKind_Memory,
D_ViewRuleKind_Graph,
D_ViewRuleKind_Bitmap,
D_ViewRuleKind_Geo3D,
D_ViewRuleKind_COUNT,
} D_ViewRuleKind;
global B32 DEV_simulate_lag = 0;
global B32 DEV_draw_ui_text_pos = 0;
global B32 DEV_draw_ui_focus_debug = 0;
global B32 DEV_draw_ui_box_heatmap = 0;
global B32 DEV_eval_compiler_tooltips = 0;
global B32 DEV_eval_watch_key_tooltips = 0;
global B32 DEV_cmd_context_tooltips = 0;
global B32 DEV_scratch_mouse_draw = 0;
global B32 DEV_updating_indicator = 0;
struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =
{
{&DEV_simulate_lag, str8_lit_comp("simulate_lag")},
{&DEV_draw_ui_text_pos, str8_lit_comp("draw_ui_text_pos")},
{&DEV_draw_ui_focus_debug, str8_lit_comp("draw_ui_focus_debug")},
{&DEV_draw_ui_box_heatmap, str8_lit_comp("draw_ui_box_heatmap")},
{&DEV_eval_compiler_tooltips, str8_lit_comp("eval_compiler_tooltips")},
{&DEV_eval_watch_key_tooltips, str8_lit_comp("eval_watch_key_tooltips")},
{&DEV_cmd_context_tooltips, str8_lit_comp("cmd_context_tooltips")},
{&DEV_scratch_mouse_draw, str8_lit_comp("scratch_mouse_draw")},
{&DEV_updating_indicator, str8_lit_comp("updating_indicator")},
};
#endif // DBG_ENGINE_META_H
+1800 -888
View File
File diff suppressed because it is too large. Load diff
+472 -262
View File
@@ -1,262 +1,472 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBGI_H #ifndef DBGI_H
#define DBGI_H #define DBGI_H
//////////////////////////////// ////////////////////////////////
//~ rjf: Info Bundle Types //~ rjf: Cache Key Type
typedef struct DBGI_Parse DBGI_Parse; typedef struct DI_Key DI_Key;
struct DBGI_Parse struct DI_Key
{ {
U64 gen; String8 path;
Arena *arena; U64 min_timestamp;
void *exe_base; };
FileProperties exe_props;
String8 dbg_path; typedef struct DI_KeyNode DI_KeyNode;
void *dbg_base; struct DI_KeyNode
FileProperties dbg_props; {
PE_BinInfo pe; DI_KeyNode *next;
RADDBG_Parsed rdbg; DI_Key v;
}; };
//////////////////////////////// typedef struct DI_KeyList DI_KeyList;
//~ rjf: Exe -> Debug Forced Override Cache Types struct DI_KeyList
{
typedef struct DBGI_ForceNode DBGI_ForceNode; DI_KeyNode *first;
struct DBGI_ForceNode DI_KeyNode *last;
{ U64 count;
DBGI_ForceNode *next; };
String8 exe_path;
U64 dbg_path_cap; typedef struct DI_KeyArray DI_KeyArray;
U64 dbg_path_size; struct DI_KeyArray
U8 *dbg_path_base; {
}; DI_Key *v;
U64 count;
typedef struct DBGI_ForceSlot DBGI_ForceSlot; };
struct DBGI_ForceSlot
{ ////////////////////////////////
DBGI_ForceNode *first; //~ rjf: Event Types
DBGI_ForceNode *last;
}; typedef enum DI_EventKind
{
typedef struct DBGI_ForceStripe DBGI_ForceStripe; DI_EventKind_Null,
struct DBGI_ForceStripe DI_EventKind_ConversionStarted,
{ DI_EventKind_ConversionEnded,
Arena *arena; DI_EventKind_ConversionFailureUnsupportedFormat,
OS_Handle rw_mutex; DI_EventKind_COUNT
OS_Handle cv; }
}; DI_EventKind;
//////////////////////////////// typedef struct DI_Event DI_Event;
//~ rjf: Binary Cache State Types struct DI_Event
{
typedef U32 DBGI_BinaryFlags; DI_EventKind kind;
enum String8 string;
{ };
DBGI_BinaryFlag_ParseInFlight = (1<<0),
}; typedef struct DI_EventNode DI_EventNode;
struct DI_EventNode
typedef struct DBGI_Binary DBGI_Binary; {
struct DBGI_Binary DI_EventNode *next;
{ DI_Event v;
// rjf: links & metadata };
DBGI_Binary *next;
String8 exe_path; typedef struct DI_EventList DI_EventList;
U64 refcount; struct DI_EventList
U64 scope_touch_count; {
U64 last_time_enqueued_for_parse_us; DI_EventNode *first;
DBGI_BinaryFlags flags; DI_EventNode *last;
U64 gen; U64 count;
};
// rjf: exe handles
OS_Handle exe_file; ////////////////////////////////
OS_Handle exe_file_map; //~ rjf: Debug Info Cache Types
// rjf: debug handles typedef struct DI_StringChunkNode DI_StringChunkNode;
OS_Handle dbg_file; struct DI_StringChunkNode
OS_Handle dbg_file_map; {
DI_StringChunkNode *next;
// rjf: analysis results U64 size;
DBGI_Parse parse; };
};
typedef struct DI_Node DI_Node;
typedef struct DBGI_BinarySlot DBGI_BinarySlot; struct DI_Node
struct DBGI_BinarySlot {
{ // rjf: links
DBGI_Binary *first; DI_Node *next;
DBGI_Binary *last; DI_Node *prev;
};
// rjf: metadata
typedef struct DBGI_BinaryStripe DBGI_BinaryStripe; U64 ref_count;
struct DBGI_BinaryStripe U64 touch_count;
{ U64 is_working;
Arena *arena;
OS_Handle rw_mutex; // rjf: key
OS_Handle cv; DI_Key key;
};
// rjf: file handles
//////////////////////////////// OS_Handle file;
//~ rjf: Weak Access Scope Types OS_Handle file_map;
void *file_base;
typedef struct DBGI_TouchedBinary DBGI_TouchedBinary; FileProperties file_props;
struct DBGI_TouchedBinary
{ // rjf: parse artifacts
DBGI_TouchedBinary *next; Arena *arena;
DBGI_Binary *binary; RDI_Parsed rdi;
}; B32 parse_done;
};
typedef struct DBGI_Scope DBGI_Scope;
struct DBGI_Scope typedef struct DI_Slot DI_Slot;
{ struct DI_Slot
DBGI_Scope *next; {
DBGI_TouchedBinary *first_tb; DI_Node *first;
DBGI_TouchedBinary *last_tb; DI_Node *last;
}; };
typedef struct DBGI_ThreadCtx DBGI_ThreadCtx; typedef struct DI_Stripe DI_Stripe;
struct DBGI_ThreadCtx struct DI_Stripe
{ {
Arena *arena; Arena *arena;
DBGI_Scope *free_scope; DI_Node *free_node;
DBGI_TouchedBinary *free_tb; DI_StringChunkNode *free_string_chunks[8];
}; OS_Handle rw_mutex;
OS_Handle cv;
//////////////////////////////// };
//~ rjf: Event Types
////////////////////////////////
typedef enum DBGI_EventKind //~ rjf: Search Cache Types
{
DBGI_EventKind_Null, typedef struct DI_SearchItem DI_SearchItem;
DBGI_EventKind_ConversionStarted, struct DI_SearchItem
DBGI_EventKind_ConversionEnded, {
DBGI_EventKind_ConversionFailureUnsupportedFormat, U64 idx;
DBGI_EventKind_COUNT U64 dbgi_idx;
} U64 missed_size;
DBGI_EventKind; FuzzyMatchRangeList match_ranges;
};
typedef struct DBGI_Event DBGI_Event;
struct DBGI_Event typedef struct DI_SearchItemChunk DI_SearchItemChunk;
{ struct DI_SearchItemChunk
DBGI_EventKind kind; {
String8 string; DI_SearchItemChunk *next;
}; DI_SearchItem *v;
U64 count;
typedef struct DBGI_EventNode DBGI_EventNode; U64 cap;
struct DBGI_EventNode };
{
DBGI_EventNode *next; typedef struct DI_SearchItemChunkList DI_SearchItemChunkList;
DBGI_Event v; struct DI_SearchItemChunkList
}; {
DI_SearchItemChunk *first;
typedef struct DBGI_EventList DBGI_EventList; DI_SearchItemChunk *last;
struct DBGI_EventList U64 chunk_count;
{ U64 total_count;
DBGI_EventNode *first; };
DBGI_EventNode *last;
U64 count; typedef struct DI_SearchItemArray DI_SearchItemArray;
}; struct DI_SearchItemArray
{
//////////////////////////////// DI_SearchItem *v;
//~ rjf: Cross-Thread Shared State U64 count;
};
typedef struct DBGI_Shared DBGI_Shared;
struct DBGI_Shared typedef struct DI_SearchParams DI_SearchParams;
{ struct DI_SearchParams
// rjf: arena {
Arena *arena; RDI_SectionKind target;
DI_KeyArray dbgi_keys;
// rjf: forced override table };
U64 force_slots_count;
U64 force_stripes_count; typedef struct DI_SearchBucket DI_SearchBucket;
DBGI_ForceSlot *force_slots; struct DI_SearchBucket
DBGI_ForceStripe *force_stripes; {
Arena *arena;
// rjf: binary table String8 query;
U64 binary_slots_count; U64 params_hash;
U64 binary_stripes_count; DI_SearchParams params;
DBGI_BinarySlot *binary_slots; };
DBGI_BinaryStripe *binary_stripes;
typedef struct DI_SearchNode DI_SearchNode;
// rjf: user -> parse ring struct DI_SearchNode
OS_Handle u2p_ring_mutex; {
OS_Handle u2p_ring_cv; DI_SearchNode *next;
U64 u2p_ring_size; DI_SearchNode *prev;
U8 *u2p_ring_base; U128 key;
U64 u2p_ring_write_pos; U64 scope_refcount;
U64 u2p_ring_read_pos; U64 work_refcount;
U64 last_update_tick_idx;
// rjf: parse -> user event ring U64 bucket_read_gen;
OS_Handle p2u_ring_mutex; U64 bucket_write_gen;
OS_Handle p2u_ring_cv; U64 bucket_items_gen;
U64 p2u_ring_size; DI_SearchBucket buckets[6];
U8 *p2u_ring_base; DI_SearchItemArray items;
U64 p2u_ring_write_pos; };
U64 p2u_ring_read_pos;
typedef struct DI_SearchSlot DI_SearchSlot;
// rjf: threads struct DI_SearchSlot
U64 parse_thread_count; {
OS_Handle *parse_threads; DI_SearchNode *first;
OS_Handle evictor_thread; DI_SearchNode *last;
}; };
//////////////////////////////// typedef struct DI_SearchStripe DI_SearchStripe;
//~ rjf: Globals struct DI_SearchStripe
{
global DBGI_Shared *dbgi_shared = 0; Arena *arena;
thread_static DBGI_ThreadCtx *dbgi_tctx = 0; DI_SearchNode *free_node;
global DBGI_Parse dbgi_parse_nil = {0}; OS_Handle rw_mutex;
OS_Handle cv;
//////////////////////////////// };
//~ rjf: Main Layer Initialization
////////////////////////////////
internal void dbgi_init(void); //~ rjf: Scoped Access Types
//////////////////////////////// typedef struct DI_Touch DI_Touch;
//~ rjf: Thread-Context Idempotent Initialization struct DI_Touch
{
internal void dbgi_ensure_tctx_inited(void); DI_Touch *next;
DI_Node *node;
//////////////////////////////// DI_SearchNode *search_node;
//~ rjf: Helpers };
internal U64 dbgi_hash_from_string(String8 string); typedef struct DI_Scope DI_Scope;
struct DI_Scope
//////////////////////////////// {
//~ rjf: Forced Override Cache Functions DI_Scope *next;
DI_Touch *first_touch;
internal void dbgi_force_exe_path_dbg_path(String8 exe_path, String8 dbg_path); DI_Touch *last_touch;
internal String8 dbgi_forced_dbg_path_from_exe_path(Arena *arena, String8 exe_path); };
//////////////////////////////// typedef struct DI_TCTX DI_TCTX;
//~ rjf: Scope Functions struct DI_TCTX
{
internal DBGI_Scope *dbgi_scope_open(void); Arena *arena;
internal void dbgi_scope_close(DBGI_Scope *scope); DI_Scope *free_scope;
internal void dbgi_scope_touch_binary__stripe_mutex_r_guarded(DBGI_Scope *scope, DBGI_Binary *binary); DI_Touch *free_touch;
};
////////////////////////////////
//~ rjf: Binary Cache Functions ////////////////////////////////
//~ rjf: Search Thread State Types
internal void dbgi_binary_open(String8 exe_path);
internal void dbgi_binary_close(String8 exe_path); typedef struct DI_SearchThread DI_SearchThread;
internal DBGI_Parse *dbgi_parse_from_exe_path(DBGI_Scope *scope, String8 exe_path, U64 endt_us); struct DI_SearchThread
{
//////////////////////////////// OS_Handle thread;
//~ rjf: Parse Threads OS_Handle ring_mutex;
OS_Handle ring_cv;
internal B32 dbgi_u2p_enqueue_exe_path(String8 exe_path, U64 endt_us); U64 ring_size;
internal String8 dbgi_u2p_dequeue_exe_path(Arena *arena); U8 *ring_base;
U64 ring_write_pos;
internal void dbgi_p2u_push_event(DBGI_Event *event); U64 ring_read_pos;
internal DBGI_EventList dbgi_p2u_pop_events(Arena *arena, U64 endt_us); };
internal void dbgi_parse_thread_entry_point(void *p); ////////////////////////////////
//~ rjf: Match Cache State Types
////////////////////////////////
//~ rjf: Evictor Thread typedef struct DI_Match DI_Match;
struct DI_Match
internal void dbgi_evictor_thread_entry_point(void *p); {
DI_Match *next;
#endif //DBGI_H DI_Match *prev;
U64 dbgi_idx;
RDI_SectionKind section;
U32 idx;
};
typedef struct DI_MatchNameNode DI_MatchNameNode;
struct DI_MatchNameNode
{
// rjf: synchronously written by usage code
DI_MatchNameNode *next;
DI_MatchNameNode *prev;
DI_MatchNameNode *lru_next;
DI_MatchNameNode *lru_prev;
U64 alloc_gen;
U64 first_gen_touched;
U64 last_gen_touched;
U64 req_params_hash;
U64 req_count;
String8 name;
U64 hash;
// rjf: atomically written by match work
U64 cmp_count;
U64 cmp_params_hash;
RDI_SectionKind section_kind;
// DI_Match *first_match;
// DI_Match *last_match;
};
typedef struct DI_MatchNameSlot DI_MatchNameSlot;
struct DI_MatchNameSlot
{
DI_MatchNameNode *first;
DI_MatchNameNode *last;
};
typedef struct DI_MatchStore DI_MatchStore;
struct DI_MatchStore
{
Arena *arena;
U64 gen;
Arena *gen_arenas[2];
// rjf: parameters
Arena *params_arena;
OS_Handle params_rw_mutex;
U64 params_hash;
DI_KeyArray params_keys;
// rjf: match cache
U64 match_name_slots_count;
DI_MatchNameSlot *match_name_slots;
DI_MatchNameNode *first_free_match_name;
DI_Match *first_free_match;
DI_MatchNameNode *first_lru_match_name;
DI_MatchNameNode *last_lru_match_name;
U64 active_match_name_nodes_count;
OS_Handle match_rw_mutex;
OS_Handle match_cv;
// rjf: user -> match work ring buffer
OS_Handle u2m_ring_cv;
OS_Handle u2m_ring_mutex;
U64 u2m_ring_size;
U8 *u2m_ring_base;
U64 u2m_ring_write_pos;
U64 u2m_ring_read_pos;
};
////////////////////////////////
//~ rjf: Shared State Types
typedef struct DI_Shared DI_Shared;
struct DI_Shared
{
Arena *arena;
// rjf: debug info cache
U64 slots_count;
DI_Slot *slots;
U64 stripes_count;
DI_Stripe *stripes;
// rjf: search cache
U64 search_slots_count;
DI_SearchSlot *search_slots;
U64 search_stripes_count;
DI_SearchStripe *search_stripes;
// rjf: user -> parse ring
OS_Handle u2p_ring_mutex;
OS_Handle u2p_ring_cv;
U64 u2p_ring_size;
U8 *u2p_ring_base;
U64 u2p_ring_write_pos;
U64 u2p_ring_read_pos;
// rjf: parse -> user event ring
OS_Handle p2u_ring_mutex;
OS_Handle p2u_ring_cv;
U64 p2u_ring_size;
U8 *p2u_ring_base;
U64 p2u_ring_write_pos;
U64 p2u_ring_read_pos;
// rjf: search threads
U64 search_threads_count;
DI_SearchThread *search_threads;
OS_Handle search_evictor_thread;
};
////////////////////////////////
//~ rjf: Globals
global DI_Shared *di_shared = 0;
thread_static DI_TCTX *di_tctx = 0;
global RDI_Parsed di_rdi_parsed_nil = {0};
////////////////////////////////
//~ rjf: Basic Helpers
internal U64 di_hash_from_seed_string(U64 seed, String8 string, StringMatchFlags match_flags);
internal U64 di_hash_from_string(String8 string, StringMatchFlags match_flags);
internal U64 di_hash_from_key(DI_Key *k);
internal DI_Key di_key_zero(void);
internal B32 di_key_match(DI_Key *a, DI_Key *b);
internal DI_Key di_key_copy(Arena *arena, DI_Key *src);
internal DI_Key di_normalized_key_from_key(Arena *arena, DI_Key *src);
internal void di_key_list_push(Arena *arena, DI_KeyList *list, DI_Key *key);
internal DI_KeyArray di_key_array_from_list(Arena *arena, DI_KeyList *list);
internal DI_KeyArray di_key_array_copy(Arena *arena, DI_KeyArray *src);
internal DI_SearchParams di_search_params_copy(Arena *arena, DI_SearchParams *src);
internal U64 di_hash_from_search_params(DI_SearchParams *params);
internal void di_search_item_chunk_list_concat_in_place(DI_SearchItemChunkList *dst, DI_SearchItemChunkList *to_push);
internal U64 di_search_item_num_from_array_element_idx__linear_search(DI_SearchItemArray *array, U64 element_idx);
internal String8 di_search_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind target, U64 element_idx);
////////////////////////////////
//~ rjf: Main Layer Initialization
internal void di_init(void);
////////////////////////////////
//~ rjf: Scope Functions
internal DI_Scope *di_scope_open(void);
internal void di_scope_close(DI_Scope *scope);
internal void di_scope_touch_node__stripe_mutex_r_guarded(DI_Scope *scope, DI_Node *node);
internal void di_scope_touch_search_node__stripe_mutex_r_guarded(DI_Scope *scope, DI_SearchNode *node);
////////////////////////////////
//~ rjf: Per-Slot Functions
internal DI_Node *di_node_from_key_slot__stripe_mutex_r_guarded(DI_Slot *slot, DI_Key *key);
////////////////////////////////
//~ rjf: Per-Stripe Functions
internal U64 di_string_bucket_idx_from_string_size(U64 size);
internal String8 di_string_alloc__stripe_mutex_w_guarded(DI_Stripe *stripe, String8 string);
internal void di_string_release__stripe_mutex_w_guarded(DI_Stripe *stripe, String8 string);
////////////////////////////////
//~ rjf: Key Opening/Closing
internal void di_open(DI_Key *key);
internal void di_close(DI_Key *key);
////////////////////////////////
//~ rjf: Debug Info Cache Lookups
internal RDI_Parsed *di_rdi_from_key(DI_Scope *scope, DI_Key *key, U64 endt_us);
////////////////////////////////
//~ rjf: Search Cache Lookups
internal DI_SearchItemArray di_search_items_from_key_params_query(DI_Scope *scope, U128 key, DI_SearchParams *params, String8 query, U64 endt_us, B32 *stale_out);
////////////////////////////////
//~ rjf: Asynchronous Parse Work
internal B32 di_u2p_enqueue_key(DI_Key *key, U64 endt_us);
internal void di_u2p_dequeue_key(Arena *arena, DI_Key *out_key);
internal void di_p2u_push_event(DI_Event *event);
internal DI_EventList di_p2u_pop_events(Arena *arena, U64 endt_us);
ASYNC_WORK_DEF(di_parse_work);
////////////////////////////////
//~ rjf: Search Threads
internal B32 di_u2s_enqueue_req(U128 key, U64 endt_us);
internal U128 di_u2s_dequeue_req(U64 thread_idx);
ASYNC_WORK_DEF(di_search_work);
internal int di_qsort_compare_search_items(DI_SearchItem *a, DI_SearchItem *b);
internal void di_search_thread__entry_point(void *p);
internal void di_search_evictor_thread__entry_point(void *p);
////////////////////////////////
//~ rjf: Match Store
internal DI_MatchStore *di_match_store_alloc(void);
internal void di_match_store_begin(DI_MatchStore *store, DI_KeyArray keys);
internal RDI_SectionKind di_match_store_section_kind_from_name(DI_MatchStore *store, String8 name, U64 endt_us);
ASYNC_WORK_DEF(di_match_work);
#endif // DBGI_H
-235
View File
@@ -1,235 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//- allen: Acceleration Layer Functions
//- accel helpers
internal DEMON_AccelModule*
demon_accel_module_alloc(void){
DEMON_AccelModule *result = demon_free_module_accel;
if (result != 0){
SLLStackPop(demon_free_module_accel);
}
else{
result = push_array_no_zero(demon_ent_arena, DEMON_AccelModule, 1);
}
MemoryZeroStruct(result);
return(result);
}
internal void
demon_accel_module_free(DEMON_AccelModule *module){
SLLStackPush(demon_free_module_accel, module);
}
internal DEMON_AccelThread*
demon_accel_thread_alloc(void){
DEMON_AccelThread *result = demon_free_thread_accel;
if (result != 0){
SLLStackPop(demon_free_thread_accel);
}
else{
result = push_array_no_zero(demon_ent_arena, DEMON_AccelThread, 1);
}
MemoryZeroStruct(result);
return(result);
}
internal void
demon_accel_thread_free(DEMON_AccelThread *thread){
SLLStackPush(demon_free_thread_accel, thread);
}
internal DEMON_AccelThread*
demon_accel_from_thread(DEMON_Entity *thread){
DEMON_AccelThread *accel = (DEMON_AccelThread*)thread->accel;
if (accel == 0){
accel = demon_accel_thread_alloc();
thread->accel = accel;
}
return(accel);
}
//- operations on demon objects
internal String8
demon_accel_full_path_from_module(Arena *arena, DEMON_Entity *module){
DEMON_AccelModule *accel = (DEMON_AccelModule*)module->accel;
String8 result = {0};
// first time
if (accel == 0){
result = demon_os_full_path_from_module(arena, module);
// build chain
DEMON_AccelModule *last_accel = 0;
U8 *ptr = result.str;
U8 *opl = result.str + result.size;
for (;ptr < opl;){
U64 size = (U64)(ptr - opl);
U64 clamped_size = ClampTop(result.size, sizeof(Member(DEMON_AccelModule, buf)));
DEMON_AccelModule *node = demon_accel_module_alloc();
SLLQueuePush(accel, last_accel, node);
node->total_size = result.size;
MemoryCopy(node->buf, ptr, clamped_size);
ptr += clamped_size;
}
// store in module
module->accel = accel;
}
// read from accel
else{
U64 size = accel->total_size;
U8 *str = push_array_no_zero(arena, U8, size + 1);
// copy chain contents to buffer
U8 *ptr = str;
for (DEMON_AccelModule *node = accel;
node != 0;
node = node->next){
U64 total_size = node->total_size;
U64 clamped_size = ClampTop(total_size, sizeof(node->buf));
MemoryCopy(ptr, node->buf, clamped_size);
ptr += clamped_size;
}
*ptr = 0;
// fill result
result.str = str;
result.size = size;
}
return(result);
}
internal U64
demon_accel_stack_base_vaddr_from_thread(DEMON_Entity *thread){
// get accel data
DEMON_AccelThread *accel = demon_accel_from_thread(thread);
// fill stack base
if (!accel->has_stack_base){
accel->has_stack_base = 1;
accel->stack_base = demon_os_stack_base_vaddr_from_thread(thread);
}
return(accel->stack_base);
}
internal U64
demon_accel_tls_root_vaddr_from_thread(DEMON_Entity *thread){
// get accel data
DEMON_AccelThread *accel = demon_accel_from_thread(thread);
// fill tls root
if (!accel->has_tls_root){
accel->has_tls_root = 1;
accel->tls_root = demon_os_tls_root_vaddr_from_thread(thread);
}
return(accel->tls_root);
}
internal void*
demon_accel_read_regs(DEMON_Entity *thread){
// get accel data
DEMON_AccelThread *accel = demon_accel_from_thread(thread);
// update reg cache
if (accel->reg_cache_time != demon_time){
accel->reg_cache_time = demon_time;
B32 success = 0;
switch (thread->arch){
case Architecture_x86:{success = demon_os_read_regs_x86(thread, &accel->regs.x86);}break;
case Architecture_x64:{success = demon_os_read_regs_x64(thread, &accel->regs.x64);}break;
}
if (!success){
MemoryZeroStruct(&accel->regs);
}
}
return(&accel->regs);
}
internal void
demon_accel_write_regs(DEMON_Entity *thread, void *data){
// get accel data
DEMON_AccelThread *accel = demon_accel_from_thread(thread);
// low level write
B32 success = 0;
U64 data_size = 0;
switch (thread->arch){
case Architecture_x86:
{
data_size = sizeof(REGS_RegBlockX86);
success = demon_os_write_regs_x86(thread, (REGS_RegBlockX86*)data);
}break;
case Architecture_x64:
{
data_size = sizeof(REGS_RegBlockX64);
success = demon_os_write_regs_x64(thread, (REGS_RegBlockX64*)data);
}break;
}
// update cache
if (success){
accel->reg_cache_time = demon_time;
MemoryCopy(&accel->regs, data, data_size);
}
}
internal void
demon_accel_low_level_write_regs(DEMON_Entity *thread){
// NOTE(allen): This is a tricky one. It's just a way to enable some internal
// optimizations. Instead of forcing the user to pass in register data
// to write out and copy to the cache, the "user" is other demon code that
// knows what it's doing. So it grabs the cache memory (through a call to
// `demon_accel_read_regs`) modifies it in place and then calls this.
// So we just have to write the cache contents directly out to OS.
// get accel data
DEMON_AccelThread *accel = demon_accel_from_thread(thread);
switch (thread->arch){
case Architecture_x86:
{
demon_os_write_regs_x86(thread, &accel->regs.x86);
}break;
case Architecture_x64:
{
demon_os_write_regs_x64(thread, &accel->regs.x64);
}break;
}
}
//- entity accel free
internal void
demon_accel_free(DEMON_Entity *entity){
switch (entity->kind){
case DEMON_EntityKind_Module:
{
if (entity->accel != 0){
for (DEMON_AccelModule *node = (DEMON_AccelModule*)entity->accel, *next = 0;
node != 0;
node = next){
next = node->next;
demon_accel_module_free(node);
}
}
}break;
case DEMON_EntityKind_Thread:
{
if (entity->accel != 0){
demon_accel_thread_free((DEMON_AccelThread*)entity->accel);
}
}break;
}
}
-66
View File
@@ -1,66 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_ACCEL_H
#define DEMON_ACCEL_H
////////////////////////////////
//~ allen: Acceleration Data
typedef struct DEMON_AccelModule DEMON_AccelModule;
struct DEMON_AccelModule
{
DEMON_AccelModule *next;
U64 total_size;
U8 buf[240];
};
typedef union DEMON_AccelThread DEMON_AccelThread;
union DEMON_AccelThread
{
DEMON_AccelThread *next;
struct{
B32 has_stack_base;
B32 has_tls_root;
U64 stack_base;
U64 tls_root;
U64 reg_cache_time;
union{
REGS_RegBlockX64 x64;
REGS_RegBlockX86 x86;
} regs;
};
};
////////////////////////////////
//~ allen: Acceleration Globals
global DEMON_AccelModule *demon_free_module_accel = 0;
global DEMON_AccelThread *demon_free_thread_accel = 0;
////////////////////////////////
//~ allen: Acceleration Layer Functions
//- accel helpers
internal DEMON_AccelModule *demon_accel_module_alloc(void);
internal void demon_accel_module_free(DEMON_AccelModule *module);
internal DEMON_AccelThread *demon_accel_thread_alloc(void);
internal void demon_accel_thread_free(DEMON_AccelThread *thread);
internal DEMON_AccelThread *demon_accel_from_thread(DEMON_Entity *thread);
//- operations on demon objects
internal String8 demon_accel_full_path_from_module(Arena *arena, DEMON_Entity *module);
internal U64 demon_accel_stack_base_vaddr_from_thread(DEMON_Entity *thread);
internal U64 demon_accel_tls_root_vaddr_from_thread(DEMON_Entity *thread);
internal void* demon_accel_read_regs(DEMON_Entity *thread);
internal void demon_accel_write_regs(DEMON_Entity *thread, void *data);
internal void demon_accel_low_level_write_regs(DEMON_Entity *thread);
//- entity accel free
internal void demon_accel_free(DEMON_Entity *entity);
#endif //DEMON_ACCEL_H
-270
View File
@@ -1,270 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
// NOTE(allen): State Safety Helper
internal B32
demon_access_begin(void){
B32 result = 0;
if (demon_primary_thread){
Assert(demon_run_state);
result = 1;
}
else{
os_mutex_take(demon_state_mutex);
if (demon_run_state){
os_mutex_drop(demon_state_mutex);
}
else{
result = 1;
}
}
return(result);
}
internal void
demon_access_end(void){
if (!demon_primary_thread){
os_mutex_drop(demon_state_mutex);
}
}
////////////////////////////////
// NOTE(allen): Entity System
internal void
demon_common_init(void){
// access control mechanism
demon_state_mutex = os_mutex_alloc();
// time
demon_time = 1;
// setup arena
demon_ent_arena = arena_alloc();
// setup map
demon_ent_map = push_array(demon_ent_arena, DEMON_Map, 1);
demon_ent_map->bucket_count = 4093;
demon_ent_map->buckets = push_array(demon_ent_arena, DEMON_MapSlot*, demon_ent_map->bucket_count);
// setup entity memory
U64 reserve_size_unaligned = (DEMON_ENTITY_CAP)*sizeof(DEMON_Entity);
U64 reserve_size = AlignPow2(reserve_size_unaligned, DEMON_ENTITY_CMT_SIZE);
demon_ent_cmt = demon_ent_pos = demon_ent_base = (DEMON_Entity*)os_reserve(reserve_size);
demon_ent_opl = demon_ent_base + (reserve_size/sizeof(DEMON_Entity));
Assert(demon_ent_base != 0);
// setup root
demon_ent_root = demon_ent_alloc();
demon_ent_root->kind = DEMON_EntityKind_Root;
}
internal DEMON_Entity*
demon_ent_alloc(void){
DEMON_Entity *result = demon_ent_free;
if (result != 0){
SLLStackPop(demon_ent_free);
}
else{
if (demon_ent_pos < demon_ent_opl){
if (ensure_commit(&demon_ent_cmt, demon_ent_pos + 1, DEMON_ENTITY_CMT_SIZE)){
result = demon_ent_pos;
demon_ent_pos += 1;
}
}
}
if (result != 0){
U32 gen = result->gen;
MemoryZeroStruct(result);
result->gen = gen;
}
return(result);
}
//- handle <-> entity pointer
internal DEMON_Entity*
demon_ent_ptr_from_handle(DEMON_Handle handle){
Assert(demon_ent_base != 0);
DEMON_Entity *result = 0;
U32 index = (U32)(handle & 0xFFFFFFFF);
U64 count = (U64)(demon_ent_pos - demon_ent_base);
if (0 < index && index < count){
DEMON_Entity *entity = demon_ent_base + index;
U32 gen = (U32)(handle >> 32);
if (gen == entity->gen){
result = entity;
}
}
return(result);
}
internal DEMON_Handle
demon_ent_handle_from_ptr(DEMON_Entity *entity){
Assert(demon_ent_base != 0);
DEMON_Handle result = {0};
if (demon_ent_base < entity && entity < demon_ent_pos){
U32 index = (U32)(entity - demon_ent_base);
U64 gen = entity->gen;
result = (gen << 32) | index;
}
return(result);
}
//- high level entity alloc,init,release
internal DEMON_Entity*
demon_ent_new(DEMON_Entity *parent, DEMON_EntityKind kind, U64 id){
Assert(demon_ent_base != 0);
DEMON_Entity *result = demon_ent_alloc();
if (result != 0){
result->kind = kind;
result->id = id;
result->arch = parent->arch;
result->parent = parent;
DLLPushBack(parent->first, parent->last, result);
demon_ent_map_save(kind, id, result);
}
return(result);
}
internal void
demon_ent_release_single(DEMON_Entity *entity){
switch (entity->kind){
case DEMON_EntityKind_Process: demon_proc_count -= 1; break;
case DEMON_EntityKind_Thread: demon_thread_count -= 1; break;
case DEMON_EntityKind_Module: demon_module_count -= 1; break;
}
demon_accel_free(entity);
demon_os_entity_cleanup(entity);
DEMON_MapRef ref = demon_ent_map_find(entity->kind, entity->id);
demon_ent_map_erase(ref);
entity->gen += 1;
}
internal void
demon_ent_release_children(DEMON_Entity *root){
Assert(demon_ent_base != 0);
if (root->first != 0){
for (DEMON_Entity *node = root->first;
node != 0;
node = node->next){
demon_ent_release_children(node);
demon_ent_release_single(node);
}
root->last->next = demon_ent_free;
demon_ent_free = root->first;
root->first = 0;
root->last = 0;
}
}
internal void
demon_ent_release_root_and_children(DEMON_Entity *root){
Assert(demon_ent_base != 0);
Assert(root->parent != 0);
// release children
demon_ent_release_children(root);
// release root
DEMON_Entity *parent = root->parent;
demon_ent_release_single(root);
DLLRemove(parent->first, parent->last, root);
SLLStackPush(demon_ent_free, root);
}
//- entity map
internal U64
demon_ent_map_hash(U16 kind, U64 id){
U64 result = ((U64)kind << 32) ^ id;
return(result);
}
internal void
demon_ent_map_save(U16 kind, U64 id, DEMON_Entity *entity){
Assert(demon_ent_base != 0);
DEMON_Map *map = demon_ent_map;
// allocate a new slot
DEMON_MapSlot *slot = map->free_slots;
if (slot != 0){
SLLStackPop(map->free_slots);
}
else{
slot = push_array_no_zero(demon_ent_arena, DEMON_MapSlot, 1);
}
// fill slot
slot->kind = kind;
slot->id = id;
slot->entity = entity;
// insert into bucket
U64 hash = demon_ent_map_hash(kind, id);
U64 bucket_index = hash%map->bucket_count;
SLLStackPush(map->buckets[bucket_index], slot);
}
internal DEMON_MapRef
demon_ent_map_find(U16 kind, U64 id){
Assert(demon_ent_base != 0);
DEMON_Map *map = demon_ent_map;
// scan bucket
DEMON_MapRef result = {0};
U64 hash = demon_ent_map_hash(kind, id);
U64 bucket_index = hash%map->bucket_count;
for (DEMON_MapSlot **ptr = &map->buckets[bucket_index], *slot = 0;
*ptr != 0;
ptr = &slot->next){
slot = *ptr;
if (slot->kind == kind && slot->id == id){
result.slot = slot;
result.ptr_to_slot = ptr;
break;
}
}
return(result);
}
internal DEMON_Entity*
demon_ent_map_entity_from_id(U16 kind, U64 id){
DEMON_Entity *result = 0;
DEMON_MapRef ref = demon_ent_map_find(kind, id);
if (ref.slot != 0){
result = ref.slot->entity;
}
return(result);
}
internal void
demon_ent_map_erase(DEMON_MapRef ref){
Assert(demon_ent_base != 0);
DEMON_Map *map = demon_ent_map;
// move slot to free list
if (ref.slot != 0){
*ref.ptr_to_slot = ref.slot->next;
SLLStackPush(map->free_slots, ref.slot);
}
}
////////////////////////////////
// NOTE(allen): Event Helpers
internal DEMON_Event*
demon_push_event(Arena *arena, DEMON_EventList *list, DEMON_EventKind kind){
DEMON_EventNode *n = push_array(arena, DEMON_EventNode, 1);
DEMON_Event *result = &n->v;
SLLQueuePush(list->first, list->last, n);
list->count += 1;
result->kind = kind;
return(result);
}
-150
View File
@@ -1,150 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_COMMON_H
#define DEMON_COMMON_H
////////////////////////////////
//~ allen: DEMON Entity System
typedef enum DEMON_EntityKind
{
DEMON_EntityKind_NULL,
DEMON_EntityKind_Root,
DEMON_EntityKind_Process,
DEMON_EntityKind_Thread,
DEMON_EntityKind_Module,
DEMON_EntityKind_COUNT
}
DEMON_EntityKind;
typedef struct DEMON_Entity DEMON_Entity;
struct DEMON_Entity
{
// TODO(allen): these could be U32s
DEMON_Entity *next;
DEMON_Entity *prev;
DEMON_Entity *parent;
DEMON_Entity *first;
DEMON_Entity *last;
U16 kind;
U16 arch;
U32 gen;
U64 id;
U64 addr_range_dim;
// each OS backend decides how to use `ext` for each entity kind
union{
void *ext;
U64 ext_u64;
};
// the accel layer attaches some extra information to some entities
void *accel;
};
//- id -> entity map
typedef struct DEMON_MapSlot DEMON_MapSlot;
struct DEMON_MapSlot
{
DEMON_MapSlot *next;
U16 kind;
U64 id;
DEMON_Entity *entity;
};
typedef struct DEMON_Map DEMON_Map;
struct DEMON_Map
{
DEMON_MapSlot **buckets;
U64 bucket_count;
DEMON_MapSlot *free_slots;
};
typedef struct DEMON_MapRef DEMON_MapRef;
struct DEMON_MapRef
{
DEMON_MapSlot *slot;
DEMON_MapSlot **ptr_to_slot;
};
//- rjf: entity extrusive list
typedef struct DEMON_EntityNode DEMON_EntityNode;
struct DEMON_EntityNode
{
DEMON_EntityNode *next;
DEMON_Entity *entity;
};
////////////////////////////////
//~ allen: Demon Globals
thread_static B32 demon_primary_thread = 0;
global B32 demon_run_state = 0;
global OS_Handle demon_state_mutex = {0};
global U64 demon_time = 0;
global Arena *demon_ent_arena = 0;
global DEMON_Map *demon_ent_map = 0;
global DEMON_Entity *demon_ent_free = 0;
global DEMON_Entity *demon_ent_root = 0;
global DEMON_Entity *demon_ent_base = 0;
global DEMON_Entity *demon_ent_pos = 0;
global DEMON_Entity *demon_ent_opl = 0;
global void *demon_ent_cmt = 0;
global U64 demon_proc_count = 0;
global U64 demon_thread_count = 0;
global U64 demon_module_count = 0;
#if !defined(DEMON_ENTITY_CMT_SIZE)
# define DEMON_ENTITY_CMT_SIZE KB(64)
#endif
#if !defined(DEMON_ENTITY_CAP)
# define DEMON_ENTITY_CAP 65536
#endif
StaticAssert(IsPow2(DEMON_ENTITY_CMT_SIZE), check_demon_entity_cmt_size);
////////////////////////////////
//~ allen: State Safety Helper
internal B32 demon_access_begin(void);
internal void demon_access_end(void);
////////////////////////////////
//~ allen: Entity System
internal void demon_common_init(void);
internal DEMON_Entity* demon_ent_alloc(void);
//- handle <-> entity pointer
internal DEMON_Entity* demon_ent_ptr_from_handle(DEMON_Handle handle);
internal DEMON_Handle demon_ent_handle_from_ptr(DEMON_Entity *entity);
//- high level entity alloc,init,release
internal DEMON_Entity* demon_ent_new(DEMON_Entity *parent, DEMON_EntityKind kind, U64 id);
internal void demon_ent_release_single(DEMON_Entity *entity);
internal void demon_ent_release_children(DEMON_Entity *root);
internal void demon_ent_release_root_and_children(DEMON_Entity *root);
//- entity map
internal U64 demon_ent_map_hash(U16 kind, U64 id);
internal void demon_ent_map_save(U16 kind, U64 id, DEMON_Entity *entity);
internal DEMON_MapRef demon_ent_map_find(U16 kind, U64 id);
internal DEMON_Entity* demon_ent_map_entity_from_id(U16 kind, U64 id);
internal void demon_ent_map_erase(DEMON_MapRef map_ref);
////////////////////////////////
//~ allen: Event Helpers
internal DEMON_Event* demon_push_event(Arena *arena, DEMON_EventList *list, DEMON_EventKind kind);
#endif //DEMON_COMMON_H
+188 -871
View File
File diff suppressed because it is too large. Load diff
+243 -293
View File
@@ -1,293 +1,243 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_H #ifndef DEMON_CORE_H
#define DEMON_CORE_H #define DEMON_CORE_H
//////////////////////////////// ////////////////////////////////
//~ allen: Demon Low Level Entities //~ rjf: Control-Thread-Only Context
//
typedef U64 DEMON_Handle; // An instance of this struct must ONLY be returned by dmn_ctrl_begin, and only
// used by the thread which called it. All APIs which can ONLY run on the
typedef struct DEMON_HandleNode DEMON_HandleNode; // control thread, which blocks to control & receive events, will take this
struct DEMON_HandleNode // parameter. All other APIs can be called from any thread.
{
DEMON_HandleNode *next; typedef struct DMN_CtrlCtx DMN_CtrlCtx;
DEMON_Handle v; struct DMN_CtrlCtx
}; {
U64 u64[1];
typedef struct DEMON_HandleList DEMON_HandleList; };
struct DEMON_HandleList
{ ////////////////////////////////
DEMON_HandleNode *first; //~ rjf: Handle Types
DEMON_HandleNode *last;
U64 count; typedef union DMN_Handle DMN_Handle;
}; union DMN_Handle
{
typedef struct DEMON_HandleArray DEMON_HandleArray; U32 u32[2];
struct DEMON_HandleArray U64 u64[1];
{ };
DEMON_Handle *handles;
U64 count; typedef struct DMN_HandleNode DMN_HandleNode;
}; struct DMN_HandleNode
{
//////////////////////////////// DMN_HandleNode *next;
//~ rjf: Memory Protection Flags DMN_Handle v;
};
typedef U32 DEMON_MemoryProtectFlags;
enum{ typedef struct DMN_HandleList DMN_HandleList;
DEMON_MemoryProtectFlag_Read = (1<<0), struct DMN_HandleList
DEMON_MemoryProtectFlag_Write = (1<<1), {
DEMON_MemoryProtectFlag_Execute = (1<<2), DMN_HandleNode *first;
}; DMN_HandleNode *last;
U64 count;
//////////////////////////////// };
//~ allen: Demon Event Types
typedef struct DMN_HandleArray DMN_HandleArray;
typedef enum DEMON_EventKind struct DMN_HandleArray
{ {
DEMON_EventKind_Null, DMN_Handle *handles;
DEMON_EventKind_Error, U64 count;
DEMON_EventKind_HandshakeComplete, };
DEMON_EventKind_CreateProcess,
DEMON_EventKind_ExitProcess, ////////////////////////////////
DEMON_EventKind_CreateThread, //~ rjf: Generated Code
DEMON_EventKind_ExitThread,
DEMON_EventKind_LoadModule, #include "generated/demon.meta.h"
DEMON_EventKind_UnloadModule,
DEMON_EventKind_Breakpoint, ////////////////////////////////
DEMON_EventKind_Trap, //~ rjf: Event Types
DEMON_EventKind_SingleStep,
DEMON_EventKind_Exception, typedef struct DMN_Event DMN_Event;
DEMON_EventKind_Halt, struct DMN_Event
DEMON_EventKind_Memory, {
DEMON_EventKind_DebugString, DMN_EventKind kind;
DEMON_EventKind_SetThreadName, DMN_ErrorKind error_kind;
DEMON_EventKind_COUNT DMN_MemoryEventKind memory_kind;
} DMN_ExceptionKind exception_kind;
DEMON_EventKind; DMN_Handle process;
DMN_Handle thread;
typedef enum DEMON_ErrorKind DMN_Handle module;
{ Arch arch;
DEMON_ErrorKind_Null, U64 address;
DEMON_ErrorKind_NotInitialized, U64 size;
DEMON_ErrorKind_NotAttached, String8 string;
DEMON_ErrorKind_UnexpectedFailure, U32 code; // code gives pid & tid on CreateProcess and CreateThread (respectfully)
DEMON_ErrorKind_InvalidHandle, U32 flags;
} S32 signo;
DEMON_ErrorKind; S32 sigcode;
U64 instruction_pointer;
typedef enum DEMON_MemoryEventKind U64 stack_pointer;
{ U64 user_data;
DEMON_MemoryEventKind_Null, B32 exception_repeated;
DEMON_MemoryEventKind_Commit, };
DEMON_MemoryEventKind_Reserve,
DEMON_MemoryEventKind_Decommit, typedef struct DMN_EventNode DMN_EventNode;
DEMON_MemoryEventKind_Release, struct DMN_EventNode
DEMON_MemoryEventKind_COUNT {
} DMN_EventNode *next;
DEMON_MemoryEventKind; DMN_Event v;
};
typedef enum DEMON_ExceptionKind
{ typedef struct DMN_EventList DMN_EventList;
DEMON_ExceptionKind_Null, struct DMN_EventList
DEMON_ExceptionKind_MemoryRead, {
DEMON_ExceptionKind_MemoryWrite, DMN_EventNode *first;
DEMON_ExceptionKind_MemoryExecute, DMN_EventNode *last;
DEMON_ExceptionKind_CppThrow, U64 count;
DEMON_ExceptionKind_COUNT };
}
DEMON_ExceptionKind; ////////////////////////////////
//~ rjf: Run Control Types
typedef struct DEMON_Event DEMON_Event;
struct DEMON_Event typedef struct DMN_Trap DMN_Trap;
{ struct DMN_Trap
// TODO(allen): condense {
DEMON_EventKind kind; DMN_Handle process;
DEMON_ErrorKind error_kind; U64 vaddr;
DEMON_MemoryEventKind memory_kind; U64 id;
DEMON_ExceptionKind exception_kind; };
DEMON_Handle process;
DEMON_Handle thread; typedef struct DMN_TrapChunkNode DMN_TrapChunkNode;
DEMON_Handle module; struct DMN_TrapChunkNode
U64 address; {
U64 size; DMN_TrapChunkNode *next;
String8 string; DMN_Trap *v;
U32 code; // code gives pid & tid on CreateProcess and CreateThread (respectfully) U64 cap;
U32 flags; U64 count;
S32 signo; };
S32 sigcode;
U64 instruction_pointer; typedef struct DMN_TrapChunkList DMN_TrapChunkList;
U64 stack_pointer; struct DMN_TrapChunkList
U64 user_data; {
B32 exception_repeated; DMN_TrapChunkNode *first;
}; DMN_TrapChunkNode *last;
U64 node_count;
typedef struct DEMON_EventNode DEMON_EventNode; U64 trap_count;
struct DEMON_EventNode };
{
DEMON_EventNode *next; typedef struct DMN_RunCtrls DMN_RunCtrls;
DEMON_Event v; struct DMN_RunCtrls
}; {
DMN_Handle single_step_thread;
typedef struct DEMON_EventList DEMON_EventList; B8 ignore_previous_exception;
struct DEMON_EventList B8 run_entities_are_unfrozen;
{ B8 run_entities_are_processes;
DEMON_EventNode *first; DMN_Handle *run_entities;
DEMON_EventNode *last; U64 run_entity_count;
U64 count; DMN_TrapChunkList traps;
}; };
//////////////////////////////// ////////////////////////////////
//~ allen: Demon Run Control Types //~ rjf: System Process Listing Types
typedef struct DEMON_Trap DEMON_Trap; typedef struct DMN_ProcessIter DMN_ProcessIter;
struct DEMON_Trap struct DMN_ProcessIter
{ {
DEMON_Handle process; U64 v[2];
U64 address; };
U64 id;
}; typedef struct DMN_ProcessInfo DMN_ProcessInfo;
struct DMN_ProcessInfo
typedef struct DEMON_TrapChunkNode DEMON_TrapChunkNode; {
struct DEMON_TrapChunkNode String8 name;
{ U32 pid;
DEMON_TrapChunkNode *next; };
DEMON_Trap *v;
U64 cap; ////////////////////////////////
U64 count; //~ rjf: Basic Type Functions (Helpers, Implemented Once)
};
//- rjf: handles
typedef struct DEMON_TrapChunkList DEMON_TrapChunkList; internal DMN_Handle dmn_handle_zero(void);
struct DEMON_TrapChunkList internal B32 dmn_handle_match(DMN_Handle a, DMN_Handle b);
{
DEMON_TrapChunkNode *first; //- rjf: trap chunk lists
DEMON_TrapChunkNode *last; internal void dmn_trap_chunk_list_push(Arena *arena, DMN_TrapChunkList *list, U64 cap, DMN_Trap *trap);
U64 node_count; internal void dmn_trap_chunk_list_concat_in_place(DMN_TrapChunkList *dst, DMN_TrapChunkList *to_push);
U64 trap_count; internal void dmn_trap_chunk_list_concat_shallow_copy(Arena *arena, DMN_TrapChunkList *dst, DMN_TrapChunkList *to_push);
};
//- rjf: handle lists
typedef struct DEMON_RunCtrls DEMON_RunCtrls; internal void dmn_handle_list_push(Arena *arena, DMN_HandleList *list, DMN_Handle handle);
struct DEMON_RunCtrls internal DMN_HandleArray dmn_handle_array_from_list(Arena *arena, DMN_HandleList *list);
{ internal DMN_HandleArray dmn_handle_array_copy(Arena *arena, DMN_HandleArray *src);
DEMON_Handle single_step_thread;
B8 ignore_previous_exception; //- rjf: event list building
B8 run_entities_are_unfrozen; internal DMN_Event *dmn_event_list_push(Arena *arena, DMN_EventList *list);
B8 run_entities_are_processes;
DEMON_Handle *run_entities; ////////////////////////////////
U64 run_entity_count; //~ rjf: Thread Reading Helper Functions (Helpers, Implemented Once)
DEMON_TrapChunkList traps;
}; internal U64 dmn_rip_from_thread(DMN_Handle thread);
internal U64 dmn_rsp_from_thread(DMN_Handle thread);
////////////////////////////////
//~ allen: Demon Process Listing ////////////////////////////////
//~ rjf: @dmn_os_hooks Main Layer Initialization (Implemented Per-OS)
typedef struct DEMON_ProcessIter DEMON_ProcessIter;
struct DEMON_ProcessIter internal void dmn_init(void);
{
U64 v[2]; ////////////////////////////////
}; //~ rjf: @dmn_os_hooks Blocking Control Thread Operations (Implemented Per-OS)
typedef struct DEMON_ProcessInfo DEMON_ProcessInfo; internal DMN_CtrlCtx *dmn_ctrl_begin(void);
struct DEMON_ProcessInfo internal void dmn_ctrl_exclusive_access_begin(void);
{ internal void dmn_ctrl_exclusive_access_end(void);
String8 name; #define DMN_CtrlExclusiveAccessScope DeferLoop(dmn_ctrl_exclusive_access_begin(), dmn_ctrl_exclusive_access_end())
U32 pid; internal U32 dmn_ctrl_launch(DMN_CtrlCtx *ctx, OS_ProcessLaunchParams *params);
}; internal B32 dmn_ctrl_attach(DMN_CtrlCtx *ctx, U32 pid);
internal B32 dmn_ctrl_kill(DMN_CtrlCtx *ctx, DMN_Handle process, U32 exit_code);
//////////////////////////////// internal B32 dmn_ctrl_detach(DMN_CtrlCtx *ctx, DMN_Handle process);
//~ rjf: Main Layer Initialization internal DMN_EventList dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls);
internal void demon_init(void); ////////////////////////////////
//~ rjf: @dmn_os_hooks Halting (Implemented Per-OS)
////////////////////////////////
//~ rjf: Basic Type Functions internal void dmn_halt(U64 code, U64 user_data);
//- rjf: stringizing ////////////////////////////////
internal String8 demon_string_from_event_kind(DEMON_EventKind kind); //~ rjf: @dmn_os_hooks Introspection Functions (Implemented Per-OS)
internal String8 demon_string_from_memory_event_kind(DEMON_MemoryEventKind kind);
internal String8 demon_string_from_exception_kind(DEMON_ExceptionKind kind); //- rjf: run/memory/register counters
internal void demon_string_list_from_event(Arena *arena, String8List *out, DEMON_Event *event); internal U64 dmn_run_gen(void);
internal U64 dmn_mem_gen(void);
//- rjf: trap chunk lists internal U64 dmn_reg_gen(void);
internal void demon_trap_chunk_list_push(Arena *arena, DEMON_TrapChunkList *list, U64 cap, DEMON_Trap *trap);
internal void demon_trap_chunk_list_concat_in_place(DEMON_TrapChunkList *dst, DEMON_TrapChunkList *to_push); //- rjf: non-blocking-control-thread access barriers
internal void demon_trap_chunk_list_concat_shallow_copy(Arena *arena, DEMON_TrapChunkList *dst, DEMON_TrapChunkList *to_push); internal B32 dmn_access_open(void);
internal void dmn_access_close(void);
//- rjf: handle lists #define DMN_AccessScope DeferLoopChecked(dmn_access_open(), dmn_access_close())
internal void demon_handle_list_push(Arena *arena, DEMON_HandleList *list, DEMON_Handle handle);
internal DEMON_HandleArray demon_handle_array_from_list(Arena *arena, DEMON_HandleList *list); //- rjf: processes
internal DEMON_HandleArray demon_handle_array_copy(Arena *arena, DEMON_HandleArray *src); internal U64 dmn_process_memory_reserve(DMN_Handle process, U64 vaddr, U64 size);
internal void dmn_process_memory_commit(DMN_Handle process, U64 vaddr, U64 size);
//////////////////////////////// internal void dmn_process_memory_decommit(DMN_Handle process, U64 vaddr, U64 size);
//~ rjf: Primary Thread & Exclusive Mode Controls internal void dmn_process_memory_release(DMN_Handle process, U64 vaddr, U64 size);
internal void dmn_process_memory_protect(DMN_Handle process, U64 vaddr, U64 size, OS_AccessFlags flags);
internal void demon_primary_thread_begin(void); internal U64 dmn_process_read(DMN_Handle process, Rng1U64 range, void *dst);
internal void demon_exclusive_mode_begin(void); internal B32 dmn_process_write(DMN_Handle process, Rng1U64 range, void *src);
internal void demon_exclusive_mode_end(void); #define dmn_process_read_struct(process, vaddr, ptr) dmn_process_read((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
#define dmn_process_write_struct(process, vaddr, ptr) dmn_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
//////////////////////////////// internal String8 dmn_process_read_cstring(Arena *arena, DMN_Handle process, U64 addr);
//~ rjf: Running/Halting
//- rjf: threads
internal DEMON_EventList demon_run(Arena *arena, DEMON_RunCtrls *ctrls); internal Arch dmn_arch_from_thread(DMN_Handle handle);
internal void demon_halt(U64 code, U64 user_data); internal U64 dmn_stack_base_vaddr_from_thread(DMN_Handle handle);
internal U64 demon_get_time_counter(void); internal U64 dmn_tls_root_vaddr_from_thread(DMN_Handle handle);
internal B32 dmn_thread_read_reg_block(DMN_Handle handle, void *reg_block);
//////////////////////////////// internal B32 dmn_thread_write_reg_block(DMN_Handle handle, void *reg_block);
//~ rjf: Target Process Launching/Attaching/Killing/Detaching/Halting
//- rjf: system process listing
internal U32 demon_launch_process(OS_LaunchOptions *options); internal void dmn_process_iter_begin(DMN_ProcessIter *iter);
internal B32 demon_attach_process(U32 pid); internal B32 dmn_process_iter_next(Arena *arena, DMN_ProcessIter *iter, DMN_ProcessInfo *info_out);
internal B32 demon_kill_process(DEMON_Handle process, U32 exit_code); internal void dmn_process_iter_end(DMN_ProcessIter *iter);
internal B32 demon_detach_process(DEMON_Handle process);
#endif // DEMON_CORE_H
////////////////////////////////
//~ rjf: Entity Functions
//- rjf: basics
internal B32 demon_object_exists(DEMON_Handle object);
//- rjf: introspection
internal Architecture demon_arch_from_object(DEMON_Handle object);
internal U64 demon_base_vaddr_from_module(DEMON_Handle module);
internal Rng1U64 demon_vaddr_range_from_module(DEMON_Handle module);
internal String8 demon_full_path_from_module(Arena *arena, DEMON_Handle module);
internal U64 demon_stack_base_vaddr_from_thread(DEMON_Handle thread);
internal U64 demon_tls_root_vaddr_from_thread(DEMON_Handle thread);
internal DEMON_HandleArray demon_all_processes(Arena *arena);
internal DEMON_HandleArray demon_threads_from_process(Arena *arena, DEMON_Handle process);
internal DEMON_HandleArray demon_modules_from_process(Arena *arena, DEMON_Handle process);
//- rjf: target process memory allocation/protection
internal U64 demon_reserve_memory(DEMON_Handle process, U64 size);
internal B32 demon_set_memory_protect_flags(DEMON_Handle process, U64 page_vaddr, U64 size, DEMON_MemoryProtectFlags flags);
internal B32 demon_release_memory(DEMON_Handle process, U64 vaddr, U64 size);
//- rjf: target process memory reading/writing
internal U64 demon_read_memory(DEMON_Handle process, void *dst, U64 src_address, U64 size);
internal B32 demon_write_memory(DEMON_Handle process, U64 dst_address, void *src, U64 size);
internal U64 demon_read_memory_amap_aligned(DEMON_Handle process, void *dst, U64 src_address, U64 size);
internal U64 demon_read_memory_amap(DEMON_Handle process, void *dst, U64 src_address, U64 size);
//- rjf: thread registers reading/writing
// IMPORTANT(allen): This API is _trusting_ you. You should never modify the data pointed
// at by that void pointer! It is pointing to the internal cache of the registers, so it
// will become invalid after a call to demon_write_regs, or demon_run. Use it to read
// what you need and be done ASAP and we can avoid an extra copy baked into the API.
internal void *demon_read_regs(DEMON_Handle thread);
internal B32 demon_write_regs(DEMON_Handle thread, void *data);
// TODO(allen): These might be a bad idea when we try to extend to ARM
// They make sense for x86/x64 abstraction, which often needs identical
// code paths except for these parts. Revisit this when ARM is integrated.
internal U64 demon_read_ip(DEMON_Handle thread);
internal U64 demon_read_sp(DEMON_Handle thread);
internal void demon_write_ip(DEMON_Handle thread, U64 ip);
////////////////////////////////
//~ rjf: Process Listing
internal void demon_proc_iter_begin(DEMON_ProcessIter *iter);
internal B32 demon_proc_iter_next(Arena *arena, DEMON_ProcessIter *iter, DEMON_ProcessInfo *info_out);
internal void demon_proc_iter_end(DEMON_ProcessIter *iter);
#endif //DEMON_CORE_H
+90
View File
@@ -0,0 +1,90 @@
////////////////////////////////
//~ rjf: Event Kind Tables
@table(name)
DMN_EventKindTable:
{
{Null}
{Error}
{HandshakeComplete}
{CreateProcess}
{ExitProcess}
{CreateThread}
{ExitThread}
{LoadModule}
{UnloadModule}
{Breakpoint}
{Trap}
{SingleStep}
{Exception}
{Halt}
{Memory}
{DebugString}
{SetThreadName}
}
@table(name)
DMN_ErrorKindTable:
{
{Null}
{NotAttached}
{UnexpectedFailure}
{InvalidHandle}
}
@table(name)
DMN_MemoryEventKindTable:
{
{Null}
{Commit}
{Reserve}
{Decommit}
{Release}
}
@table(name)
DMN_ExceptionKindTable:
{
{Null}
{MemoryRead}
{MemoryWrite}
{MemoryExecute}
{CppThrow}
}
////////////////////////////////
//~ rjf: Generators
@enum DMN_EventKind:
{
@expand(DMN_EventKindTable a) `$(a.name)`,
COUNT
}
@data(String8) dmn_event_kind_string_table:
{
@expand(DMN_EventKindTable a) `str8_lit_comp("$(a.name)")`
}
@enum DMN_ErrorKind:
{
@expand(DMN_ErrorKindTable a) `$(a.name)`,
COUNT
}
@enum DMN_MemoryEventKind:
{
@expand(DMN_MemoryEventKindTable a) `$(a.name)`,
COUNT
}
@enum DMN_ExceptionKind:
{
@expand(DMN_ExceptionKindTable a) `$(a.name)`,
COUNT
}
@data(String8) dmn_exception_kind_string_table:
{
@expand(DMN_ExceptionKindTable a) `str8_lit_comp("$(a.name)")`
}
+12 -14
View File
@@ -1,14 +1,12 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "demon_core.c" #include "demon/demon_core.c"
#include "demon_common.c"
#include "demon_accel.c" #if OS_WINDOWS
# include "demon/win32/demon_core_win32.c"
#if OS_WINDOWS #elif OS_LINUX
# include "win32/demon_os_win32.c" # include "demon/linux/demon_core_linux.c"
#elif OS_LINUX #else
# include "linux/demon_os_linux.c" # error Demon layer backend not defined for this operating system.
#else #endif
# error No Demon Implementation for This OS
#endif
+17 -20
View File
@@ -1,20 +1,17 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_INC_H #ifndef DEMON_INC_H
#define DEMON_INC_H #define DEMON_INC_H
#include "demon_core.h" #include "demon/demon_core.h"
#include "demon_common.h"
#include "demon_accel.h" #if OS_WINDOWS
#include "demon_os.h" # include "demon/win32/demon_core_win32.h"
#elif OS_LINUX
#if OS_WINDOWS # include "demon/linux/demon_core_linux.h"
# include "win32/demon_os_win32.h" #else
#elif OS_LINUX # error Demon layer backend not defined for this operating system.
# include "linux/demon_os_linux.h" #endif
#else
# error No Demon Implementation for This OS #endif // DEMON_INC_H
#endif
#endif //DEMON_INC_H
-92
View File
@@ -1,92 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_OS_H
#define DEMON_OS_H
// NOTE(allen):
// These are the functions that the OS backends actually implement.
// Demon objects go through a handle validation layer but it is a lot more
// convenient in the OS backends to implement these versions which take the
// already validated DEMON_Entity*. These are also more convenient to call from
// the backend layer, which lets us avoid converting back and forth between
// handles and pointers a lot.
////////////////////////////////
//~ NOTE(allen): Demon OS Run Control Types
typedef struct DEMON_OS_Trap DEMON_OS_Trap;
struct DEMON_OS_Trap
{
DEMON_Entity *process;
U64 address;
};
typedef struct DEMON_OS_RunCtrls DEMON_OS_RunCtrls;
struct DEMON_OS_RunCtrls
{
DEMON_Entity *single_step_thread;
B8 ignore_previous_exception;
B8 run_entities_are_unfrozen;
B8 run_entities_are_processes;
DEMON_Entity **run_entities;
U64 run_entity_count;
DEMON_OS_Trap *traps;
U64 trap_count;
};
////////////////////////////////
//~ rjf: @demon_os_hooks Main Layer Initialization
internal void demon_os_init(void);
////////////////////////////////
//~ rjf: @demon_os_hooks Running/Halting
internal DEMON_EventList demon_os_run(Arena *arena, DEMON_OS_RunCtrls *controls);
internal void demon_os_halt(U64 code, U64 user_data);
////////////////////////////////
//~ rjf: @demon_os_hooks Target Process Launching/Attaching/Killing/Detaching/Halting
internal U32 demon_os_launch_process(OS_LaunchOptions *options);
internal B32 demon_os_attach_process(U32 pid);
internal B32 demon_os_kill_process(DEMON_Entity *process, U32 exit_code);
internal B32 demon_os_detach_process(DEMON_Entity *process);
////////////////////////////////
//~ rjf: @demon_os_hooks Entity Functions
//- rjf: cleanup
internal void demon_os_entity_cleanup(DEMON_Entity *entity);
//- rjf: introspection
internal String8 demon_os_full_path_from_module(Arena *arena, DEMON_Entity *module);
internal U64 demon_os_stack_base_vaddr_from_thread(DEMON_Entity *thread);
internal U64 demon_os_tls_root_vaddr_from_thread(DEMON_Entity *thread);
//- rjf: target process memory allocation/protection
internal U64 demon_os_reserve_memory(DEMON_Entity *process, U64 size);
internal void demon_os_set_memory_protect_flags(DEMON_Entity *process, U64 page_vaddr, U64 size, DEMON_MemoryProtectFlags flags);
internal void demon_os_release_memory(DEMON_Entity *process, U64 vaddr, U64 size);
//- rjf: target process memory reading/writing
internal U64 demon_os_read_memory(DEMON_Entity *process, void *dst, U64 src_address, U64 size);
internal B32 demon_os_write_memory(DEMON_Entity *process, U64 dst_address, void *src, U64 size);
#define demon_os_read_struct(p,dst,src) demon_os_read_memory((p), (dst), (src), sizeof(*(dst)))
#define demon_os_write_struct(p,dst,src) demon_os_write_memory((p), (dst), (src), sizeof(*(src)))
//- rjf: thread registers reading/writing
internal B32 demon_os_read_regs_x86(DEMON_Entity *thread, REGS_RegBlockX86 *dst);
internal B32 demon_os_write_regs_x86(DEMON_Entity *thread, REGS_RegBlockX86 *src);
internal B32 demon_os_read_regs_x64(DEMON_Entity *thread, REGS_RegBlockX64 *dst);
internal B32 demon_os_write_regs_x64(DEMON_Entity *thread, REGS_RegBlockX64 *src);
////////////////////////////////
//~ rjf: @demon_os_hooks Process Listing
internal void demon_os_proc_iter_begin(DEMON_ProcessIter *iter);
internal B32 demon_os_proc_iter_next(Arena *arena, DEMON_ProcessIter *iter, DEMON_ProcessInfo *info_out);
internal void demon_os_proc_iter_end(DEMON_ProcessIter *iter);
#endif //DEMON_OS_H
+38
View File
@@ -0,0 +1,38 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
C_LINKAGE_BEGIN
String8 dmn_event_kind_string_table[17] =
{
str8_lit_comp("Null"),
str8_lit_comp("Error"),
str8_lit_comp("HandshakeComplete"),
str8_lit_comp("CreateProcess"),
str8_lit_comp("ExitProcess"),
str8_lit_comp("CreateThread"),
str8_lit_comp("ExitThread"),
str8_lit_comp("LoadModule"),
str8_lit_comp("UnloadModule"),
str8_lit_comp("Breakpoint"),
str8_lit_comp("Trap"),
str8_lit_comp("SingleStep"),
str8_lit_comp("Exception"),
str8_lit_comp("Halt"),
str8_lit_comp("Memory"),
str8_lit_comp("DebugString"),
str8_lit_comp("SetThreadName"),
};
String8 dmn_exception_kind_string_table[5] =
{
str8_lit_comp("Null"),
str8_lit_comp("MemoryRead"),
str8_lit_comp("MemoryWrite"),
str8_lit_comp("MemoryExecute"),
str8_lit_comp("CppThrow"),
};
C_LINKAGE_END
+66
View File
@@ -0,0 +1,66 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
#ifndef DEMON_META_H
#define DEMON_META_H
typedef enum DMN_EventKind
{
DMN_EventKind_Null,
DMN_EventKind_Error,
DMN_EventKind_HandshakeComplete,
DMN_EventKind_CreateProcess,
DMN_EventKind_ExitProcess,
DMN_EventKind_CreateThread,
DMN_EventKind_ExitThread,
DMN_EventKind_LoadModule,
DMN_EventKind_UnloadModule,
DMN_EventKind_Breakpoint,
DMN_EventKind_Trap,
DMN_EventKind_SingleStep,
DMN_EventKind_Exception,
DMN_EventKind_Halt,
DMN_EventKind_Memory,
DMN_EventKind_DebugString,
DMN_EventKind_SetThreadName,
DMN_EventKind_COUNT,
} DMN_EventKind;
typedef enum DMN_ErrorKind
{
DMN_ErrorKind_Null,
DMN_ErrorKind_NotAttached,
DMN_ErrorKind_UnexpectedFailure,
DMN_ErrorKind_InvalidHandle,
DMN_ErrorKind_COUNT,
} DMN_ErrorKind;
typedef enum DMN_MemoryEventKind
{
DMN_MemoryEventKind_Null,
DMN_MemoryEventKind_Commit,
DMN_MemoryEventKind_Reserve,
DMN_MemoryEventKind_Decommit,
DMN_MemoryEventKind_Release,
DMN_MemoryEventKind_COUNT,
} DMN_MemoryEventKind;
typedef enum DMN_ExceptionKind
{
DMN_ExceptionKind_Null,
DMN_ExceptionKind_MemoryRead,
DMN_ExceptionKind_MemoryWrite,
DMN_ExceptionKind_MemoryExecute,
DMN_ExceptionKind_CppThrow,
DMN_ExceptionKind_COUNT,
} DMN_ExceptionKind;
C_LINKAGE_BEGIN
extern String8 dmn_event_kind_string_table[17];
extern String8 dmn_exception_kind_string_table[5];
C_LINKAGE_END
#endif // DEMON_META_H
+174
View File
@@ -0,0 +1,174 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: @dmn_os_hooks Main Layer Initialization (Implemented Per-OS)
internal void
dmn_init(void)
{
}
////////////////////////////////
//~ rjf: @dmn_os_hooks Blocking Control Thread Operations (Implemented Per-OS)
internal DMN_CtrlCtx *
dmn_ctrl_begin(void)
{
}
internal void
dmn_ctrl_exclusive_access_begin(void)
{
}
internal void
dmn_ctrl_exclusive_access_end(void)
{
}
internal U32
dmn_ctrl_launch(DMN_CtrlCtx *ctx, OS_ProcessLaunchParams *params)
{
}
internal B32
dmn_ctrl_attach(DMN_CtrlCtx *ctx, U32 pid)
{
}
internal B32
dmn_ctrl_kill(DMN_CtrlCtx *ctx, DMN_Handle process, U32 exit_code)
{
}
internal B32
dmn_ctrl_detach(DMN_CtrlCtx *ctx, DMN_Handle process)
{
}
internal DMN_EventList
dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
{
}
////////////////////////////////
//~ rjf: @dmn_os_hooks Halting (Implemented Per-OS)
internal void
dmn_halt(U64 code, U64 user_data)
{
}
////////////////////////////////
//~ rjf: @dmn_os_hooks Introspection Functions (Implemented Per-OS)
//- rjf: run/memory/register counters
internal U64
dmn_run_gen(void)
{
}
internal U64
dmn_mem_gen(void)
{
}
internal U64
dmn_reg_gen(void)
{
}
//- rjf: non-blocking-control-thread access barriers
internal B32
dmn_access_open(void)
{
}
internal void
dmn_access_close(void)
{
}
//- rjf: processes
internal U64
dmn_process_memory_reserve(DMN_Handle process, U64 vaddr, U64 size)
{
}
internal void
dmn_process_memory_commit(DMN_Handle process, U64 vaddr, U64 size)
{
}
internal void
dmn_process_memory_decommit(DMN_Handle process, U64 vaddr, U64 size)
{
}
internal void
dmn_process_memory_release(DMN_Handle process, U64 vaddr, U64 size)
{
}
internal void
dmn_process_memory_protect(DMN_Handle process, U64 vaddr, U64 size, OS_AccessFlags flags)
{
}
internal U64
dmn_process_read(DMN_Handle process, Rng1U64 range, void *dst)
{
}
internal B32
dmn_process_write(DMN_Handle process, Rng1U64 range, void *src)
{
}
//- rjf: threads
internal Arch
dmn_arch_from_thread(DMN_Handle handle)
{
}
internal U64
dmn_stack_base_vaddr_from_thread(DMN_Handle handle)
{
}
internal U64
dmn_tls_root_vaddr_from_thread(DMN_Handle handle)
{
}
internal B32
dmn_thread_read_reg_block(DMN_Handle handle, void *reg_block)
{
}
internal B32
dmn_thread_write_reg_block(DMN_Handle handle, void *reg_block)
{
}
//- rjf: system process listing
internal void
dmn_process_iter_begin(DMN_ProcessIter *iter)
{
}
internal B32
dmn_process_iter_next(Arena *arena, DMN_ProcessIter *iter, DMN_ProcessInfo *info_out)
{
}
internal void
dmn_process_iter_end(DMN_ProcessIter *iter)
{
}
+7
View File
@@ -0,0 +1,7 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_LINUX_H
#define DEMON_CORE_LINUX_H
#endif // DEMON_CORE_LINUX_H
File diff suppressed because it is too large. Load diff
+222 -222
View File
@@ -1,222 +1,222 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_OS_LINUX_H #ifndef DEMON_OS_LINUX_H
#define DEMON_OS_LINUX_H #define DEMON_OS_LINUX_H
// TODO(allen): Potential Upgrades: // TODO(allen): Potential Upgrades:
// //
// memory fd upgrade - Right now for each process we hold open a file // memory fd upgrade - Right now for each process we hold open a file
// descriptor for the process's memory (/proc/%d/mem) for the entire lifetime // descriptor for the process's memory (/proc/%d/mem) for the entire lifetime
// of the process; it could be opened and closed with some kind of LRU cache // of the process; it could be opened and closed with some kind of LRU cache
// to put a finite cap on the number of handles the demon holds // to put a finite cap on the number of handles the demon holds
// //
//////////////////////////////// ////////////////////////////////
//~ NOTE(allen): Get The Linux Includes //~ NOTE(allen): Get The Linux Includes
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <elf.h> #include <elf.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
//////////////////////////////// ////////////////////////////////
//~ NOTE(allen): Linux Demon Types //~ NOTE(allen): Linux Demon Types
//- entities //- entities
// Demon Linux Entity Extensions // Demon Linux Entity Extensions
// Process: ext_u64 set to memory file descriptor // Process: ext_u64 set to memory file descriptor
// Thread : ext_u64 cast to DEMON_LNX_ThreadExt // Thread : ext_u64 cast to DEMON_LNX_ThreadExt
// Module : ext_u64 set to U64 (address of name) // Module : ext_u64 set to U64 (address of name)
struct DEMON_LNX_ThreadExt{ struct DEMON_LNX_ThreadExt{
B32 expecting_dummy_sigstop; B32 expecting_dummy_sigstop;
}; };
StaticAssert(sizeof(DEMON_LNX_ThreadExt) <= sizeof(Member(DEMON_Entity, ext_u64)), check_demon_lnx_thread_ext); StaticAssert(sizeof(DEMON_LNX_ThreadExt) <= sizeof(Member(DEMON_Entity, ext_u64)), check_demon_lnx_thread_ext);
//- helpers //- helpers
struct DEMON_LNX_AttachNode{ struct DEMON_LNX_AttachNode{
DEMON_LNX_AttachNode *next; DEMON_LNX_AttachNode *next;
pid_t pid; pid_t pid;
}; };
struct DEMON_LNX_ProcessAux{ struct DEMON_LNX_ProcessAux{
B32 filled; B32 filled;
U64 phnum; U64 phnum;
U64 phent; U64 phent;
U64 phdr; U64 phdr;
U64 execfn; U64 execfn;
}; };
struct DEMON_LNX_PhdrInfo{ struct DEMON_LNX_PhdrInfo{
Rng1U64 range; Rng1U64 range;
U64 dynamic; U64 dynamic;
}; };
struct DEMON_LNX_ModuleNode{ struct DEMON_LNX_ModuleNode{
DEMON_LNX_ModuleNode *next; DEMON_LNX_ModuleNode *next;
U64 vaddr; U64 vaddr;
U64 size; U64 size;
U64 name; U64 name;
U64 already_known; U64 already_known;
}; };
struct DEMON_LNX_EntityNode{ struct DEMON_LNX_EntityNode{
DEMON_LNX_EntityNode *next; DEMON_LNX_EntityNode *next;
DEMON_Entity *entity; DEMON_Entity *entity;
}; };
//////////////////////////////// ////////////////////////////////
//~ NOTE(allen): Linux Demon Register Layouts //~ NOTE(allen): Linux Demon Register Layouts
// these are defined in <sys/user.h> but only for one architecture at a time // these are defined in <sys/user.h> but only for one architecture at a time
// (and we can't really trick it into giving us both in any obvious way) // (and we can't really trick it into giving us both in any obvious way)
// we define them here so that we have them all "at once" // we define them here so that we have them all "at once"
struct DEMON_LNX_UserRegsX64{ struct DEMON_LNX_UserRegsX64{
U64 r15; U64 r15;
U64 r14; U64 r14;
U64 r13; U64 r13;
U64 r12; U64 r12;
U64 rbp; U64 rbp;
U64 rbx; U64 rbx;
U64 r11; U64 r11;
U64 r10; U64 r10;
U64 r9; U64 r9;
U64 r8; U64 r8;
U64 rax; U64 rax;
U64 rcx; U64 rcx;
U64 rdx; U64 rdx;
U64 rsi; U64 rsi;
U64 rdi; U64 rdi;
U64 orig_rax; U64 orig_rax;
U64 rip; U64 rip;
U64 cs; U64 cs;
U64 rflags; U64 rflags;
U64 rsp; U64 rsp;
U64 ss; U64 ss;
U64 fsbase; U64 fsbase;
U64 gsbase; U64 gsbase;
U64 ds; U64 ds;
U64 es; U64 es;
U64 fs; U64 fs;
U64 gs; U64 gs;
}; };
struct DEMON_LNX_UserX64{ struct DEMON_LNX_UserX64{
DEMON_LNX_UserRegsX64 regs; DEMON_LNX_UserRegsX64 regs;
S32 u_fpvalid, _pad0; S32 u_fpvalid, _pad0;
SYMS_XSaveLegacy i387; SYMS_XSaveLegacy i387;
U64 u_tsize, u_dsize, u_ssize, start_code, start_stack; U64 u_tsize, u_dsize, u_ssize, start_code, start_stack;
U64 signal; U64 signal;
S32 reserved, _pad1; S32 reserved, _pad1;
U64 u_ar0, u_fpstate; U64 u_ar0, u_fpstate;
U64 magic; U64 magic;
U8 u_comm[32]; U8 u_comm[32];
U64 u_debugreg[8]; U64 u_debugreg[8];
}; };
struct DEMON_LNX_UserRegsX86{ struct DEMON_LNX_UserRegsX86{
U32 ebx; U32 ebx;
U32 ecx; U32 ecx;
U32 edx; U32 edx;
U32 esi; U32 esi;
U32 edi; U32 edi;
U32 ebp; U32 ebp;
U32 eax; U32 eax;
U32 ds; U32 ds;
U32 es; U32 es;
U32 fs; U32 fs;
U32 gs; U32 gs;
U32 orig_eax; U32 orig_eax;
U32 eip; U32 eip;
U32 cs; U32 cs;
U32 eflags; U32 eflags;
U32 sp; U32 sp;
U32 ss; U32 ss;
}; };
struct DEMON_LNX_UserX86{ struct DEMON_LNX_UserX86{
DEMON_LNX_UserRegsX86 regs; DEMON_LNX_UserRegsX86 regs;
S32 u_fpvalid; S32 u_fpvalid;
SYMS_FSave i387; SYMS_FSave i387;
U32 u_tsize, u_dsize, u_ssize, start_code, start_stack; U32 u_tsize, u_dsize, u_ssize, start_code, start_stack;
S32 signal, reserved; S32 signal, reserved;
U32 u_ar0, u_fpstate; U32 u_ar0, u_fpstate;
U32 magic; U32 magic;
U8 u_comm[32]; U8 u_comm[32];
U32 u_debugreg[8]; U32 u_debugreg[8];
}; };
//////////////////////////////// ////////////////////////////////
enum enum
{ {
DEMON_LNX_PermFlags_Read = (1 << 0), DEMON_LNX_PermFlags_Read = (1 << 0),
DEMON_LNX_PermFlags_Write = (1 << 1), DEMON_LNX_PermFlags_Write = (1 << 1),
DEMON_LNX_PermFlags_Exec = (1 << 2), DEMON_LNX_PermFlags_Exec = (1 << 2),
DEMON_LNX_PermFlags_Private = (1 << 3) DEMON_LNX_PermFlags_Private = (1 << 3)
}; };
typedef int DEMON_LNX_PermFlags; typedef int DEMON_LNX_PermFlags;
enum enum
{ {
DEMON_LNX_MapsEntryType_Null, DEMON_LNX_MapsEntryType_Null,
DEMON_LNX_MapsEntryType_Path, DEMON_LNX_MapsEntryType_Path,
DEMON_LNX_MapsEntryType_Heap, DEMON_LNX_MapsEntryType_Heap,
DEMON_LNX_MapsEntryType_Stack, DEMON_LNX_MapsEntryType_Stack,
DEMON_LNX_MapsEntryType_VDSO, DEMON_LNX_MapsEntryType_VDSO,
}; };
typedef int DEMON_LNX_MapsEntryType; typedef int DEMON_LNX_MapsEntryType;
struct DEMON_LNX_MapsEntry struct DEMON_LNX_MapsEntry
{ {
U64 address_lo; U64 address_lo;
U64 address_hi; U64 address_hi;
DEMON_LNX_PermFlags perms; DEMON_LNX_PermFlags perms;
U64 offset; U64 offset;
U32 dev_major; U32 dev_major;
U32 dev_minor; U32 dev_minor;
U64 inode; U64 inode;
String8 pathname; String8 pathname;
DEMON_LNX_MapsEntryType type; DEMON_LNX_MapsEntryType type;
pid_t stack_tid; pid_t stack_tid;
}; };
//////////////////////////////// ////////////////////////////////
//~ rjf: Helpers //~ rjf: Helpers
internal DEMON_LNX_ThreadExt* demon_lnx_thread_ext(DEMON_Entity *entity); internal DEMON_LNX_ThreadExt* demon_lnx_thread_ext(DEMON_Entity *entity);
internal B32 demon_lnx_attach_pid(Arena *arena, pid_t pid, DEMON_LNX_AttachNode **new_node); internal B32 demon_lnx_attach_pid(Arena *arena, pid_t pid, DEMON_LNX_AttachNode **new_node);
internal String8 demon_lnx_executable_path_from_pid(Arena *arena, pid_t pid); internal String8 demon_lnx_executable_path_from_pid(Arena *arena, pid_t pid);
internal int demon_lnx_open_memory_fd_for_pid(pid_t pid); internal int demon_lnx_open_memory_fd_for_pid(pid_t pid);
internal Architecture demon_lnx_arch_from_pid(pid_t pid); internal Arch demon_lnx_arch_from_pid(pid_t pid);
internal DEMON_LNX_ProcessAux demon_lnx_aux_from_pid(pid_t pid, Architecture arch); internal DEMON_LNX_ProcessAux demon_lnx_aux_from_pid(pid_t pid, Arch arch);
internal DEMON_LNX_PhdrInfo demon_lnx_phdr_info_from_memory(int memory_fd, B32 is_32bit, internal DEMON_LNX_PhdrInfo demon_lnx_phdr_info_from_memory(int memory_fd, B32 is_32bit,
U64 phvaddr, U64 phstride, U64 phcount); U64 phvaddr, U64 phstride, U64 phcount);
internal DEMON_LNX_ModuleNode* demon_lnx_module_list_from_process(Arena *arena, DEMON_Entity *process); internal DEMON_LNX_ModuleNode* demon_lnx_module_list_from_process(Arena *arena, DEMON_Entity *process);
internal U64 demon_lnx_read_memory(int memory_fd, void *dst, U64 src, U64 size); internal U64 demon_lnx_read_memory(int memory_fd, void *dst, U64 src, U64 size);
internal B32 demon_lnx_write_memory(int memory_fd, U64 dst, void *src, U64 size); internal B32 demon_lnx_write_memory(int memory_fd, U64 dst, void *src, U64 size);
internal String8 demon_lnx_read_memory_str(Arena *arena, int memory_fd, U64 address); internal String8 demon_lnx_read_memory_str(Arena *arena, int memory_fd, U64 address);
internal void demon_lnx_regs_x64_from_usr_regs_x64(SYMS_RegX64 *dst, DEMON_LNX_UserRegsX64 *src); internal void demon_lnx_regs_x64_from_usr_regs_x64(SYMS_RegX64 *dst, DEMON_LNX_UserRegsX64 *src);
internal void demon_lnx_usr_regs_x64_from_regs_x64(DEMON_LNX_UserRegsX64 *dst, SYMS_RegX64 *src); internal void demon_lnx_usr_regs_x64_from_regs_x64(DEMON_LNX_UserRegsX64 *dst, SYMS_RegX64 *src);
internal String8 demon_lnx_read_int_string(int fd); internal String8 demon_lnx_read_int_string(int fd);
internal B32 demon_lnx_read_expect(int fd, char expect); internal B32 demon_lnx_read_expect(int fd, char expect);
internal int demon_lnx_read_whitespace(int fd); internal int demon_lnx_read_whitespace(int fd);
internal String8 demon_lnx_read_string(Arena *arena, int fd); internal String8 demon_lnx_read_string(Arena *arena, int fd);
internal int demon_lnx_open_maps(pid_t pid); internal int demon_lnx_open_maps(pid_t pid);
internal B32 demon_lnx_next_map(Arena *arena, int maps, DEMON_LNX_MapsEntry *entry_out); internal B32 demon_lnx_next_map(Arena *arena, int maps, DEMON_LNX_MapsEntry *entry_out);
#endif //DEMON_OS_LINUX_H #endif //DEMON_OS_LINUX_H
-65
View File
@@ -1,65 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
// exe //
#include "base/base_inc.h"
#include "os/os_inc.h"
#include "demon/demon_inc.h"
#include "syms_helpers/syms_internal_overrides.h"
#include "syms/syms_inc.h"
#include "syms_helpers/syms_helpers.h"
#include "base/base_inc.c"
#include "os/os_inc.c"
#include "demon/demon_inc.c"
#include "syms_helpers/syms_internal_overrides.c"
#include "syms/syms_inc.c"
#include "syms_helpers/syms_helpers.c"
int
main(int argument_count, char **arguments)
{
os_init(argument_count, arguments);
Arena *arena = arena_alloc();
demon_init();
//- rjf: find PID of mule_loop.exe
String8 attach_process_name = str8_lit("mule_loop.exe");
U32 pid = 0;
{
DEMON_ProcessIter it = {0};
demon_proc_iter_begin(&it);
for(DEMON_ProcessInfo info = {0}; demon_proc_iter_next(arena, &it, &info);)
{
if(str8_match(info.name, attach_process_name, 0))
{
pid = info.pid;
break;
}
}
demon_proc_iter_end(&it);
}
//- rjf: attach
B32 attach_good = demon_attach_process(pid);
//- rjf: get events
DEMON_RunCtrls ctrls = {0};
DEMON_EventList events = demon_run(arena, ctrls);
for(DEMON_Event *event = events.first; event != 0; event = event->next)
{
int x = 0;
}
#if 0
//- rjf: try to break in the loop
DEMON_RunCtrls ctrls = {0};
DEMON_Trap trap = {0};
{
U64 loop_bp = 0x0000000140001074;
ctrls.trap_count = 1;
ctrls.traps = &trap;
}
#endif
}
-166
View File
@@ -1,166 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#include "base/base_inc.h"
#include "os/os_inc.h"
#include "demon/demon_inc.h"
#include "syms_helpers/syms_internal_overrides.h"
#include "syms/syms_inc.h"
#include "syms_helpers/syms_helpers.h"
#include "base/base_inc.c"
#include "os/os_inc.c"
#include "demon/demon_inc.c"
#include "syms_helpers/syms_internal_overrides.c"
#include "syms/syms_inc.c"
#include "syms_helpers/syms_helpers.c"
internal SYMS_String8
file_load_func_for_syms(void *user, SYMS_Arena *arena, SYMS_String8 file_name){
String8 data = os_read_file(arena, str8_from_syms(file_name));
SYMS_String8 result = syms_from_str8(data);
return(result);
}
int
main(int argument_count, char **arguments)
{
os_init(argument_count, arguments);
Temp scratch = scratch_begin(0, 0);
// setup
demon_init();
// parse arguments
String8 executable_file_name = {0};
U64 bp_address = 0;
{
String8List command_line_arguments = os_get_command_line_arguments();
CmdLine cmd_line = cmd_line_from_string_list(scratch.arena, command_line_arguments);
if (cmd_line.inputs.first != 0){
executable_file_name = cmd_line.inputs.first->string;
}
String8 bp_string = cmd_line_string(cmd_line, str8_lit("bp"));
try_u64_from_str8_c_rules(bp_string, &bp_address);
}
// check parameters
if (bp_address == 0 || executable_file_name.size == 0){
printf("bad parameters\n");
exit(0);
}
// demon launch
OS_LaunchOptions launch_opts = {0};
str8_list_push(scratch.arena, &launch_opts.cmd_line, executable_file_name);
launch_opts.path = os_get_path(scratch.arena, OS_SystemPath_Current);
U32 process_id = demon_launch_process(&launch_opts);
if (process_id == 0){
printf("could not launch: '%.*s'\n", str8_varg(executable_file_name));
exit(0);
}
// demon loop
{
DEMON_Handle process = 0;
DEMON_Handle thread = 0;
B32 hit_bp = false;
U64 single_step_counter = 0;
U64 counter = 0;
for (;;){
Temp temp = temp_begin(scratch.arena);
DEMON_RunCtrls run_controls = {0};
DEMON_Trap traps[1];
if (!hit_bp){
if (process != 0){
run_controls.trap_count = 1;
run_controls.traps = traps;
run_controls.traps[0].process = process;
run_controls.traps[0].address = bp_address;
}
}
else{
run_controls.single_step_thread = thread;
}
DEMON_EventList events = demon_run(temp.arena, run_controls);
for (DEMON_Event *event = events.first;
event != 0;
event = event->next, counter += 1){
// update tracking state
switch (event->kind){
case DEMON_EventKind_CreateProcess:
{
process = event->process;
}break;
case DEMON_EventKind_ExitProcess:
{
if (event->process == process){
process = 0;
}
}break;
case DEMON_EventKind_CreateThread:
{
thread = event->thread;
}break;
case DEMON_EventKind_Breakpoint:
{
hit_bp = true;
}break;
case DEMON_EventKind_SingleStep:
{
single_step_counter += 1;
SYMS_RegX64 regs1 = {0};
demon_read_x64_regs(thread, &regs1);
demon_write_x64_regs(thread, &regs1);
SYMS_RegX64 regs2 = {0};
demon_read_x64_regs(thread, &regs2);
if (!MemoryMatchStruct(&regs1, &regs2)){
printf("mismatch at single_step_counter=%llu\n", single_step_counter);
}
if (single_step_counter == 1000){
goto end_loop;
}
}break;
case DEMON_EventKind_NotAttached:
{
fprintf(stderr, "not attached - exiting\n");
goto end_loop;
}break;
case DEMON_EventKind_NotInitialized:
case DEMON_EventKind_UnexpectedFailure:
{
fprintf(stderr, "unexpected error - exiting\n");
goto end_loop;
}break;
}
}
goto end_it;
end_loop:
temp_end(temp);
goto loop_exit;
end_it:;
}
loop_exit:;
}
printf("[done]\n");
scratch_end(scratch);
}
-250
View File
@@ -1,250 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#include "base/base_inc.h"
#include "os/os_inc.h"
#include "demon/demon_inc.h"
#include "syms_helpers/syms_internal_overrides.h"
#include "syms/syms_inc.h"
#include "syms_helpers/syms_helpers.h"
#include "base/base_inc.c"
#include "os/os_inc.c"
#include "demon/demon_inc.c"
#include "syms_helpers/syms_internal_overrides.c"
#include "syms/syms_inc.c"
#include "syms_helpers/syms_helpers.c"
internal SYMS_String8
file_load_func_for_syms(void *user, SYMS_Arena *arena, SYMS_String8 file_name){
String8 data = os_read_file(arena, str8_from_syms(file_name));
SYMS_String8 result = syms_from_str8(data);
return(result);
}
int
main(int argument_count, char **arguments)
{
os_init(argument_count, arguments);
demon_init();
String8Node node[2];
#define TARGET_EXE "C:\\devel\\projects\\debugger\\build\\mule_unwind_20210511_clang11_lldlink.exe"
OS_LaunchOptions options = {0};
#if OS_WINDOWS
str8_list_push(&options.cmd_line, &node[0], str8_lit(TARGET_EXE));
options.path = str8_lit("C:\\devel\\projects\\debugger\\build\\");
#else
str8_list_push(&options.cmd_line, &node[0], str8_lit("/home/allenw/projects_copy/debugger/build/mule_main"));
options.path = str8_lit("/home/allenw/projects_copy/debugger/build/");
#endif
U32 process_id = demon_launch_process(&options);
if (process_id == 0){
printf("Could not launch process\n");
exit(1);
}
#if OS_WINDOWS
U64 bp_addr = 0x140001134;
#else
U64 bp_addr = 0x400918;
#endif
DEMON_Handle process = 0;
DEMON_Handle thread = 0;
DEMON_Handle module = 0;
U64 module_base = 0;
SYMS_Group *group = 0;
B32 hit_bp = false;
U64 counter = 0;
for (;;){
DEMON_RunCtrls run_controls = {0};
DEMON_Trap trap_memory[2];
DEMON_Trap *trap_ptr = trap_memory;
if (process != 0 && !hit_bp){
trap_ptr->process = process;
trap_ptr->address = bp_addr;
trap_ptr += 1;
}
run_controls.traps = trap_memory;
run_controls.trap_count = (U64)(trap_ptr - trap_memory);
Temp scratch = scratch_begin(0, 0);
DEMON_EventList events = demon_run(scratch.arena, run_controls);
for (DEMON_Event *event = events.first;
event != 0;
event = event->next){
printf("STEP[%05llx] -- ", counter);
counter += 1;
switch (event->kind){
case DEMON_EventKind_NotInitialized:
{
printf("Not Initialized\n");
exit(1);
}break;
case DEMON_EventKind_NotAttached:
{
printf("Not Attached\n");
exit(1);
}break;
case DEMON_EventKind_UnexpectedFailure:
{
printf("Unexpected Failure\n");
exit(1);
}break;
case DEMON_EventKind_CreateProcess:
{
printf("Create Process\n");
if (process == 0){
process = event->process;
}
}break;
case DEMON_EventKind_CreateThread:
{
printf("Create Thread\n");
if (thread == 0){
thread = event->thread;
}
}break;
case DEMON_EventKind_LoadModule:
{
Temp temp = temp_begin(scratch.arena);
String8 file_name = demon_full_path_from_module(scratch.arena, event->module);
printf("Load Module: %.*s\n", str8_varg(file_name));
if (module == 0 && str8_match(file_name, str8_lit(TARGET_EXE), 0)){
module = event->module;
module_base = event->address;
// setup syms group
group = syms_group_alloc();
SYMS_FileLoadCtx ctx = {0};
ctx.file_load_func = file_load_func_for_syms;
SYMS_String8List file_names = {0};
syms_string_list_push(group->arena, &file_names, syms_from_str8(file_name));
SYMS_FileInfOptions opts = {0};
SYMS_FileInfResult inf_result = syms_file_inf_infer_from_file_list(group->arena, ctx, file_names, &opts);
syms_group_init(group, &inf_result.data_parsed);
}
temp_end(temp);
}break;
case DEMON_EventKind_ExitProcess:
{
printf("Exit Process\n");
exit(0);
}break;
case DEMON_EventKind_ExitThread:
{
printf("Exit Thread\n");
}break;
case DEMON_EventKind_UnloadModule:
{
printf("Unload Module\n");
}break;
case DEMON_EventKind_Breakpoint:
{
Architecture arch = demon_arch_from_object(event->process);
U64 ip = event->instruction_pointer;
printf("Breakpoint: %llx\n", ip);
hit_bp = true;
//- unwind
// setup bin
SYMS_String8 bin_data = group->bin_data;
SYMS_BinAccel *generic_bin = group->bin;
SYMS_PeBinAccel *pe_bin = 0;
if (generic_bin->format == SYMS_FileFormat_PE){
pe_bin = (SYMS_PeBinAccel*)generic_bin;
}
if (pe_bin != 0){
// read regs
SYMS_RegX64 regs = {0};
demon_read_x64_regs(event->thread, &regs);
// read stack
SYMS_U64 sp = regs.rsp.u64;
SYMS_U64 sp_rounded_down = sp&~(KB(4) - 1);
SYMS_String8 stack_memory = {0};
stack_memory.size = KB(8);
stack_memory.str = push_array_no_zero(scratch.arena, U8, stack_memory.size);
SYMS_U64 stack_memory_addr = sp_rounded_down;
stack_memory.size = demon_read_memory_amap(event->process, stack_memory.str,
stack_memory_addr, stack_memory.size);
// unwind loop
U64 counter = 1;
for (;; counter += 1){
printf("%02llu: ip=%llx; sp=%llx\n", counter, regs.rip.u64, regs.rsp.u64);
SYMS_MemoryView memview = syms_memory_view_make(stack_memory, stack_memory_addr);
SYMS_UnwindResult unwind_result = syms_unwind_pe_x64(bin_data, pe_bin, module_base, &memview, &regs);
if (unwind_result.dead){
break;
}
}
}
}break;
case DEMON_EventKind_Trap:
{
Architecture arch = demon_arch_from_object(event->process);
U64 ip = event->instruction_pointer;
printf("Trap: %llx\n", ip);
}break;
case DEMON_EventKind_SingleStep:
{
printf("Single Step: %llx\n", event->instruction_pointer);
}break;
case DEMON_EventKind_Exception:
{
printf("Exception: %llx\n", event->instruction_pointer);
}break;
case DEMON_EventKind_Halt:
{
printf("Halt\n");
}break;
case DEMON_EventKind_Memory:
{
printf("Memory\n");
}break;
default:
{
printf("Unhandled Event\n");
exit(1);
}break;
}
}
scratch_end(scratch);
}
printf("Done\n");
}
-935
View File
@@ -1,935 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
// NOTE(rjf): (18 October 2021) Notes on Win32 process halting via
// DebugBreakProcess:
//
// Calling DebugBreakProcess seems to cause a few events to come back:
// 1. Thread Creation Event
// 2. Breakpoint Event (with the thread matching that of #1)
// 3. Thread Exiting Event (matching #1)
//
// Having done this experiment on a single-threaded program (mule_loop.exe),
// I can only infer that what is happening here is that when DebugBreakProcess
// is called, it first injects a thread into the target process that runs
// code with an int3. This is very similar to the old approach that Demon
// took.
//
// It's going to be difficult to distinguish between these CreateThreads and
// ExitThreads from others (not caused by halting), even though we can match
// the hit breakpoint to the associated thread.
//
// What could be possible (in order to distinguish the hit breakpoint as a
// halt event, instead of an arbitrary breakpoint) is looking at the breakpoint
// address. This injected thread has a breakpoint that's different from the
// initial breakpoint that the kernel automatically hits when a process is
// first being debugged.
//
// With DebugBreakProcess:
// - first breakpoint that is hit: 0x7ff8ad9806b0 in kernel code
// - last breakpoint that is hit: 0x7ff8ad950860 in kernel code (halt)
//
// Without DebugBreakProcess:
// - first breakpoint that is hit: 0x7ff8ad9806b0
//
// NOTE(rjf): (18 October 2021) Notes on suspending processes via
// NtSuspendProcess:
//
// NtSuspendProcess is an undocumented API that is exported by ntdll. It is
// fairly simple but could be unstable. To call it, the main trick is that
// you need a handle with certain privileges (PROCESS_SUSPEND_RESUME), so
// you can't just take any handle and use it.
//
// To use it, we can manually load it from ntdll, grab an elevated handle
// for a given process HANDLE, and then call it. We can resume, then, with
// NtResumeProcess.
//
// Other than this, our options seem to more-or-less lie in individually
// suspending all of the threads in the process-to-be-halted.
#include <windows.h>
#include "base/base_inc.h"
#include "os/os_inc.h"
#include "syms_helpers/syms_internal_overrides.h"
#include "syms/syms_inc.h"
#include "syms_helpers/syms_helpers.h"
#include "base/base_inc.c"
#include "os/os_inc.c"
#include "syms_helpers/syms_internal_overrides.c"
#include "syms/syms_inc.c"
#include "syms_helpers/syms_helpers.c"
typedef LONG NtSuspendProcessFunction(HANDLE ProcessHandle);
global NtSuspendProcessFunction *NtSuspendProcess = 0;
////////////////////////////////
// NOTE(allen): Win32 Demon Exceptions
#define DEMON_W32_EXCEPTION_BREAKPOINT 0x80000003u
#define DEMON_W32_EXCEPTION_SINGLE_STEP 0x80000004u
#define DEMON_W32_EXCEPTION_LONG_JUMP 0x80000026u
#define DEMON_W32_EXCEPTION_ACCESS_VIOLATION 0xC0000005u
#define DEMON_W32_EXCEPTION_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define DEMON_W32_EXCEPTION_DATA_TYPE_MISALIGNMENT 0x80000002u
#define DEMON_W32_EXCEPTION_GUARD_PAGE_VIOLATION 0x80000001u
#define DEMON_W32_EXCEPTION_FLT_DENORMAL_OPERAND 0xC000008Du
#define DEMON_W32_EXCEPTION_FLT_DEVIDE_BY_ZERO 0xC000008Eu
#define DEMON_W32_EXCEPTION_FLT_INEXACT_RESULT 0xC000008Fu
#define DEMON_W32_EXCEPTION_FLT_INVALID_OPERATION 0xC0000090u
#define DEMON_W32_EXCEPTION_FLT_OVERFLOW 0xC0000091u
#define DEMON_W32_EXCEPTION_FLT_STACK_CHECK 0xC0000092u
#define DEMON_W32_EXCEPTION_FLT_UNDERFLOW 0xC0000093u
#define DEMON_W32_EXCEPTION_INT_DIVIDE_BY_ZERO 0xC0000094u
#define DEMON_W32_EXCEPTION_INT_OVERFLOW 0xC0000095u
#define DEMON_W32_EXCEPTION_PRIVILEGED_INSTRUCTION 0xC0000096u
#define DEMON_W32_EXCEPTION_ILLEGAL_INSTRUCTION 0xC000001Du
#define DEMON_W32_EXCEPTION_IN_PAGE_ERROR 0xC0000006u
#define DEMON_W32_EXCEPTION_INVALID_DISPOSITION 0xC0000026u
#define DEMON_W32_EXCEPTION_NONCONTINUABLE 0xC0000025u
#define DEMON_W32_EXCEPTION_STACK_OVERFLOW 0xC00000FDu
#define DEMON_W32_EXCEPTION_INVALID_HANDLE 0xC0000008u
#define DEMON_W32_EXCEPTION_UNWIND_CONSOLIDATE 0x80000029u
#define DEMON_W32_EXCEPTION_DLL_NOT_FOUND 0xC0000135u
#define DEMON_W32_EXCEPTION_ORDINAL_NOT_FOUND 0xC0000138u
#define DEMON_W32_EXCEPTION_ENTRY_POINT_NOT_FOUND 0xC0000139u
#define DEMON_W32_EXCEPTION_DLL_INIT_FAILED 0xC0000142u
#define DEMON_W32_EXCEPTION_CONTROL_C_EXIT 0xC000013Au
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_FAULTS 0xC00002B4u
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_TRAPS 0xC00002B5u
#define DEMON_W32_EXCEPTION_NAT_CONSUMPTION 0xC00002C9u
#define DEMON_W32_EXCEPTION_HEAP_CORRUPTION 0xC0000374u
#define DEMON_W32_EXCEPTION_STACK_BUFFER_OVERRUN 0xC0000409u
#define DEMON_W32_EXCEPTION_INVALID_CRUNTIME_PARAM 0xC0000417u
#define DEMON_W32_EXCEPTION_ASSERT_FAILURE 0xC0000420u
#define DEMON_W32_EXCEPTION_NO_MEMORY 0xC0000017u
#define DEMON_W32_EXCEPTION_THROW 0xE06D7363u
////////////////////////////////
// NOTE(allen): Win32 Demon Register API Codes
#define DEMON_W32_CTX_X86 0x00010000
#define DEMON_W32_CTX_X64 0x00100000
#define DEMON_W32_CTX_INTEL_CONTROL 0x0001
#define DEMON_W32_CTX_INTEL_INTEGER 0x0002
#define DEMON_W32_CTX_INTEL_SEGMENTS 0x0004
#define DEMON_W32_CTX_INTEL_FLOATS 0x0008
#define DEMON_W32_CTX_INTEL_DEBUG 0x0010
#define DEMON_W32_CTX_INTEL_EXTENDED 0x0020
#define DEMON_W32_CTX_INTEL_XSTATE 0x0040
#define DEMON_W32_CTX_X86_ALL (DEMON_W32_CTX_X86 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_DEBUG | \
DEMON_W32_CTX_INTEL_EXTENDED)
#define DEMON_W32_CTX_X64_ALL (DEMON_W32_CTX_X64 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_FLOATS | \
DEMON_W32_CTX_INTEL_DEBUG)
struct TEST_DebugEvent
{
String8 name;
U64 process_id;
U64 thread_id;
HANDLE process;
HANDLE thread;
U64 addr;
DEBUG_EVENT evt;
};
struct TEST_Trap
{
HANDLE process;
U64 address;
};
internal U16
test_w32_real_tag_word_from_xsave(XSAVE_FORMAT *fxsave)
{
U16 result = 0;
U32 top = (fxsave->StatusWord >> 11) & 7;
for (U32 fpr = 0; fpr < 8; fpr += 1){
U32 tag = 3;
if (fxsave->TagWord & (1 << fpr)){
U32 st = (fpr - top)&7;
SYMS_Reg80 *fp = (SYMS_Reg80*)&fxsave->FloatRegisters[st*16];
U16 exponent = fp->sign1_exp15 & bitmask15;
U64 integer_part = fp->int1_frac63 >> 63;
U64 fraction_part = fp->int1_frac63 & bitmask63;
// tag: 0 - normal; 1 - zero; 2 - special
tag = 2;
if (exponent == 0){
if (integer_part == 0 && fraction_part == 0){
tag = 1;
}
}
else if (exponent != bitmask15 && integer_part != 0){
tag = 0;
}
}
result |= tag << (2 * fpr);
}
return(result);
}
internal U16
test_w32_xsave_tag_word_from_real_tag_word(U16 ftw)
{
U16 compact = 0;
for (U32 fpr = 0; fpr < 8; fpr++){
U32 tag = (ftw >> (fpr * 2)) & 3;
if (tag != 3){
compact |= (1 << fpr);
}
}
return(compact);
}
internal B32
test_w32_read_x64_regs(HANDLE thread, SYMS_RegX64 *dst)
{
Temp scratch = scratch_begin(0, 0);
// NOTE(allen): Check available features
U32 feature_mask = GetEnabledXStateFeatures();
B32 avx_enabled = !!(feature_mask & XSTATE_MASK_AVX);
// NOTE(allen): Setup the context
CONTEXT *ctx = 0;
U32 ctx_flags = DEMON_W32_CTX_X64_ALL;
if (avx_enabled){
ctx_flags |= DEMON_W32_CTX_INTEL_XSTATE;
}
DWORD size = 0;
InitializeContext(0, ctx_flags, 0, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
void *ctx_memory = push_array(scratch.arena, U8, size);
if (!InitializeContext(ctx_memory, ctx_flags, &ctx, &size)){
ctx = 0;
}
}
B32 avx_available = false;
if (ctx != 0){
// NOTE(allen): Finish Context Setup
if (avx_enabled){
SetXStateFeaturesMask(ctx, XSTATE_MASK_AVX);
}
// NOTE(allen): Determine what features are available on this particular ctx
// TODO(allen): Experiment carefully with this nonsense.
// Does avx_enabled = avx_available in all circumstances or not?
DWORD64 xstate_flags = 0;
if (GetXStateFeaturesMask(ctx, &xstate_flags)){
if (xstate_flags & XSTATE_MASK_AVX){
avx_available = true;
}
}
}
// get thread context
HANDLE thread_handle = thread;
if (!GetThreadContext(thread_handle, ctx)){
ctx = 0;
}
B32 result = false;
if (ctx != 0){
result = true;
// NOTE(allen): Convert CONTEXT -> SYMS_RegX64
dst->rax.u64 = ctx->Rax;
dst->rcx.u64 = ctx->Rcx;
dst->rdx.u64 = ctx->Rdx;
dst->rbx.u64 = ctx->Rbx;
dst->rsp.u64 = ctx->Rsp;
dst->rbp.u64 = ctx->Rbp;
dst->rsi.u64 = ctx->Rsi;
dst->rdi.u64 = ctx->Rdi;
dst->r8.u64 = ctx->R8;
dst->r9.u64 = ctx->R9;
dst->r10.u64 = ctx->R10;
dst->r11.u64 = ctx->R11;
dst->r12.u64 = ctx->R12;
dst->r13.u64 = ctx->R13;
dst->r14.u64 = ctx->R14;
dst->r15.u64 = ctx->R15;
dst->rip.u64 = ctx->Rip;
dst->cs.u16 = ctx->SegCs;
dst->ds.u16 = ctx->SegDs;
dst->es.u16 = ctx->SegEs;
dst->fs.u16 = ctx->SegFs;
dst->gs.u16 = ctx->SegGs;
dst->ss.u16 = ctx->SegSs;
dst->dr0.u32 = ctx->Dr0;
dst->dr1.u32 = ctx->Dr1;
dst->dr2.u32 = ctx->Dr2;
dst->dr3.u32 = ctx->Dr3;
dst->dr6.u32 = ctx->Dr6;
dst->dr7.u32 = ctx->Dr7;
// NOTE(allen): This bit is "supposed to always be 1" I guess.
// TODO(allen): Not sure what this is all about but I haven't investigated it yet.
// This might be totally not necessary or something.
dst->rflags.u64 = ctx->EFlags | 0x2;
XSAVE_FORMAT *xsave = &ctx->FltSave;
dst->fcw.u16 = xsave->ControlWord;
dst->fsw.u16 = xsave->StatusWord;
dst->ftw.u16 = test_w32_real_tag_word_from_xsave(xsave);
dst->fop.u16 = xsave->ErrorOpcode;
dst->fcs.u16 = xsave->ErrorSelector;
dst->fds.u16 = xsave->DataSelector;
dst->fip.u32 = xsave->ErrorOffset;
dst->fdp.u32 = xsave->DataOffset;
dst->mxcsr.u32 = xsave->MxCsr;
dst->mxcsr_mask.u32 = xsave->MxCsr_Mask;
M128A *float_s = xsave->FloatRegisters;
SYMS_Reg80 *float_d = &dst->fpr0;
for (U32 n = 0; n < 8; n += 1, float_s += 1, float_d += 1){
MemoryCopy(float_d, float_s, sizeof(*float_d));
}
if (!avx_available){
M128A *xmm_s = xsave->XmmRegisters;
SYMS_Reg256 *xmm_d = &dst->ymm0;
for (U32 n = 0; n < 16; n += 1, xmm_s += 1, xmm_d += 1){
MemoryCopy(xmm_d, xmm_s, sizeof(*xmm_s));
}
}
if (avx_available){
DWORD part0_length = 0;
M128A *part0 = (M128A*)LocateXStateFeature(ctx, XSTATE_LEGACY_SSE, &part0_length);
DWORD part1_length = 0;
M128A *part1 = (M128A*)LocateXStateFeature(ctx, XSTATE_AVX, &part1_length);
Assert(part0_length == part1_length);
DWORD count = part0_length/sizeof(part0[0]);
count = ClampTop(count, 16);
SYMS_Reg256 *ymm_d = &dst->ymm0;
for (DWORD i = 0;
i < count;
i += 1, part0 += 1, part1 += 1, ymm_d += 1){
// TODO(allen): Are we writing these out in the right order? Seems weird right?
ymm_d->u64[3] = part0->Low;
ymm_d->u64[2] = part0->High;
ymm_d->u64[1] = part1->Low;
ymm_d->u64[0] = part1->High;
}
}
}
scratch_end(scratch);
return(result);
}
internal B32
test_w32_write_x64_regs(HANDLE thread, SYMS_RegX64 *src)
{
Temp scratch = scratch_begin(0, 0);
// NOTE(allen): Check available features
U32 feature_mask = GetEnabledXStateFeatures();
B32 avx_enabled = !!(feature_mask & XSTATE_MASK_AVX);
// NOTE(allen): Setup the context
CONTEXT *ctx = 0;
U32 ctx_flags = DEMON_W32_CTX_X64_ALL;
if (avx_enabled){
ctx_flags |= DEMON_W32_CTX_INTEL_XSTATE;
}
DWORD size = 0;
InitializeContext(0, ctx_flags, 0, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
void *ctx_memory = push_array(scratch.arena, U8, size);
if (!InitializeContext(ctx_memory, ctx_flags, &ctx, &size)){
ctx = 0;
}
}
B32 avx_available = false;
if (ctx != 0){
// NOTE(allen): Finish Context Setup
if (avx_enabled){
SetXStateFeaturesMask(ctx, XSTATE_MASK_AVX);
}
// NOTE(allen): Determine what features are available on this particular ctx
// TODO(allen): Experiment carefully with this nonsense.
// Does avx_enabled = avx_available in all circumstances or not?
DWORD64 xstate_flags = 0;
if (GetXStateFeaturesMask(ctx, &xstate_flags)){
if (xstate_flags & XSTATE_MASK_AVX){
avx_available = true;
}
}
}
B32 result = false;
if (ctx != 0){
// NOTE(allen): Convert SYMS_RegX64 -> CONTEXT
ctx->ContextFlags = ctx_flags;
ctx->MxCsr = src->mxcsr.u32 & src->mxcsr_mask.u32;
ctx->Rax = src->rax.u64;
ctx->Rcx = src->rcx.u64;
ctx->Rdx = src->rdx.u64;
ctx->Rbx = src->rbx.u64;
ctx->Rsp = src->rsp.u64;
ctx->Rbp = src->rbp.u64;
ctx->Rsi = src->rsi.u64;
ctx->Rdi = src->rdi.u64;
ctx->R8 = src->r8.u64;
ctx->R9 = src->r9.u64;
ctx->R10 = src->r10.u64;
ctx->R11 = src->r11.u64;
ctx->R12 = src->r12.u64;
ctx->R13 = src->r13.u64;
ctx->R14 = src->r14.u64;
ctx->R15 = src->r15.u64;
ctx->Rip = src->rip.u64;
ctx->SegCs = src->cs.u16;
ctx->SegDs = src->ds.u16;
ctx->SegEs = src->es.u16;
ctx->SegFs = src->fs.u16;
ctx->SegGs = src->gs.u16;
ctx->SegSs = src->ss.u16;
ctx->Dr0 = src->dr0.u32;
ctx->Dr1 = src->dr1.u32;
ctx->Dr2 = src->dr2.u32;
ctx->Dr3 = src->dr3.u32;
ctx->Dr6 = src->dr6.u32;
ctx->Dr7 = src->dr7.u32;
ctx->EFlags = src->rflags.u64;
XSAVE_FORMAT *fxsave = &ctx->FltSave;
fxsave->ControlWord = src->fcw.u16;
fxsave->StatusWord = src->fsw.u16;
fxsave->TagWord = test_w32_xsave_tag_word_from_real_tag_word(src->ftw.u16);
fxsave->ErrorOpcode = src->fop.u16;
fxsave->ErrorSelector = src->fcs.u16;
fxsave->DataSelector = src->fds.u16;
fxsave->ErrorOffset = src->fip.u32;
fxsave->DataOffset = src->fdp.u32;
M128A *float_d = fxsave->FloatRegisters;
SYMS_Reg80 *float_s = &src->fpr0;
for (U32 n = 0;
n < 8;
n += 1, float_s += 1, float_d += 1){
MemoryCopy(float_d, float_s, 10);
}
if (!avx_available){
M128A *xmm_d = fxsave->XmmRegisters;
SYMS_Reg256 *xmm_s = &src->ymm0;
for (U32 n = 0;
n < 8;
n += 1, xmm_d += 1, xmm_s += 1){
MemoryCopy(xmm_d, xmm_s, sizeof(*xmm_d));
}
}
if (avx_available){
DWORD part0_length = 0;
M128A *part0 = (M128A*)LocateXStateFeature(ctx, XSTATE_LEGACY_SSE, &part0_length);
DWORD part1_length = 0;
M128A *part1 = (M128A*)LocateXStateFeature(ctx, XSTATE_AVX, &part1_length);
Assert(part0_length == part1_length);
DWORD count = part0_length/sizeof(part0[0]);
count = ClampTop(count, 16);
SYMS_Reg256 *ymm_d = &src->ymm0;
for (DWORD i = 0;
i < count;
i += 1, part0 += 1, part1 += 1, ymm_d += 1){
// TODO(allen): Are we writing these out in the right order? Seems weird right?
part0->Low = ymm_d->u64[3];
part0->High = ymm_d->u64[2];
part1->Low = ymm_d->u64[1];
part1->High = ymm_d->u64[0];
}
}
//- set thread context
HANDLE thread_handle = thread;
if (SetThreadContext(thread_handle, ctx)){
result = true;
}
}
scratch_end(scratch);
return(result);
}
internal B32
test_w32_read_memory(HANDLE process_handle, void *dst, U64 src_address, U64 size)
{
B32 result = true;
U8 *ptr = (U8*)dst;
U8 *opl = ptr + size;
U64 cursor = src_address;
for (;ptr < opl;){
SIZE_T to_read = (SIZE_T)(opl - ptr);
SIZE_T actual_read = 0;
if (!ReadProcessMemory(process_handle, (LPCVOID)cursor, ptr, to_read, &actual_read)){
result = false;
break;
}
ptr += actual_read;
cursor += actual_read;
}
return(result);
}
internal B32
test_w32_write_memory(HANDLE process_handle, U64 dst_address, void *src, U64 size)
{
B32 result = true;
U8 *ptr = (U8*)src;
U8 *opl = ptr + size;
U64 cursor = dst_address;
for (;ptr < opl;){
SIZE_T to_write = (SIZE_T)(opl - ptr);
SIZE_T actual_write = 0;
if (!WriteProcessMemory(process_handle, (LPVOID)cursor, ptr, to_write, &actual_write)){
result = false;
break;
}
ptr += actual_write;
cursor += actual_write;
}
return(result);
}
internal B32
test_launch_process(OS_LaunchOptions *options)
{
B32 result = false;
Temp scratch = scratch_begin(0, 0);
StringJoin join_params = {0};
join_params.pre = str8_lit("\"");
join_params.sep = str8_lit("\" \"");
join_params.post = str8_lit("\"");
String8 cmd = str8_list_join(scratch.arena, &options->cmd_line, &join_params);
StringJoin join_params2 = {0};
join_params2.sep = str8_lit("\0");
join_params2.post = str8_lit("\0");
String8 env = str8_list_join(scratch.arena, &options->env, &join_params2);
String16 cmd16 = str16_from_8(scratch.arena, cmd);
String16 dir16 = str16_from_8(scratch.arena, options->path);
String16 env16 = str16_from_8(scratch.arena, env);
DWORD access_flags = PROCESS_QUERY_INFORMATION | DEBUG_PROCESS | PROCESS_VM_READ | PROCESS_VM_WRITE;
STARTUPINFOW startup_info = {sizeof(startup_info)};
PROCESS_INFORMATION process_info = {0};
if (CreateProcessW(0, (WCHAR*)cmd16.str, 0, 0, 0, access_flags, (WCHAR*)env16.str, (WCHAR*)dir16.str,
&startup_info, &process_info))
{
CloseHandle(process_info.hProcess);
CloseHandle(process_info.hThread);
result = true;
}
scratch_end(scratch);
return(result);
}
global HANDLE g_process_1 = 0;
global DWORD g_process_id_1 = 0;
global U64 g_process_injection_addr_1 = 0;
global HANDLE g_process_2 = 0;
global DWORD g_process_id_2 = 0;
internal B32
test_w32_inject_thread(HANDLE process, U64 start_address)
{
B32 result = false;
LPTHREAD_START_ROUTINE start = (LPTHREAD_START_ROUTINE)start_address;
HANDLE thread = CreateRemoteThread(process, 0, 0, start, 0, 0, 0);
if(thread != 0)
{
CloseHandle(thread);
result = true;
}
return result;
}
internal void
test_halt(void)
{
test_w32_inject_thread(g_process_1, g_process_injection_addr_1);
}
internal TEST_DebugEvent
test_run_process(HANDLE step_thread, HANDLE suspend_thread, U64 traps_count, TEST_Trap *traps)
{
Temp scratch = scratch_begin(0, 0);
TEST_DebugEvent result = {0};
//- rjf: freeze thread
if(suspend_thread)
{
DWORD result = SuspendThread(suspend_thread);
DWORD error = GetLastError();
int x = 0;
}
//- rjf: write traps
U8 *trap_swap_bytes = push_array_no_zero(scratch.arena, U8, traps_count);
{
TEST_Trap *trap = traps;
for(U64 i = 0; i < traps_count; i += 1, trap += 1)
{
if(test_w32_read_memory(trap->process, trap_swap_bytes + i, trap->address, 1))
{
U8 int3 = 0xCC;
test_w32_write_memory(trap->process, trap->address, &int3, 1);
}
else
{
trap_swap_bytes[i] = 0xCC;
}
}
}
//- rjf: set single step bit
if(step_thread != 0)
{
SYMS_RegX64 regs = {0};
test_w32_read_x64_regs(step_thread, &regs);
regs.rflags.u64 |= 0x100;
test_w32_write_x64_regs(step_thread, &regs);
}
//- rjf: continue
local_persist B32 need_resume = 0;
local_persist DWORD resume_pid = 0;
local_persist DWORD resume_tid = 0;
if(need_resume)
{
need_resume = 0;
ContinueDebugEvent(resume_pid, resume_tid, DBG_CONTINUE);
}
//- rjf: get event
DEBUG_EVENT evt = {0};
if(WaitForDebugEvent(&evt, INFINITE))
{
need_resume = 1;
resume_pid = evt.dwProcessId;
resume_tid = evt.dwThreadId;
result.evt = evt;
switch(evt.dwDebugEventCode)
{
default:break;
case CREATE_PROCESS_DEBUG_EVENT:
{
result.name = str8_lit("create process");
result.process_id = evt.dwProcessId;
result.process = evt.u.CreateProcessInfo.hProcess;
result.thread_id = evt.dwThreadId;
result.thread = evt.u.CreateProcessInfo.hThread;
if(g_process_1 == 0)
{
g_process_1 = result.process;
g_process_id_1 = result.process_id;
// injection memory
{
U8 injection_code[64];
injection_code[0] = 0xCC;
injection_code[1] = 0xC3;
for (U64 i = 2; i < 64; i += 1){
injection_code[i] = 0xCC;
}
U64 injection_size = 64;
U64 injection_address = (U64)VirtualAllocEx(g_process_1, 0, injection_size, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE);
test_w32_write_memory(g_process_1, injection_address, injection_code, sizeof(injection_code));
g_process_injection_addr_1 = injection_address;
}
}
else
{
g_process_2 = result.process;
g_process_id_2 = result.process_id;
}
}break;
case EXIT_PROCESS_DEBUG_EVENT:
{
result.name = str8_lit("exit process");
result.process_id = evt.dwProcessId;
}break;
case CREATE_THREAD_DEBUG_EVENT:
{
result.name = str8_lit("create thread");
result.thread_id = evt.dwThreadId;
result.thread = evt.u.CreateThread.hThread;
}break;
case EXIT_THREAD_DEBUG_EVENT:
{
result.name = str8_lit("exit thread");
result.thread_id = evt.dwThreadId;
}break;
case LOAD_DLL_DEBUG_EVENT:
{
result.name = str8_lit("load dll");
}break;
case UNLOAD_DLL_DEBUG_EVENT:
{
result.name = str8_lit("unload dll");
}break;
case EXCEPTION_DEBUG_EVENT:
{
result.name = str8_lit("exception");
EXCEPTION_DEBUG_INFO *edi = &evt.u.Exception;
EXCEPTION_RECORD *exception = &edi->ExceptionRecord;
switch(exception->ExceptionCode)
{
case DEMON_W32_EXCEPTION_BREAKPOINT:
{
result.name = str8_lit("breakpoint");
result.addr = (U64)exception->ExceptionAddress;
}break;
case DEMON_W32_EXCEPTION_SINGLE_STEP:
{
result.name = str8_lit("single_step");
}break;
case DEMON_W32_EXCEPTION_THROW:
{
result.name = str8_lit("exception throw");
}break;
case DEMON_W32_EXCEPTION_ACCESS_VIOLATION:
case DEMON_W32_EXCEPTION_IN_PAGE_ERROR:
{
result.name = str8_lit("exception access violation");
}break;
default:
{
}break;
}
}break;
case OUTPUT_DEBUG_STRING_EVENT:
{
Temp scratch = scratch_begin(0, 0);
result.name = str8_lit("output debug string");
U64 string_address = (U64)evt.u.DebugString.lpDebugStringData;
U64 string_size = (U64)evt.u.DebugString.nDebugStringLength;
// TODO(allen): is the string in UTF-8 or UTF-16?
U8 *buffer = push_array_no_zero(scratch.arena, U8, string_size + 1);
test_w32_read_memory(g_process_id_1 == evt.dwProcessId ? g_process_1 : g_process_2, buffer, string_address, string_size);
buffer[string_size] = 0;
printf("%s\n", buffer);
scratch_end(scratch);
}break;
case RIP_EVENT:
{
result.name = str8_lit("rip event");
}break;
}
}
//- rjf: set single step bit
if(step_thread != 0)
{
SYMS_RegX64 regs = {0};
test_w32_read_x64_regs(step_thread, &regs);
regs.rflags.u64 &= ~0x100;
test_w32_write_x64_regs(step_thread, &regs);
}
//- rjf: unset traps
{
TEST_Trap *trap = traps;
for(U64 i = 0; i < traps_count; i += 1, trap += 1)
{
U8 og_byte = trap_swap_bytes[i];
if(og_byte != 0xCC)
{
test_w32_write_memory(trap->process, trap->address, &og_byte, 1);
}
}
}
//- rjf: resume thread
if(suspend_thread)
{
ResumeThread(suspend_thread);
}
scratch_end(scratch);
return result;
}
internal DWORD
test_halter_thread(void *params)
{
HANDLE original_process_handle = params;
Sleep(1500);
test_halt();
#if 0
DWORD process_id = GetProcessId(original_process_handle);
HANDLE elevated_process_handle = OpenProcess(PROCESS_SUSPEND_RESUME, 0, process_id);
LONG result = NtSuspendProcess(elevated_process_handle);
CloseHandle(elevated_process_handle);
DebugBreakProcess(process);
#endif
return 0;
}
int
main(int argument_count, char **arguments)
{
os_init(argument_count, arguments);
Arena *arena = arena_alloc();
NtSuspendProcess = (NtSuspendProcessFunction *)GetProcAddress(GetModuleHandle("ntdll"), "NtSuspendProcess");
// rjf: launch
{
OS_LaunchOptions opts = {0};
opts.path = os_get_path(arena, OS_SystemPath_Current);
str8_list_push(arena, &opts.cmd_line, str8_lit("R:\\projects\\debugger\\build\\mule_loop.exe"));
B32 launch_good = test_launch_process(&opts);
int x = 0;
}
// rjf: get process/thread handles
HANDLE process = 0;
HANDLE thread1 = 0;
U64 thread1_id = 0;
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0);
if(evt.process)
{
process = evt.process;
}
if(evt.thread)
{
thread1 = evt.thread;
thread1_id = evt.thread_id;
}
if(process != 0 && thread1 != 0)
{
break;
}
}
}
// rjf: get first breakpoint
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0);
if(evt.evt.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
break;
}
}
}
// rjf: launch halter thread
DWORD halter_id = 0;
{
CreateThread(0, 0, test_halter_thread, process, 0, &halter_id);
}
// rjf: run + wait for event
for(;;)
{
TEST_DebugEvent evt = test_run_process(0, 0, 0, 0);
int x = 0;
}
#if 0
//- rjf: run until 2nd thread starts up
HANDLE thread2 = 0;
U64 thread2_id = 0;
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0/*ArrayCount(traps), traps*/);
if(evt.thread)
{
thread2 = evt.thread;
thread2_id = evt.thread_id;
break;
}
}
}
//- rjf: wait for first output string
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0);
if(evt.evt.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)
{
break;
}
}
}
//- rjf: wait for bps
{
// U64 thread1_stop_vaddr = 0x0000000140001119;
// U64 thread2_stop_vaddr = 0x00000001400010C8;
// TEST_Trap traps[] =
{
// {process, thread1_stop_vaddr},
//{process, thread2_stop_vaddr},
};
TEST_DebugEvent evt = {0};
//for(;;)
{
evt = test_run_process(0, thread2, 0, 0/*ArrayCount(traps), traps*/);
int x = 0;
}
for(;;) {}
}
#endif
}
-874
View File
@@ -1,874 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#include <windows.h>
#include "base/base_inc.h"
#include "os/os_inc.h"
#include "syms_helpers/syms_internal_overrides.h"
#include "syms/syms_inc.h"
#include "syms_helpers/syms_helpers.h"
#include "base/base_inc.c"
#include "os/os_inc.c"
#include "syms_helpers/syms_internal_overrides.c"
#include "syms/syms_inc.c"
#include "syms_helpers/syms_helpers.c"
////////////////////////////////
// NOTE(allen): Win32 Demon Exceptions
#define DEMON_W32_EXCEPTION_BREAKPOINT 0x80000003u
#define DEMON_W32_EXCEPTION_SINGLE_STEP 0x80000004u
#define DEMON_W32_EXCEPTION_LONG_JUMP 0x80000026u
#define DEMON_W32_EXCEPTION_ACCESS_VIOLATION 0xC0000005u
#define DEMON_W32_EXCEPTION_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define DEMON_W32_EXCEPTION_DATA_TYPE_MISALIGNMENT 0x80000002u
#define DEMON_W32_EXCEPTION_GUARD_PAGE_VIOLATION 0x80000001u
#define DEMON_W32_EXCEPTION_FLT_DENORMAL_OPERAND 0xC000008Du
#define DEMON_W32_EXCEPTION_FLT_DEVIDE_BY_ZERO 0xC000008Eu
#define DEMON_W32_EXCEPTION_FLT_INEXACT_RESULT 0xC000008Fu
#define DEMON_W32_EXCEPTION_FLT_INVALID_OPERATION 0xC0000090u
#define DEMON_W32_EXCEPTION_FLT_OVERFLOW 0xC0000091u
#define DEMON_W32_EXCEPTION_FLT_STACK_CHECK 0xC0000092u
#define DEMON_W32_EXCEPTION_FLT_UNDERFLOW 0xC0000093u
#define DEMON_W32_EXCEPTION_INT_DIVIDE_BY_ZERO 0xC0000094u
#define DEMON_W32_EXCEPTION_INT_OVERFLOW 0xC0000095u
#define DEMON_W32_EXCEPTION_PRIVILEGED_INSTRUCTION 0xC0000096u
#define DEMON_W32_EXCEPTION_ILLEGAL_INSTRUCTION 0xC000001Du
#define DEMON_W32_EXCEPTION_IN_PAGE_ERROR 0xC0000006u
#define DEMON_W32_EXCEPTION_INVALID_DISPOSITION 0xC0000026u
#define DEMON_W32_EXCEPTION_NONCONTINUABLE 0xC0000025u
#define DEMON_W32_EXCEPTION_STACK_OVERFLOW 0xC00000FDu
#define DEMON_W32_EXCEPTION_INVALID_HANDLE 0xC0000008u
#define DEMON_W32_EXCEPTION_UNWIND_CONSOLIDATE 0x80000029u
#define DEMON_W32_EXCEPTION_DLL_NOT_FOUND 0xC0000135u
#define DEMON_W32_EXCEPTION_ORDINAL_NOT_FOUND 0xC0000138u
#define DEMON_W32_EXCEPTION_ENTRY_POINT_NOT_FOUND 0xC0000139u
#define DEMON_W32_EXCEPTION_DLL_INIT_FAILED 0xC0000142u
#define DEMON_W32_EXCEPTION_CONTROL_C_EXIT 0xC000013Au
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_FAULTS 0xC00002B4u
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_TRAPS 0xC00002B5u
#define DEMON_W32_EXCEPTION_NAT_CONSUMPTION 0xC00002C9u
#define DEMON_W32_EXCEPTION_HEAP_CORRUPTION 0xC0000374u
#define DEMON_W32_EXCEPTION_STACK_BUFFER_OVERRUN 0xC0000409u
#define DEMON_W32_EXCEPTION_INVALID_CRUNTIME_PARAM 0xC0000417u
#define DEMON_W32_EXCEPTION_ASSERT_FAILURE 0xC0000420u
#define DEMON_W32_EXCEPTION_NO_MEMORY 0xC0000017u
#define DEMON_W32_EXCEPTION_THROW 0xE06D7363u
////////////////////////////////
// NOTE(allen): Win32 Demon Register API Codes
#define DEMON_W32_CTX_X86 0x00010000
#define DEMON_W32_CTX_X64 0x00100000
#define DEMON_W32_CTX_INTEL_CONTROL 0x0001
#define DEMON_W32_CTX_INTEL_INTEGER 0x0002
#define DEMON_W32_CTX_INTEL_SEGMENTS 0x0004
#define DEMON_W32_CTX_INTEL_FLOATS 0x0008
#define DEMON_W32_CTX_INTEL_DEBUG 0x0010
#define DEMON_W32_CTX_INTEL_EXTENDED 0x0020
#define DEMON_W32_CTX_INTEL_XSTATE 0x0040
#define DEMON_W32_CTX_X86_ALL (DEMON_W32_CTX_X86 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_DEBUG | \
DEMON_W32_CTX_INTEL_EXTENDED)
#define DEMON_W32_CTX_X64_ALL (DEMON_W32_CTX_X64 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_FLOATS | \
DEMON_W32_CTX_INTEL_DEBUG)
struct TEST_DebugEvent
{
String8 name;
U64 process_id;
U64 thread_id;
HANDLE process;
HANDLE thread;
U64 addr;
DEBUG_EVENT evt;
};
struct TEST_Trap
{
HANDLE process;
U64 address;
};
internal U16
test_w32_real_tag_word_from_xsave(XSAVE_FORMAT *fxsave)
{
U16 result = 0;
U32 top = (fxsave->StatusWord >> 11) & 7;
for (U32 fpr = 0; fpr < 8; fpr += 1){
U32 tag = 3;
if (fxsave->TagWord & (1 << fpr)){
U32 st = (fpr - top)&7;
SYMS_Reg80 *fp = (SYMS_Reg80*)&fxsave->FloatRegisters[st*16];
U16 exponent = fp->sign1_exp15 & bitmask15;
U64 integer_part = fp->int1_frac63 >> 63;
U64 fraction_part = fp->int1_frac63 & bitmask63;
// tag: 0 - normal; 1 - zero; 2 - special
tag = 2;
if (exponent == 0){
if (integer_part == 0 && fraction_part == 0){
tag = 1;
}
}
else if (exponent != bitmask15 && integer_part != 0){
tag = 0;
}
}
result |= tag << (2 * fpr);
}
return(result);
}
internal U16
test_w32_xsave_tag_word_from_real_tag_word(U16 ftw)
{
U16 compact = 0;
for (U32 fpr = 0; fpr < 8; fpr++){
U32 tag = (ftw >> (fpr * 2)) & 3;
if (tag != 3){
compact |= (1 << fpr);
}
}
return(compact);
}
internal B32
test_w32_read_x64_regs(HANDLE thread, SYMS_RegX64 *dst)
{
Temp scratch = scratch_begin(0, 0);
// NOTE(allen): Check available features
U32 feature_mask = GetEnabledXStateFeatures();
B32 avx_enabled = !!(feature_mask & XSTATE_MASK_AVX);
// NOTE(allen): Setup the context
CONTEXT *ctx = 0;
U32 ctx_flags = DEMON_W32_CTX_X64_ALL;
if (avx_enabled){
ctx_flags |= DEMON_W32_CTX_INTEL_XSTATE;
}
DWORD size = 0;
InitializeContext(0, ctx_flags, 0, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
void *ctx_memory = push_array(scratch.arena, U8, size);
if (!InitializeContext(ctx_memory, ctx_flags, &ctx, &size)){
ctx = 0;
}
}
B32 avx_available = false;
if (ctx != 0){
// NOTE(allen): Finish Context Setup
if (avx_enabled){
SetXStateFeaturesMask(ctx, XSTATE_MASK_AVX);
}
// NOTE(allen): Determine what features are available on this particular ctx
// TODO(allen): Experiment carefully with this nonsense.
// Does avx_enabled = avx_available in all circumstances or not?
DWORD64 xstate_flags = 0;
if (GetXStateFeaturesMask(ctx, &xstate_flags)){
if (xstate_flags & XSTATE_MASK_AVX){
avx_available = true;
}
}
}
// get thread context
HANDLE thread_handle = thread;
if (!GetThreadContext(thread_handle, ctx)){
ctx = 0;
}
B32 result = false;
if (ctx != 0){
result = true;
// NOTE(allen): Convert CONTEXT -> SYMS_RegX64
dst->rax.u64 = ctx->Rax;
dst->rcx.u64 = ctx->Rcx;
dst->rdx.u64 = ctx->Rdx;
dst->rbx.u64 = ctx->Rbx;
dst->rsp.u64 = ctx->Rsp;
dst->rbp.u64 = ctx->Rbp;
dst->rsi.u64 = ctx->Rsi;
dst->rdi.u64 = ctx->Rdi;
dst->r8.u64 = ctx->R8;
dst->r9.u64 = ctx->R9;
dst->r10.u64 = ctx->R10;
dst->r11.u64 = ctx->R11;
dst->r12.u64 = ctx->R12;
dst->r13.u64 = ctx->R13;
dst->r14.u64 = ctx->R14;
dst->r15.u64 = ctx->R15;
dst->rip.u64 = ctx->Rip;
dst->cs.u16 = ctx->SegCs;
dst->ds.u16 = ctx->SegDs;
dst->es.u16 = ctx->SegEs;
dst->fs.u16 = ctx->SegFs;
dst->gs.u16 = ctx->SegGs;
dst->ss.u16 = ctx->SegSs;
dst->dr0.u32 = ctx->Dr0;
dst->dr1.u32 = ctx->Dr1;
dst->dr2.u32 = ctx->Dr2;
dst->dr3.u32 = ctx->Dr3;
dst->dr6.u32 = ctx->Dr6;
dst->dr7.u32 = ctx->Dr7;
// NOTE(allen): This bit is "supposed to always be 1" I guess.
// TODO(allen): Not sure what this is all about but I haven't investigated it yet.
// This might be totally not necessary or something.
dst->rflags.u64 = ctx->EFlags | 0x2;
XSAVE_FORMAT *xsave = &ctx->FltSave;
dst->fcw.u16 = xsave->ControlWord;
dst->fsw.u16 = xsave->StatusWord;
dst->ftw.u16 = test_w32_real_tag_word_from_xsave(xsave);
dst->fop.u16 = xsave->ErrorOpcode;
dst->fcs.u16 = xsave->ErrorSelector;
dst->fds.u16 = xsave->DataSelector;
dst->fip.u32 = xsave->ErrorOffset;
dst->fdp.u32 = xsave->DataOffset;
dst->mxcsr.u32 = xsave->MxCsr;
dst->mxcsr_mask.u32 = xsave->MxCsr_Mask;
M128A *float_s = xsave->FloatRegisters;
SYMS_Reg80 *float_d = &dst->fpr0;
for (U32 n = 0; n < 8; n += 1, float_s += 1, float_d += 1){
MemoryCopy(float_d, float_s, sizeof(*float_d));
}
if (!avx_available){
M128A *xmm_s = xsave->XmmRegisters;
SYMS_Reg256 *xmm_d = &dst->ymm0;
for (U32 n = 0; n < 16; n += 1, xmm_s += 1, xmm_d += 1){
MemoryCopy(xmm_d, xmm_s, sizeof(*xmm_s));
}
}
if (avx_available){
DWORD part0_length = 0;
M128A *part0 = (M128A*)LocateXStateFeature(ctx, XSTATE_LEGACY_SSE, &part0_length);
DWORD part1_length = 0;
M128A *part1 = (M128A*)LocateXStateFeature(ctx, XSTATE_AVX, &part1_length);
Assert(part0_length == part1_length);
DWORD count = part0_length/sizeof(part0[0]);
count = ClampTop(count, 16);
SYMS_Reg256 *ymm_d = &dst->ymm0;
for (DWORD i = 0;
i < count;
i += 1, part0 += 1, part1 += 1, ymm_d += 1){
// TODO(allen): Are we writing these out in the right order? Seems weird right?
ymm_d->u64[3] = part0->Low;
ymm_d->u64[2] = part0->High;
ymm_d->u64[1] = part1->Low;
ymm_d->u64[0] = part1->High;
}
}
}
scratch_end(scratch);
return(result);
}
internal B32
test_w32_write_x64_regs(HANDLE thread, SYMS_RegX64 *src)
{
Temp scratch = scratch_begin(0, 0);
// NOTE(allen): Check available features
U32 feature_mask = GetEnabledXStateFeatures();
B32 avx_enabled = !!(feature_mask & XSTATE_MASK_AVX);
// NOTE(allen): Setup the context
CONTEXT *ctx = 0;
U32 ctx_flags = DEMON_W32_CTX_X64_ALL;
if (avx_enabled){
ctx_flags |= DEMON_W32_CTX_INTEL_XSTATE;
}
DWORD size = 0;
InitializeContext(0, ctx_flags, 0, &size);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
void *ctx_memory = push_array(scratch.arena, U8, size);
if (!InitializeContext(ctx_memory, ctx_flags, &ctx, &size)){
ctx = 0;
}
}
B32 avx_available = false;
if (ctx != 0){
// NOTE(allen): Finish Context Setup
if (avx_enabled){
SetXStateFeaturesMask(ctx, XSTATE_MASK_AVX);
}
// NOTE(allen): Determine what features are available on this particular ctx
// TODO(allen): Experiment carefully with this nonsense.
// Does avx_enabled = avx_available in all circumstances or not?
DWORD64 xstate_flags = 0;
if (GetXStateFeaturesMask(ctx, &xstate_flags)){
if (xstate_flags & XSTATE_MASK_AVX){
avx_available = true;
}
}
}
B32 result = false;
if (ctx != 0){
// NOTE(allen): Convert SYMS_RegX64 -> CONTEXT
ctx->ContextFlags = ctx_flags;
ctx->MxCsr = src->mxcsr.u32 & src->mxcsr_mask.u32;
ctx->Rax = src->rax.u64;
ctx->Rcx = src->rcx.u64;
ctx->Rdx = src->rdx.u64;
ctx->Rbx = src->rbx.u64;
ctx->Rsp = src->rsp.u64;
ctx->Rbp = src->rbp.u64;
ctx->Rsi = src->rsi.u64;
ctx->Rdi = src->rdi.u64;
ctx->R8 = src->r8.u64;
ctx->R9 = src->r9.u64;
ctx->R10 = src->r10.u64;
ctx->R11 = src->r11.u64;
ctx->R12 = src->r12.u64;
ctx->R13 = src->r13.u64;
ctx->R14 = src->r14.u64;
ctx->R15 = src->r15.u64;
ctx->Rip = src->rip.u64;
ctx->SegCs = src->cs.u16;
ctx->SegDs = src->ds.u16;
ctx->SegEs = src->es.u16;
ctx->SegFs = src->fs.u16;
ctx->SegGs = src->gs.u16;
ctx->SegSs = src->ss.u16;
ctx->Dr0 = src->dr0.u32;
ctx->Dr1 = src->dr1.u32;
ctx->Dr2 = src->dr2.u32;
ctx->Dr3 = src->dr3.u32;
ctx->Dr6 = src->dr6.u32;
ctx->Dr7 = src->dr7.u32;
ctx->EFlags = src->rflags.u64;
XSAVE_FORMAT *fxsave = &ctx->FltSave;
fxsave->ControlWord = src->fcw.u16;
fxsave->StatusWord = src->fsw.u16;
fxsave->TagWord = test_w32_xsave_tag_word_from_real_tag_word(src->ftw.u16);
fxsave->ErrorOpcode = src->fop.u16;
fxsave->ErrorSelector = src->fcs.u16;
fxsave->DataSelector = src->fds.u16;
fxsave->ErrorOffset = src->fip.u32;
fxsave->DataOffset = src->fdp.u32;
M128A *float_d = fxsave->FloatRegisters;
SYMS_Reg80 *float_s = &src->fpr0;
for (U32 n = 0;
n < 8;
n += 1, float_s += 1, float_d += 1){
MemoryCopy(float_d, float_s, 10);
}
if (!avx_available){
M128A *xmm_d = fxsave->XmmRegisters;
SYMS_Reg256 *xmm_s = &src->ymm0;
for (U32 n = 0;
n < 8;
n += 1, xmm_d += 1, xmm_s += 1){
MemoryCopy(xmm_d, xmm_s, sizeof(*xmm_d));
}
}
if (avx_available){
DWORD part0_length = 0;
M128A *part0 = (M128A*)LocateXStateFeature(ctx, XSTATE_LEGACY_SSE, &part0_length);
DWORD part1_length = 0;
M128A *part1 = (M128A*)LocateXStateFeature(ctx, XSTATE_AVX, &part1_length);
Assert(part0_length == part1_length);
DWORD count = part0_length/sizeof(part0[0]);
count = ClampTop(count, 16);
SYMS_Reg256 *ymm_d = &src->ymm0;
for (DWORD i = 0;
i < count;
i += 1, part0 += 1, part1 += 1, ymm_d += 1){
// TODO(allen): Are we writing these out in the right order? Seems weird right?
part0->Low = ymm_d->u64[3];
part0->High = ymm_d->u64[2];
part1->Low = ymm_d->u64[1];
part1->High = ymm_d->u64[0];
}
}
//- set thread context
HANDLE thread_handle = thread;
if (SetThreadContext(thread_handle, ctx)){
result = true;
}
}
scratch_end(scratch);
return(result);
}
internal B32
test_w32_read_memory(HANDLE process_handle, void *dst, U64 src_address, U64 size)
{
B32 result = true;
U8 *ptr = (U8*)dst;
U8 *opl = ptr + size;
U64 cursor = src_address;
for (;ptr < opl;){
SIZE_T to_read = (SIZE_T)(opl - ptr);
SIZE_T actual_read = 0;
if (!ReadProcessMemory(process_handle, (LPCVOID)cursor, ptr, to_read, &actual_read)){
result = false;
break;
}
ptr += actual_read;
cursor += actual_read;
}
return(result);
}
internal B32
test_w32_write_memory(HANDLE process_handle, U64 dst_address, void *src, U64 size)
{
B32 result = true;
U8 *ptr = (U8*)src;
U8 *opl = ptr + size;
U64 cursor = dst_address;
for (;ptr < opl;){
SIZE_T to_write = (SIZE_T)(opl - ptr);
SIZE_T actual_write = 0;
if (!WriteProcessMemory(process_handle, (LPVOID)cursor, ptr, to_write, &actual_write)){
result = false;
break;
}
ptr += actual_write;
cursor += actual_write;
}
return(result);
}
internal B32
test_launch_process(OS_LaunchOptions *options)
{
B32 result = false;
Temp scratch = scratch_begin(0, 0);
StringJoin join_params = {0};
join_params.pre = str8_lit("\"");
join_params.sep = str8_lit("\" \"");
join_params.post = str8_lit("\"");
String8 cmd = str8_list_join(scratch.arena, &options->cmd_line, &join_params);
StringJoin join_params2 = {0};
join_params2.sep = str8_lit("\0");
join_params2.post = str8_lit("\0");
String8 env = str8_list_join(scratch.arena, &options->env, &join_params2);
String16 cmd16 = str16_from_8(scratch.arena, cmd);
String16 dir16 = str16_from_8(scratch.arena, options->path);
String16 env16 = str16_from_8(scratch.arena, env);
DWORD access_flags = PROCESS_QUERY_INFORMATION | DEBUG_PROCESS | PROCESS_VM_READ | PROCESS_VM_WRITE;
STARTUPINFOW startup_info = {sizeof(startup_info)};
PROCESS_INFORMATION process_info = {0};
if (CreateProcessW(0, (WCHAR*)cmd16.str, 0, 0, 0, access_flags, (WCHAR*)env16.str, (WCHAR*)dir16.str,
&startup_info, &process_info))
{
CloseHandle(process_info.hProcess);
CloseHandle(process_info.hThread);
result = true;
}
scratch_end(scratch);
return(result);
}
global HANDLE g_process = 0;
global DWORD g_process_id = 0;
global HANDLE g_thread1 = 0;
global DWORD g_thread1_id = 0;
global HANDLE g_thread2 = 0;
global DWORD g_thread2_id = 0;
internal TEST_DebugEvent
test_run_process(HANDLE step_thread, HANDLE suspend_thread, U64 traps_count, TEST_Trap *traps)
{
Temp scratch = scratch_begin(0, 0);
TEST_DebugEvent result = {0};
//- rjf: freeze thread
if(suspend_thread)
{
DWORD result = SuspendThread(suspend_thread);
DWORD error = GetLastError();
int x = 0;
}
//- rjf: write traps
U8 *trap_swap_bytes = push_array_no_zero(scratch.arena, U8, traps_count);
{
TEST_Trap *trap = traps;
for(U64 i = 0; i < traps_count; i += 1, trap += 1)
{
if(test_w32_read_memory(trap->process, trap_swap_bytes + i, trap->address, 1))
{
U8 int3 = 0xCC;
test_w32_write_memory(trap->process, trap->address, &int3, 1);
}
else
{
trap_swap_bytes[i] = 0xCC;
}
}
}
//- rjf: set single step bit
if(step_thread != 0)
{
SYMS_RegX64 regs = {0};
test_w32_read_x64_regs(step_thread, &regs);
regs.rflags.u64 |= 0x100;
test_w32_write_x64_regs(step_thread, &regs);
}
//- rjf: continue
local_persist B32 need_resume = 0;
local_persist DWORD resume_pid = 0;
local_persist DWORD resume_tid = 0;
if(need_resume)
{
need_resume = 0;
ContinueDebugEvent(resume_pid, resume_tid, DBG_CONTINUE);
}
//- rjf: get event
DEBUG_EVENT evt = {0};
if(WaitForDebugEvent(&evt, INFINITE))
{
need_resume = 1;
resume_pid = evt.dwProcessId;
resume_tid = evt.dwThreadId;
result.evt = evt;
switch(evt.dwDebugEventCode)
{
default:break;
case CREATE_PROCESS_DEBUG_EVENT:
{
result.name = str8_lit("create process");
result.process_id = evt.dwProcessId;
result.process = evt.u.CreateProcessInfo.hProcess;
result.thread_id = evt.dwThreadId;
result.thread = evt.u.CreateProcessInfo.hThread;
if(g_process == 0)
{
g_process = result.process;
g_process_id = result.process_id;
}
if(g_thread1 == 0)
{
g_thread1 = result.thread;
g_thread1_id = result.thread_id;
}
}break;
case EXIT_PROCESS_DEBUG_EVENT:
{
result.name = str8_lit("exit process");
result.process_id = evt.dwProcessId;
}break;
case CREATE_THREAD_DEBUG_EVENT:
{
result.name = str8_lit("create thread");
result.thread_id = evt.dwThreadId;
result.thread = evt.u.CreateThread.hThread;
g_thread2 = result.thread;
g_thread2_id = result.thread_id;
}break;
case EXIT_THREAD_DEBUG_EVENT:
{
result.name = str8_lit("exit thread");
result.thread_id = evt.dwThreadId;
}break;
case LOAD_DLL_DEBUG_EVENT:
{
result.name = str8_lit("load dll");
}break;
case UNLOAD_DLL_DEBUG_EVENT:
{
result.name = str8_lit("unload dll");
}break;
case EXCEPTION_DEBUG_EVENT:
{
result.name = str8_lit("exception");
EXCEPTION_DEBUG_INFO *edi = &evt.u.Exception;
EXCEPTION_RECORD *exception = &edi->ExceptionRecord;
switch(exception->ExceptionCode)
{
case DEMON_W32_EXCEPTION_BREAKPOINT:
{
result.name = str8_lit("breakpoint");
result.addr = (U64)exception->ExceptionAddress;
local_persist B32 did_first_bp = 0;
if(did_first_bp != 0)
{
HANDLE thread = evt.dwThreadId == g_thread1_id ? g_thread1 : g_thread2;
SYMS_RegX64 regs = {0};
test_w32_read_x64_regs(thread, &regs);
regs.rip.u64 = result.addr;
test_w32_write_x64_regs(thread, &regs);
}
did_first_bp = 1;
}break;
case DEMON_W32_EXCEPTION_SINGLE_STEP:
{
result.name = str8_lit("single_step");
}break;
case DEMON_W32_EXCEPTION_THROW:
{
result.name = str8_lit("exception throw");
}break;
case DEMON_W32_EXCEPTION_ACCESS_VIOLATION:
case DEMON_W32_EXCEPTION_IN_PAGE_ERROR:
{
result.name = str8_lit("exception access violation");
}break;
default:
{
}break;
}
}break;
case OUTPUT_DEBUG_STRING_EVENT:
{
Temp scratch = scratch_begin(0, 0);
result.name = str8_lit("output debug string");
U64 string_address = (U64)evt.u.DebugString.lpDebugStringData;
U64 string_size = (U64)evt.u.DebugString.nDebugStringLength;
// TODO(allen): is the string in UTF-8 or UTF-16?
U8 *buffer = push_array_no_zero(scratch.arena, U8, string_size + 1);
test_w32_read_memory(g_process, buffer, string_address, string_size);
buffer[string_size] = 0;
printf("%s\n", buffer);
scratch_end(scratch);
}break;
case RIP_EVENT:
{
result.name = str8_lit("rip event");
}break;
}
}
//- rjf: set single step bit
if(step_thread != 0)
{
SYMS_RegX64 regs = {0};
test_w32_read_x64_regs(step_thread, &regs);
regs.rflags.u64 &= ~0x100;
test_w32_write_x64_regs(step_thread, &regs);
}
//- rjf: unset traps
{
TEST_Trap *trap = traps;
for(U64 i = 0; i < traps_count; i += 1, trap += 1)
{
U8 og_byte = trap_swap_bytes[i];
if(og_byte != 0xCC)
{
test_w32_write_memory(trap->process, trap->address, &og_byte, 1);
}
}
}
//- rjf: check for more events
for(int i = 0; i < 100; i += 1)
{
DEBUG_EVENT evt = {0};
if(WaitForDebugEvent(&evt, 0))
{
int x = 0;
}
}
//- rjf: resume thread
if(suspend_thread)
{
ResumeThread(suspend_thread);
}
scratch_end(scratch);
return result;
}
int
main(int argument_count, char **arguments)
{
os_init(argument_count, arguments);
Arena *arena = arena_alloc();
U64 before_loop_stop_vaddr = 0x0000000140001089;
U64 inner_loop_stop_vaddr = 0x0000000140001098;
// rjf: launch
{
OS_LaunchOptions opts = {0};
opts.path = os_get_path(arena, OS_SystemPath_Current);
str8_list_push(arena, &opts.cmd_line, str8_lit("R:\\projects\\debugger\\build\\mule_loop_threads_win32.exe"));
B32 launch_good = test_launch_process(&opts);
int x = 0;
}
// rjf: get process/thread handles
HANDLE process = 0;
HANDLE thread1 = 0;
U64 thread1_id = 0;
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0);
if(evt.process)
{
process = evt.process;
}
if(evt.thread)
{
thread1 = evt.thread;
thread1_id = evt.thread_id;
}
if(process != 0 && thread1 != 0)
{
break;
}
}
}
// rjf: get first breakpoint
{
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, 0, 0);
if(evt.evt.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
break;
}
}
}
//- rjf: run until 2nd thread starts up
HANDLE thread2 = 0;
U64 thread2_id = 0;
{
TEST_Trap traps[] =
{
{process, before_loop_stop_vaddr},
};
int trap_count = 0; //ArrayCount(traps);
for(TEST_DebugEvent evt = {0};;)
{
evt = test_run_process(0, 0, trap_count, traps);
if(str8_match(evt.name, str8_lit("breakpoint"), 0))
{
trap_count = 0;
}
if(evt.thread)
{
thread2 = evt.thread;
thread2_id = evt.thread_id;
break;
}
}
}
//- rjf: wait for bps
{
Temp scratch = scratch_begin(0, 0);
TEST_Trap traps[] =
{
{process, 0x0000000140001098},
{process, 0x00000001400010fb},
{process, 0x00000001400010bc},
{process, 0x00000001400010d7},
};
for(int i = 0;; i += 1)
{
TEST_DebugEvent evt = test_run_process(0, 0, 1, &traps[i % ArrayCount(traps)]);
// rjf: check regs
{
U64 rip = 0;
SYMS_RegX64 *regs = push_array(scratch.arena, SYMS_RegX64, 1);
if(evt.evt.dwThreadId == g_thread1_id && test_w32_read_x64_regs(thread1, regs))
{
rip = regs->rip.u64;
}
if(evt.evt.dwThreadId == g_thread2_id && test_w32_read_x64_regs(thread2, regs))
{
rip = regs->rip.u64;
}
for(int i = 0; i < ArrayCount(traps); i += 1)
{
if(traps[i].address == rip)
{
printf("WRONG BP! 0x%I64x\n", rip);
break;
}
}
}
if(str8_match(evt.name, str8_lit("breakpoint"), 0))
{
HANDLE step = 0;
HANDLE suspend = 0;
step = evt.evt.dwThreadId == thread2_id ? thread2 : thread1;
suspend = step == thread2 ? thread1 : thread2;
evt = test_run_process(step, suspend, 0, 0);
}
}
scratch_end(scratch);
}
return 0;
}
File diff suppressed because it is too large. Load diff
+286
View File
@@ -0,0 +1,286 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_WIN32_H
#define DEMON_CORE_WIN32_H
////////////////////////////////
//~ rjf: Windows Includes
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <psapi.h>
#include <tlhelp32.h>
////////////////////////////////
//~ rjf: Win32 Exception Codes
#define DMN_W32_EXCEPTION_BREAKPOINT 0x80000003u
#define DMN_W32_EXCEPTION_SINGLE_STEP 0x80000004u
#define DMN_W32_EXCEPTION_LONG_JUMP 0x80000026u
#define DMN_W32_EXCEPTION_ACCESS_VIOLATION 0xC0000005u
#define DMN_W32_EXCEPTION_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define DMN_W32_EXCEPTION_DATA_TYPE_MISALIGNMENT 0x80000002u
#define DMN_W32_EXCEPTION_GUARD_PAGE_VIOLATION 0x80000001u
#define DMN_W32_EXCEPTION_FLT_DENORMAL_OPERAND 0xC000008Du
#define DMN_W32_EXCEPTION_FLT_DEVIDE_BY_ZERO 0xC000008Eu
#define DMN_W32_EXCEPTION_FLT_INEXACT_RESULT 0xC000008Fu
#define DMN_W32_EXCEPTION_FLT_INVALID_OPERATION 0xC0000090u
#define DMN_W32_EXCEPTION_FLT_OVERFLOW 0xC0000091u
#define DMN_W32_EXCEPTION_FLT_STACK_CHECK 0xC0000092u
#define DMN_W32_EXCEPTION_FLT_UNDERFLOW 0xC0000093u
#define DMN_W32_EXCEPTION_INT_DIVIDE_BY_ZERO 0xC0000094u
#define DMN_W32_EXCEPTION_INT_OVERFLOW 0xC0000095u
#define DMN_W32_EXCEPTION_PRIVILEGED_INSTRUCTION 0xC0000096u
#define DMN_W32_EXCEPTION_ILLEGAL_INSTRUCTION 0xC000001Du
#define DMN_W32_EXCEPTION_IN_PAGE_ERROR 0xC0000006u
#define DMN_W32_EXCEPTION_INVALID_DISPOSITION 0xC0000026u
#define DMN_W32_EXCEPTION_NONCONTINUABLE 0xC0000025u
#define DMN_W32_EXCEPTION_STACK_OVERFLOW 0xC00000FDu
#define DMN_W32_EXCEPTION_INVALID_HANDLE 0xC0000008u
#define DMN_W32_EXCEPTION_UNWIND_CONSOLIDATE 0x80000029u
#define DMN_W32_EXCEPTION_DLL_NOT_FOUND 0xC0000135u
#define DMN_W32_EXCEPTION_ORDINAL_NOT_FOUND 0xC0000138u
#define DMN_W32_EXCEPTION_ENTRY_POINT_NOT_FOUND 0xC0000139u
#define DMN_W32_EXCEPTION_DLL_INIT_FAILED 0xC0000142u
#define DMN_W32_EXCEPTION_CONTROL_C_EXIT 0xC000013Au
#define DMN_W32_EXCEPTION_FLT_MULTIPLE_FAULTS 0xC00002B4u
#define DMN_W32_EXCEPTION_FLT_MULTIPLE_TRAPS 0xC00002B5u
#define DMN_W32_EXCEPTION_NAT_CONSUMPTION 0xC00002C9u
#define DMN_W32_EXCEPTION_HEAP_CORRUPTION 0xC0000374u
#define DMN_W32_EXCEPTION_STACK_BUFFER_OVERRUN 0xC0000409u
#define DMN_W32_EXCEPTION_INVALID_CRUNTIME_PARAM 0xC0000417u
#define DMN_W32_EXCEPTION_ASSERT_FAILURE 0xC0000420u
#define DMN_W32_EXCEPTION_NO_MEMORY 0xC0000017u
#define DMN_W32_EXCEPTION_THROW 0xE06D7363u
#define DMN_W32_EXCEPTION_SET_THREAD_NAME 0x406d1388u
#define DMN_w32_EXCEPTION_CLRDBG_NOTIFICATION 0x04242420u
#define DMN_w32_EXCEPTION_CLR 0xE0434352u
////////////////////////////////
//~ rjf: Win32 Register Codes
#define DMN_W32_CTX_X86 0x00010000
#define DMN_W32_CTX_X64 0x00100000
#define DMN_W32_CTX_INTEL_CONTROL 0x0001 // segss, rsp, segcs, rip, and rflags
#define DMN_W32_CTX_INTEL_INTEGER 0x0002 // rax, rcx, rdx, rbx, rbp, rsi, rdi, and r8-r15
#define DMN_W32_CTX_INTEL_SEGMENTS 0x0004 // segds, seges, segfs, and seggs
#define DMN_W32_CTX_INTEL_FLOATS 0x0008 // xmm0-xmm15
#define DMN_W32_CTX_INTEL_DEBUG 0x0010 // dr0-dr3 and dr6-dr7
#define DMN_W32_CTX_INTEL_EXTENDED 0x0020
#define DMN_W32_CTX_INTEL_XSTATE 0x0040
#define DMN_W32_CTX_X86_ALL (DMN_W32_CTX_X86 | \
DMN_W32_CTX_INTEL_CONTROL | DMN_W32_CTX_INTEL_INTEGER | \
DMN_W32_CTX_INTEL_SEGMENTS | DMN_W32_CTX_INTEL_DEBUG | \
DMN_W32_CTX_INTEL_EXTENDED)
#define DMN_W32_CTX_X64_ALL (DMN_W32_CTX_X64 | \
DMN_W32_CTX_INTEL_CONTROL | DMN_W32_CTX_INTEL_INTEGER | \
DMN_W32_CTX_INTEL_SEGMENTS | DMN_W32_CTX_INTEL_FLOATS | \
DMN_W32_CTX_INTEL_DEBUG)
////////////////////////////////
//~ rjf: Per-Entity State
typedef enum DMN_W32_EntityKind
{
DMN_W32_EntityKind_Null,
DMN_W32_EntityKind_Root,
DMN_W32_EntityKind_Process,
DMN_W32_EntityKind_Thread,
DMN_W32_EntityKind_Module,
DMN_W32_EntityKind_COUNT
}
DMN_W32_EntityKind;
typedef struct DMN_W32_Entity DMN_W32_Entity;
struct DMN_W32_Entity
{
DMN_W32_Entity *first;
DMN_W32_Entity *last;
DMN_W32_Entity *next;
DMN_W32_Entity *prev;
DMN_W32_Entity *parent;
DMN_W32_EntityKind kind;
U32 gen;
U64 id;
HANDLE handle;
Arch arch;
union
{
struct
{
U64 injection_address;
B32 did_first_bp;
}
proc;
struct
{
U64 thread_local_base;
U64 last_name_hash;
U64 name_gather_time_us;
}
thread;
struct
{
Rng1U64 vaddr_range;
U64 address_of_name_pointer;
B32 is_main;
B32 name_is_unicode;
}
module;
};
};
typedef struct DMN_W32_EntityNode DMN_W32_EntityNode;
struct DMN_W32_EntityNode
{
DMN_W32_EntityNode *next;
DMN_W32_Entity *v;
};
typedef struct DMN_W32_EntityIDHashNode DMN_W32_EntityIDHashNode;
struct DMN_W32_EntityIDHashNode
{
DMN_W32_EntityIDHashNode *next;
DMN_W32_EntityIDHashNode *prev;
U64 id;
DMN_W32_Entity *entity;
};
typedef struct DMN_W32_EntityIDHashSlot DMN_W32_EntityIDHashSlot;
struct DMN_W32_EntityIDHashSlot
{
DMN_W32_EntityIDHashNode *first;
DMN_W32_EntityIDHashNode *last;
};
////////////////////////////////
//~ rjf: Injection Types
typedef struct DMN_W32_InjectedBreak DMN_W32_InjectedBreak;
struct DMN_W32_InjectedBreak
{
U64 code;
U64 user_data;
};
#define DMN_W32_INJECTED_CODE_SIZE 32
////////////////////////////////
//~ rjf: Image Info Types
typedef struct DMN_W32_ImageInfo DMN_W32_ImageInfo;
struct DMN_W32_ImageInfo
{
Arch arch;
U32 size;
};
////////////////////////////////
//~ rjf: Dynamically-Loaded Win32 Function Types
typedef HRESULT DMN_W32_GetThreadDescriptionFunctionType(HANDLE hThread, WCHAR **ppszThreadDescription);
////////////////////////////////
//~ rjf: Shared State Bundle
typedef struct DMN_W32_Shared DMN_W32_Shared;
struct DMN_W32_Shared
{
// rjf: top-level info
Arena *arena;
String8List env_strings;
// rjf: access locking mechanism
OS_Handle access_mutex;
B32 access_run_state;
// rjf: run/mem/reg gens
U64 run_gen;
U64 mem_gen;
U64 reg_gen;
// rjf: detaching info
Arena *detach_arena;
DMN_HandleList detach_processes;
// rjf: entity state
Arena *entities_arena;
DMN_W32_Entity *entities_base;
DMN_W32_Entity *entities_first_free;
U64 entities_count;
DMN_W32_EntityIDHashSlot *entities_id_hash_slots;
U64 entities_id_hash_slots_count;
DMN_W32_EntityIDHashNode *entities_id_hash_node_free;
// rjf: launch state
B32 new_process_pending;
// rjf: run results
B32 resume_needed;
U32 resume_pid;
U32 resume_tid;
B32 exception_not_handled;
// rjf: halting info
DMN_Handle halter_process;
U32 halter_tid;
};
////////////////////////////////
//~ rjf: Globals
global DMN_W32_Shared *dmn_w32_shared = 0;
global DMN_W32_Entity dmn_w32_entity_nil = {&dmn_w32_entity_nil, &dmn_w32_entity_nil, &dmn_w32_entity_nil, &dmn_w32_entity_nil, &dmn_w32_entity_nil};
global DMN_W32_GetThreadDescriptionFunctionType *dmn_w32_GetThreadDescription = 0;
thread_static B32 dmn_w32_ctrl_thread = 0;
////////////////////////////////
//~ rjf: Basic Helpers
internal U64 dmn_w32_hash_from_string(String8 string);
internal U64 dmn_w32_hash_from_id(U64 id);
////////////////////////////////
//~ rjf: Entity Helpers
//- rjf: entity <-> handle
internal DMN_Handle dmn_w32_handle_from_entity(DMN_W32_Entity *entity);
internal DMN_W32_Entity *dmn_w32_entity_from_handle(DMN_Handle handle);
//- rjf: entity allocation/deallocation
internal DMN_W32_Entity *dmn_w32_entity_alloc(DMN_W32_Entity *parent, DMN_W32_EntityKind kind, U64 id);
internal void dmn_w32_entity_release(DMN_W32_Entity *entity);
//- rjf: kind*id -> entity
internal DMN_W32_Entity *dmn_w32_entity_from_kind_id(DMN_W32_EntityKind kind, U64 id);
////////////////////////////////
//~ rjf: Module Info Extraction
internal String8 dmn_w32_full_path_from_module(Arena *arena, DMN_W32_Entity *module);
////////////////////////////////
//~ rjf: Win32-Level Process/Thread Reads/Writes
//- rjf: processes
internal U64 dmn_w32_process_read(HANDLE process, Rng1U64 range, void *dst);
internal B32 dmn_w32_process_write(HANDLE process, Rng1U64 range, void *src);
internal String8 dmn_w32_read_memory_str(Arena *arena, HANDLE process_handle, U64 address);
internal String16 dmn_w32_read_memory_str16(Arena *arena, HANDLE process_handle, U64 address);
#define dmn_w32_process_read_struct(process, vaddr, ptr) dmn_w32_process_read((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
#define dmn_w32_process_write_struct(process, vaddr, ptr) dmn_w32_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
internal DMN_W32_ImageInfo dmn_w32_image_info_from_process_base_vaddr(HANDLE process, U64 base_vaddr);
//- rjf: threads
internal U16 dmn_w32_real_tag_word_from_xsave(XSAVE_FORMAT *fxsave);
internal U16 dmn_w32_xsave_tag_word_from_real_tag_word(U16 ftw);
internal B32 dmn_w32_thread_read_reg_block(Arch arch, HANDLE thread, void *reg_block);
internal B32 dmn_w32_thread_write_reg_block(Arch arch, HANDLE thread, void *reg_block);
//- rjf: remote thread injection
internal DWORD dmn_w32_inject_thread(HANDLE process, U64 start_address);
#endif // DEMON_CORE_WIN32_H
File diff suppressed because it is too large. Load diff
-382
View File
@@ -1,382 +0,0 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_OS_WIN32_H
#define DEMON_OS_WIN32_H
////////////////////////////////
//~ NOTE(allen): Win32 Demon Headers Negotation
// windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <psapi.h>
#include <tlhelp32.h>
////////////////////////////////
//~ NOTE(allen): Win32 Demon Types
//- entities
// Demon Win32 Entity Extensions
// Process: ext points to independently allocated DEMON_W32_Ext
// Thread : ext points to independently allocated DEMON_W32_Ext
// Module : ext set to HANDLE
typedef union DEMON_W32_Ext DEMON_W32_Ext;
union DEMON_W32_Ext
{
DEMON_W32_Ext *next;
struct{
HANDLE handle;
U64 injection_address;
B32 did_first_bp;
} proc;
struct{
HANDLE handle;
U64 thread_local_base;
U64 last_name_hash;
U64 name_gather_time_us;
} thread;
struct{
HANDLE handle;
U64 address_of_name_pointer;
B32 is_main;
B32 name_is_unicode;
} module;
};
//- helpers
typedef struct DEMON_W32_InjectedBreak DEMON_W32_InjectedBreak;
struct DEMON_W32_InjectedBreak
{
U64 code;
U64 user_data;
};
#define DEMON_W32_INJECTED_CODE_SIZE 32
typedef struct DEMON_W32_ImageInfo DEMON_W32_ImageInfo;
struct DEMON_W32_ImageInfo
{
Architecture arch;
U32 size;
};
typedef struct DEMON_W32_EntityNode DEMON_W32_EntityNode;
struct DEMON_W32_EntityNode
{
DEMON_W32_EntityNode *next;
DEMON_Entity *entity;
};
typedef HRESULT GetThreadDescriptionFunctionType(HANDLE hThread, WCHAR **ppszThreadDescription);
////////////////////////////////
//~ NOTE(allen): Win32 Demon Exceptions
#define DEMON_W32_EXCEPTION_BREAKPOINT 0x80000003u
#define DEMON_W32_EXCEPTION_SINGLE_STEP 0x80000004u
#define DEMON_W32_EXCEPTION_LONG_JUMP 0x80000026u
#define DEMON_W32_EXCEPTION_ACCESS_VIOLATION 0xC0000005u
#define DEMON_W32_EXCEPTION_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define DEMON_W32_EXCEPTION_DATA_TYPE_MISALIGNMENT 0x80000002u
#define DEMON_W32_EXCEPTION_GUARD_PAGE_VIOLATION 0x80000001u
#define DEMON_W32_EXCEPTION_FLT_DENORMAL_OPERAND 0xC000008Du
#define DEMON_W32_EXCEPTION_FLT_DEVIDE_BY_ZERO 0xC000008Eu
#define DEMON_W32_EXCEPTION_FLT_INEXACT_RESULT 0xC000008Fu
#define DEMON_W32_EXCEPTION_FLT_INVALID_OPERATION 0xC0000090u
#define DEMON_W32_EXCEPTION_FLT_OVERFLOW 0xC0000091u
#define DEMON_W32_EXCEPTION_FLT_STACK_CHECK 0xC0000092u
#define DEMON_W32_EXCEPTION_FLT_UNDERFLOW 0xC0000093u
#define DEMON_W32_EXCEPTION_INT_DIVIDE_BY_ZERO 0xC0000094u
#define DEMON_W32_EXCEPTION_INT_OVERFLOW 0xC0000095u
#define DEMON_W32_EXCEPTION_PRIVILEGED_INSTRUCTION 0xC0000096u
#define DEMON_W32_EXCEPTION_ILLEGAL_INSTRUCTION 0xC000001Du
#define DEMON_W32_EXCEPTION_IN_PAGE_ERROR 0xC0000006u
#define DEMON_W32_EXCEPTION_INVALID_DISPOSITION 0xC0000026u
#define DEMON_W32_EXCEPTION_NONCONTINUABLE 0xC0000025u
#define DEMON_W32_EXCEPTION_STACK_OVERFLOW 0xC00000FDu
#define DEMON_W32_EXCEPTION_INVALID_HANDLE 0xC0000008u
#define DEMON_W32_EXCEPTION_UNWIND_CONSOLIDATE 0x80000029u
#define DEMON_W32_EXCEPTION_DLL_NOT_FOUND 0xC0000135u
#define DEMON_W32_EXCEPTION_ORDINAL_NOT_FOUND 0xC0000138u
#define DEMON_W32_EXCEPTION_ENTRY_POINT_NOT_FOUND 0xC0000139u
#define DEMON_W32_EXCEPTION_DLL_INIT_FAILED 0xC0000142u
#define DEMON_W32_EXCEPTION_CONTROL_C_EXIT 0xC000013Au
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_FAULTS 0xC00002B4u
#define DEMON_W32_EXCEPTION_FLT_MULTIPLE_TRAPS 0xC00002B5u
#define DEMON_W32_EXCEPTION_NAT_CONSUMPTION 0xC00002C9u
#define DEMON_W32_EXCEPTION_HEAP_CORRUPTION 0xC0000374u
#define DEMON_W32_EXCEPTION_STACK_BUFFER_OVERRUN 0xC0000409u
#define DEMON_W32_EXCEPTION_INVALID_CRUNTIME_PARAM 0xC0000417u
#define DEMON_W32_EXCEPTION_ASSERT_FAILURE 0xC0000420u
#define DEMON_W32_EXCEPTION_NO_MEMORY 0xC0000017u
#define DEMON_W32_EXCEPTION_THROW 0xE06D7363u
#define DEMON_W32_EXCEPTION_SET_THREAD_NAME 0x406d1388u
////////////////////////////////
//~ NOTE(allen): Win32 Demon Register API Codes
#define DEMON_W32_CTX_X86 0x00010000
#define DEMON_W32_CTX_X64 0x00100000
#define DEMON_W32_CTX_INTEL_CONTROL 0x0001
#define DEMON_W32_CTX_INTEL_INTEGER 0x0002
#define DEMON_W32_CTX_INTEL_SEGMENTS 0x0004
#define DEMON_W32_CTX_INTEL_FLOATS 0x0008
#define DEMON_W32_CTX_INTEL_DEBUG 0x0010
#define DEMON_W32_CTX_INTEL_EXTENDED 0x0020
#define DEMON_W32_CTX_INTEL_XSTATE 0x0040
#define DEMON_W32_CTX_X86_ALL (DEMON_W32_CTX_X86 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_DEBUG | \
DEMON_W32_CTX_INTEL_EXTENDED)
#define DEMON_W32_CTX_X64_ALL (DEMON_W32_CTX_X64 | \
DEMON_W32_CTX_INTEL_CONTROL | DEMON_W32_CTX_INTEL_INTEGER | \
DEMON_W32_CTX_INTEL_SEGMENTS | DEMON_W32_CTX_INTEL_FLOATS | \
DEMON_W32_CTX_INTEL_DEBUG)
////////////////////////////////
//~ rjf: DOS Header Types
// this is the "MZ" as a 16-bit short
#define DEMON_DOS_MAGIC 0x5a4d
#pragma pack(push,1)
typedef struct DEMON_DosHeader DEMON_DosHeader;
struct DEMON_DosHeader
{
U16 magic;
U16 last_page_size;
U16 page_count;
U16 reloc_count;
U16 paragraph_header_size;
U16 min_paragraph;
U16 max_paragraph;
U16 init_ss;
U16 init_sp;
U16 checksum;
U16 init_ip;
U16 init_cs;
U16 reloc_table_file_off;
U16 overlay_number;
U16 reserved[4];
U16 oem_id;
U16 oem_info;
U16 reserved2[10];
U32 coff_file_offset;
};
#pragma pack(pop)
////////////////////////////////
//~ rjf: Coff Header Types
#define DEMON_PE_MAGIC 0x00004550u
typedef U16 DEMON_CoffMachineType;
enum{
DEMON_CoffMachineType_UNKNOWN = 0x0,
DEMON_CoffMachineType_X86 = 0x14c,
DEMON_CoffMachineType_X64 = 0x8664,
DEMON_CoffMachineType_ARM33 = 0x1d3,
DEMON_CoffMachineType_ARM = 0x1c0,
DEMON_CoffMachineType_ARM64 = 0xaa64,
DEMON_CoffMachineType_ARMNT = 0x1c4,
DEMON_CoffMachineType_EBC = 0xebc,
DEMON_CoffMachineType_IA64 = 0x200,
DEMON_CoffMachineType_M32R = 0x9041,
DEMON_CoffMachineType_MIPS16 = 0x266,
DEMON_CoffMachineType_MIPSFPU = 0x366,
DEMON_CoffMachineType_MIPSFPU16 = 0x466,
DEMON_CoffMachineType_POWERPC = 0x1f0,
DEMON_CoffMachineType_POWERPCFP = 0x1f1,
DEMON_CoffMachineType_R4000 = 0x166,
DEMON_CoffMachineType_RISCV32 = 0x5032,
DEMON_CoffMachineType_RISCV64 = 0x5064,
DEMON_CoffMachineType_RISCV128 = 0x5128,
DEMON_CoffMachineType_SH3 = 0x1a2,
DEMON_CoffMachineType_SH3DSP = 0x1a3,
DEMON_CoffMachineType_SH4 = 0x1a6,
DEMON_CoffMachineType_SH5 = 0x1a8,
DEMON_CoffMachineType_THUMB = 0x1c2,
DEMON_CoffMachineType_WCEMIPSV2 = 0x169,
DEMON_CoffMachineType_COUNT = 25
};
typedef U16 DEMON_CoffFlags;
enum{
DEMON_CoffFlag_RELOC_STRIPPED = (1 << 0),
DEMON_CoffFlag_EXECUTABLE_IMAGE = (1 << 1),
DEMON_CoffFlag_LINE_NUMS_STRIPPED = (1 << 2),
DEMON_CoffFlag_SYM_STRIPPED = (1 << 3),
DEMON_CoffFlag_RESERVED_0 = (1 << 4),
DEMON_CoffFlag_LARGE_ADDRESS_AWARE = (1 << 5),
DEMON_CoffFlag_RESERVED_1 = (1 << 6),
DEMON_CoffFlag_RESERVED_2 = (1 << 7),
DEMON_CoffFlag_32BIT_MACHINE = (1 << 8),
DEMON_CoffFlag_DEBUG_STRIPPED = (1 << 9),
DEMON_CoffFlag_REMOVABLE_RUN_FROM_SWAP = (1 << 10),
DEMON_CoffFlag_NET_RUN_FROM_SWAP = (1 << 11),
DEMON_CoffFlag_SYSTEM = (1 << 12),
DEMON_CoffFlag_DLL = (1 << 13),
DEMON_CoffFlag_UP_SYSTEM_ONLY = (1 << 14),
DEMON_CoffFlag_BYTES_RESERVED_HI = (1 << 15),
};
#pragma pack(push,1)
typedef struct DEMON_CoffHeader DEMON_CoffHeader;
struct DEMON_CoffHeader
{
DEMON_CoffMachineType machine;
U16 section_count;
U32 time_date_stamp;
// TODO: rename to "unix_timestamp"
U32 pointer_to_symbol_table;
U32 number_of_symbols;
// TODO: rename to "symbol_count"
U16 size_of_optional_header;
// TODO: rename to "optional_header_size"
DEMON_CoffFlags flags;
};
#pragma pack(pop)
////////////////////////////////
//~ rjf: PE Header Types
#pragma pack(push, 1)
typedef U16 DEMON_PeWindowsSubsystem;
enum{
DEMON_PeWindowsSubsystem_UNKNOWN = 0,
DEMON_PeWindowsSubsystem_NATIVE = 1,
DEMON_PeWindowsSubsystem_WINDOWS_GUI = 2,
DEMON_PeWindowsSubsystem_WINDOWS_CUI = 3,
DEMON_PeWindowsSubsystem_OS2_CUI = 5,
DEMON_PeWindowsSubsystem_POSIX_CUI = 7,
DEMON_PeWindowsSubsystem_NATIVE_WINDOWS = 8,
DEMON_PeWindowsSubsystem_WINDOWS_CE_GUI = 9,
DEMON_PeWindowsSubsystem_EFI_APPLICATION = 10,
DEMON_PeWindowsSubsystem_EFI_BOOT_SERVICE_DRIVER = 11,
DEMON_PeWindowsSubsystem_EFI_RUNTIME_DRIVER = 12,
DEMON_PeWindowsSubsystem_EFI_ROM = 13,
DEMON_PeWindowsSubsystem_XBOX = 14,
DEMON_PeWindowsSubsystem_WINDOWS_BOOT_APPLICATION = 16,
DEMON_PeWindowsSubsystem_COUNT = 14
};
typedef U16 DEMON_DllCharacteristics;
enum{
DEMON_DllCharacteristic_HIGH_ENTROPY_VA = (1 << 5),
DEMON_DllCharacteristic_DYNAMIC_BASE = (1 << 6),
DEMON_DllCharacteristic_FORCE_INTEGRITY = (1 << 7),
DEMON_DllCharacteristic_NX_COMPAT = (1 << 8),
DEMON_DllCharacteristic_NO_ISOLATION = (1 << 9),
DEMON_DllCharacteristic_NO_SEH = (1 << 10),
DEMON_DllCharacteristic_NO_BIND = (1 << 11),
DEMON_DllCharacteristic_APPCONTAINER = (1 << 12),
DEMON_DllCharacteristic_WDM_DRIVER = (1 << 13),
DEMON_DllCharacteristic_GUARD_CF = (1 << 14),
DEMON_DllCharacteristic_TERMINAL_SERVER_AWARE = (1 << 15),
};
typedef struct DEMON_PeOptionalHeader32 DEMON_PeOptionalHeader32;
struct DEMON_PeOptionalHeader32
{
U16 magic;
U8 major_linker_version;
U8 minor_linker_version;
U32 sizeof_code;
U32 sizeof_inited_data;
U32 sizeof_uninited_data;
U32 entry_point_va;
U32 code_base;
U32 data_base;
U32 image_base;
U32 section_alignment;
U32 file_alignment;
U16 major_os_ver;
U16 minor_os_ver;
U16 major_img_ver;
U16 minor_img_ver;
U16 major_subsystem_ver;
U16 minor_subsystem_ver;
U32 win32_version_value;
U32 sizeof_image;
U32 sizeof_headers;
U32 check_sum;
DEMON_PeWindowsSubsystem subsystem;
DEMON_DllCharacteristics dll_characteristics;
U32 sizeof_stack_reserve;
U32 sizeof_stack_commit;
U32 sizeof_heap_reserve;
U32 sizeof_heap_commit;
U32 loader_flags;
U32 data_dir_count;
};
typedef struct DEMON_PeOptionalHeader32Plus DEMON_PeOptionalHeader32Plus;
struct DEMON_PeOptionalHeader32Plus
{
U16 magic;
U8 major_linker_version;
U8 minor_linker_version;
U32 sizeof_code;
U32 sizeof_inited_data;
U32 sizeof_uninited_data;
U32 entry_point_va;
U32 code_base;
U64 image_base;
U32 section_alignment;
U32 file_alignment;
U16 major_os_ver;
U16 minor_os_ver;
U16 major_img_ver;
U16 minor_img_ver;
U16 major_subsystem_ver;
U16 minor_subsystem_ver;
U32 win32_version_value;
U32 sizeof_image;
U32 sizeof_headers;
U32 check_sum;
DEMON_PeWindowsSubsystem subsystem;
DEMON_DllCharacteristics dll_characteristics;
U64 sizeof_stack_reserve;
U64 sizeof_stack_commit;
U64 sizeof_heap_reserve;
U64 sizeof_heap_commit;
U32 loader_flags;
U32 data_dir_count;
};
#pragma pack(pop)
////////////////////////////////
//~ rjf: Helpers
internal U64 demon_w32_hash_from_string(String8 string);
internal DEMON_W32_Ext* demon_w32_ext_alloc(void);
internal DEMON_W32_Ext* demon_w32_ext(DEMON_Entity *entity);
internal U64 demon_w32_read_memory(HANDLE process_handle, void *dst, U64 src_address, U64 size);
internal B32 demon_w32_write_memory(HANDLE process_handle, U64 dst_address, void *src, U64 size);
internal String8 demon_w32_read_memory_str(Arena *arena, HANDLE process_handle, U64 address);
internal String16 demon_w32_read_memory_str16(Arena *arena, HANDLE process_handle, U64 address);
#define demon_w32_read_struct(h,dst,src) demon_w32_read_memory((h), (dst), (src), sizeof(*(dst)))
internal DEMON_W32_ImageInfo demon_w32_image_info_from_base(HANDLE process_handle, U64 base);
internal DWORD demon_w32_inject_thread(DEMON_Entity *process, U64 start_address);
internal U16 demon_w32_real_tag_word_from_xsave(XSAVE_FORMAT *fxsave);
internal U16 demon_w32_xsave_tag_word_from_real_tag_word(U16 ftw);
internal DWORD demon_w32_win32_from_memory_protect_flags(DEMON_MemoryProtectFlags flags);
////////////////////////////////
//~ rjf: Experiments
internal void demon_w32_peak_at_tls(DEMON_Handle handle);
#endif //DEMON_OS_WIN32_H
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Loaded 100 of 564 files, more files were not shown because too many files have changed in this diff. Show more