Commit Graph

643 Commits

Author SHA1 Message Date
Bill Currie c9f1d770e0 Merge master into csqc-improvements
That was a mess
2021-03-25 22:01:31 +09:00
Bill Currie 66fda1fddb Rewrite edict access.
The server edict arrays are now stored outside of progs memory, only the
entity data itself (ie data accessible to progs via ent.fld) is stored in
progs memory. Many of the changes were due to code accessing edicts and
entity fields directly rather than through the provided macros.
2021-03-25 18:13:48 +09:00
Bill Currie 56cf181a11 [gamecode] Make PR_RESMAP macros more function-like
I never liked that some of the macros needed the type as a parameter
(yay typeof and __auto_type) or those that returned a value hid the
return statement so they couldn't be used in assignments.
2021-03-21 21:26:36 +09:00
Bill Currie cc4167668c Fix a pile of leaks and uninit errors
Still "some" more to go: a pile to do with transforms and temporary
entities, and a nasty one with host_cbuf. There's also all the static
block-alloc lists :/
2021-03-21 19:56:17 +09:00
Bill Currie a3c1b2e992 [util] Rename qfplist.[ch]
The name is a hold-over from before the current quakeforge tree and the
QF include directory.
2021-03-21 16:13:03 +09:00
Bill Currie 4eb07220cd [util] Make plists more const-correct 2021-02-25 11:55:25 +09:00
Bill Currie dfa7af03c6 [util] Plug a thread-safety hole in plists 2021-02-09 09:57:07 +09:00
Bill Currie db14025935 [gamecode] Put strings and debug back in load funcs
It turns out they're required to be initialized before most of the rest
of the system.
2021-01-12 17:34:57 +09:00
Bill Currie ec7d974dc1 [gamecode] Move % handling to the flags state
% is effectively a format flag that cancels the format and outputs a
% single %. Fixes % not getting output for %%.
2021-01-05 00:07:58 +09:00
Bill Currie 1b8b7c04cb [gamecode] Disconnect held strings from return slot
Fixes an internal string error when a return string has been freed.
2021-01-04 23:42:10 +09:00
Bill Currie ab04a1915e [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-21 14:14:29 +09:00
Bill Currie 98795bf604 [gamecode] Add a comment about returning temp strings 2020-07-05 16:53:35 +09:00
Bill Currie 6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00
Bill Currie 2bec2527b4 [gamecode] Re-expose PR_LoadStrings
It's required for qfprogs now that PR_LoadDebug reads strings early.
2020-04-04 14:33:49 +09:00
Bill Currie cf7c4780eb [gamecode] Load extended debug data
And add function to get a source file's base directory if available.
2020-04-04 12:50:25 +09:00
Bill Currie 59f48e5e32 [gamecode] Add function to test if string exists
As it returns the string id, it is useful for getting an string id
without risking creating a new one.
2020-04-04 12:32:12 +09:00
Bill Currie 7bcfd2f2be [gamecode] Move file_hash into debug resources
I don't remember why I didn't do this earlier when I thread-safed progs.
2020-04-03 22:39:27 +09:00
Bill Currie fbbe144399 [gamecode] Clean up some stray "struct"
Left over from moving debug data from progs.h to pr_debug.c
2020-04-03 22:35:55 +09:00
Bill Currie c09f57c39e [gamecode] Delay .ctor calls if debugging
This allows a debugger to do any symbol lookups and other preparations
between loading progs and the first code execution. .ctors are called as
per normal if debug_handler is not set.
2020-04-02 17:39:11 +09:00
Bill Currie f90613bc3a [gamecode] Rename fields in pr_stack_t
s and f are a little too succinct.
2020-04-02 15:00:01 +09:00
Bill Currie 41184bd97d [gamecode] Document the format state machine 2020-04-01 20:50:42 +09:00
Bill Currie a36f72f7b4 [gamecode] Support variable field width and precision 2020-04-01 19:45:33 +09:00
Bill Currie 7f4d2215e2 [gamecode] Accept EOS at end of conversion specifier 2020-04-01 18:32:30 +09:00
Bill Currie 7f86fb5529 [gamecode] Rework PR_Sprintf to use a state machine
This makes it much easier to extend. There are even stubs for variable
field width and precision (not set yet).
2020-04-01 13:32:07 +09:00
Bill Currie a7956c7311 [gamecode] Move format state into a state struct
This is the first step in reworking PR_Sprintf to use a state machine.
The goal is to make it more robust against errors and easier to extend
(eg, * width and precision).
2020-04-01 11:19:56 +09:00
Bill Currie e9733416f4 [gamecode] Hide trace messages when debugger is attached 2020-04-01 00:09:34 +09:00
Bill Currie 58acc483fd [gamecode] Save new string ref in return slot
This plugs the memory leak that caused qwaq to crash after resizing the
locals window a "few" times (several seconds of playing with the size).
2020-03-31 20:38:41 +09:00
Bill Currie e2d1a0f7d2 [ruamoko] Tag object memory with the class name
This makes it a lot easier to see what's leaking.
2020-03-31 16:43:10 +09:00
Bill Currie ddec80edc1 [qfcc] Make type encoding union anonymous
I'd do more, but things get messy with direct access to unions that I
want to be anonymous.
2020-03-30 11:10:05 +09:00
Bill Currie 8b1e4eea58 [qfcc] Bring back the core of type aliasing
No aliasing is done yet, but most of the infrastructure is there again.
2020-03-27 12:27:46 +09:00
Bill Currie 1586df4dfc [gamecode] Make it possible to check string mutability 2020-03-26 16:38:09 +09:00
Bill Currie ec82d6b027 [gamecode] Add support for holding ephemeral strings
PR_HoldString converts ephemeral (temp and return) strings to dynamic
strings. This makes dealing with strings in progs a little easier.
2020-03-26 16:36:29 +09:00
Bill Currie b4874f7d9b [gamecode] Make PR_FreeString a little more forgiving
It treats only strings that are actually invalid as invalid. That is,
now it is safe to "free" a static string: it's just a no-op.
2020-03-26 15:48:04 +09:00
Bill Currie 22e2695f80 [gamecode] Add VISIBLE to some missed functions 2020-03-26 15:36:46 +09:00
Bill Currie 2d5df34234 [gamecode] Add VM enter/exit events
And rename prd_exit to prd_terminate (the idea is the host will
terminate the VM). This makes it possible for the debugger to pause the
VM before any code, even a builtin function, is executed. Breaks the
debugger source window, but only because it's not updating on file
change (I think).
2020-03-26 12:30:32 +09:00
Bill Currie 1bd8e2ee85 [gamecode] Add a param pointer to debug_handler
I decided I want events for VM enter/exit but enter needs to somehow
pass the function which will be executed (even if a builtin). A generic
void * param seemed the best idea, which meant the error string could be
passed via the param instead of a "global" string in the progs struct.
2020-03-26 11:44:02 +09:00
Bill Currie 4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie c945c42989 [gamecode] Fix some silly errors
I forgot to compile-test :(
2020-03-24 23:16:25 +09:00
Bill Currie d867a1a9f1 [gamecode] Allow watch-point to be updated
With the watch-point address cached in a local var, it was not possible
to update the watch-point while the progs were executing.
2020-03-24 19:45:39 +09:00
Bill Currie 713150b41a [gamecode] Add debug hooks to the VM engine
While there was a breakpoint hook, it was for only breakpoints and more
was needed. Now there's a generic hook that is called for tracing,
breakpoints, watch points, runtime errors and VM errors, with the
"event" type passed as the first parameter and a data pointer in the
second.
2020-03-24 19:45:10 +09:00
Bill Currie 1d6843d7f0 [gamecode] Improve watchpoint handling a little
Mostly just update the old value if the condition didn't trigger.
2020-03-24 13:26:35 +09:00
Bill Currie 753d183d82 [gamecode] Be more informative with function calls
PR_EnterFunction and PR_LeaveFunction now print the
entered/left/returned function when tracing. Makes debugging obj code
much easier.
2020-03-24 13:24:55 +09:00
Bill Currie b544a052bf [gamecode] Bail if PR_SearchDefs is given 0 defs
Fixes the hang when searching for a field in progs that don't have any.
2020-03-16 14:24:48 +09:00
Bill Currie e3a1413ad3 [gamecode] Tweak output for lea 2020-03-15 10:06:37 +09:00
Bill Currie 99f89840f9 [gamecode] Show containing def and relative offset
No more guessing when accessing structure field members. Next is ivars,
I guess.
2020-03-15 02:51:29 +09:00
Bill Currie 3d62a7f253 [gamecode] Use fuzzy bsearch to find defs by address
The idea is to find th def that contains the address. Had to write my
own bsearch (well... lifted from wikipedia) because libc's is exact. The
defs are assumed to be sorted (which qfcc now ensures when it writes
progs and sym files).
2020-03-15 02:48:13 +09:00
Bill Currie 2f9f6d3aa9 [gamecode] Relocate aux function return types
They are written with offsets relative to the type encodings base.
2020-03-14 23:39:14 +09:00
Bill Currie 9492f08536 [gamecode] Print structs as well as unions
Much better :)
2020-03-14 21:03:01 +09:00
Bill Currie fea6381574 [gamecode] Rework debug type handling a little
Type encodings are used whenever they are available. For now, if they
are not, then everything is treated as void (which prints <void>, not
very useful). Most return statements and references to .return are now
very readable (excluding structs), and only params going through "..."
are a messy union.
2020-03-14 20:44:43 +09:00
Bill Currie a069fad41e [gamecode] Print only entity address when no edicts
If the edicts pointer is null, it's not possible to convert the entity
address to an index.
2020-03-13 20:16:06 +09:00