Commit Graph

59 Commits

Author SHA1 Message Date
Bill Currie 81f73e4524 [gamecode] Support printing a single edict field 2021-07-25 09:54:08 +09:00
Bill Currie 86cf7fbecd [gamecode] Check for null edict before printing number
Avoids segfault during double-verbose disassembly of progs code that
uses entities.
2021-07-24 18:04:57 +09:00
Bill Currie d865095d0b [gamecode] Check for nil entity
Fixes a segfault when disassembling progs.dat files that access entity
fields as the accessed entity will generally be nil.
2021-06-28 18:12:15 +09:00
Bill Currie d23c9582f1 [qwaq] Implement execute-to-cursor
Support for finding the first address associated with a source line was
added to the engine, returning 0 if not found.

A temporary breakpoint is set and the progs allowed to run free.
However, better handling of temporary breakpoitns is needed as currently
a "permanent" breakpoint will be cleared without clearing the temporary
breakpoing if the permanent breakpoing is hit while execut-to-cursor is
running.
2021-06-08 16:54:04 +09:00
Bill Currie 6fea5f5e1a [build] Add -Wformat-non-literal option
While this caused some trouble for pr_strings and configurable strftime
(evil hacks abound), it's the result of discovering an ancient (from
maybe as early as 2004, definitely before 2012) bug in qwaq's printing
that somehow got past months of trial-by-fire testing (origin understood
thanks to the warning finding it).
2021-03-29 17:27:06 +09:00
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 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 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 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 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 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 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 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 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 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
Bill Currie 087cee06be [gamecode] Use full precision for floating point values 2020-03-13 14:57:33 +09:00
Bill Currie 6dfe37635d [gamecode] Dump union contents
The output is messy, but better than <union>
2020-03-13 14:56:56 +09:00
Bill Currie 68fc11857a [gamecode] Fix a string splitting error 2020-03-04 21:10:23 +09:00
Bill Currie c214797e97 [gamecode] Fix some curly space
and add some comments. took a bit to figure out what i was doing
2020-03-04 21:09:36 +09:00
Bill Currie 4e4b553cc3 [gamecode] Take care of missed type alias stuff 2020-03-01 16:20:23 +09:00
Bill Currie c9186c8296 Clear the statement line buffer
The problem with moving to a cached buffer is it needs to be cleared.
Fixes the weird output of qfprogs and tracing (not missing local defs,
though).
2020-02-27 01:25:41 +09:00
Bill Currie 62b541793d [gamecode] Remove all use of va
With this, the VA is very close to being safe to use in a threaded
environment (so long as each VM is used by only one thread). Just the
debug file hash and source paths to sort out.
2020-02-26 19:30:10 +09:00
Bill Currie 42713cad8b Make script much friendlier to use
It now simply sets an error message pointer and returns false if there's
an error.
2020-02-26 09:39:03 +09:00
Bill Currie 66dd3ef070 Make a bunch of count things positive-only
This fixes a pile of FIXMEs, because some things should never be
negative.
2020-02-25 21:23:13 +09:00
Bill Currie 282132958f Relocate local def type encodings in debug load
For technical reasons (programmer laziness), qfcc does not fix up local
def type encodings when writing the debug symbols file (type encoding
location not readily accessible).
2020-02-25 20:46:01 +09:00
Bill Currie 89e83d7d73 Move the debug info out of progs_t
The debug subsystem now uses the resources system to ensure it cleans
up, and its data is now semi-private. Unfortunately, PR_LoadDebug had to
remain public for qfprogs because using PR_RunLoadFuncs would cause
builtin resolution to complain.
2020-02-25 20:07:29 +09:00
Bill Currie 7406e0308e Fix some warnings picked up in an optimized build 2020-02-24 11:28:43 +09:00
Bill Currie dda045bf96 Do lazy computation of def sizes from type encodings
The size is calculated when needed and cached.
2020-02-23 23:29:58 +09:00
Bill Currie d0dc0e15fb Handle alias types in debug prints 2020-02-23 19:02:16 +09:00
Bill Currie b173c35eb4 Rework progs debug to use the type encodings
It's only a start: the output is, if anything, slightly worse than
before, but it does have the basics going.
2020-02-23 19:01:59 +09:00
Bill Currie 4b7ecdf74a Make PR_Init take an instance to initialize
This allows internal sub-systems to do per-instance initializations
without other engine systems having to know about them.
2020-02-23 18:32:16 +09:00
Bill Currie 81083698a8 Move to using an in-memory form of ddef_t
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie c296514b95 Make pr.load_file 'return' the file size 2020-02-21 21:17:28 +09:00
Bill Currie 533fb8acc9 Implement double constants 2020-02-15 23:49:12 +09:00
Bill Currie f68129dc0f Try to use type encodings for function return type
Now return statements in traces make much more sense.
2019-06-09 18:11:56 +09:00
Bill Currie 8fd5be0ee0 Fix a pile of sizeof goofs.
While scan-build wasn't what I was looking for, it has proven useful
anyway: many of the sizeof errors were just noise, but a few were actual
bugs (allocating too much or too little memory).
2018-09-07 20:00:57 +09:00
Bill Currie c25e68ecaf Use hex output for %E opcode format specifier.
This makes %E's addresses consistent with other address output.
2013-01-17 16:42:28 +09:00
Bill Currie 6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie cc35209f86 Yet more char index issues :P 2012-08-18 12:20:08 +09:00
Bill Currie d73b5045d8 Do not do any contents evaluation if not printing contents.
Fixes a segfault when tracing progs caused by the recent entity number
change.
2012-07-18 10:46:59 +09:00
Bill Currie 23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00