From: Mikhail Elhimov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
Sergey Bronnikov <sergeyb@tarantool.org>,
Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit v2 7/7] dbg: remove wrong GC state
Date: Fri, 4 Dec 2026 23:03:08 +0300 [thread overview]
Message-ID: <5d1e8f3dfc3da72552592249767cd2f292733763.1796410322.git.m.elhimov@vk.team> (raw)
In-Reply-To: <cover.1796410322.git.m.elhimov@vk.team>
It was copied originally by mistake from the LuaVela fork of LuaJIT.
---
src/luajit_dbg.py | 3 +-
.../debug-extension-tests.py | 98 +++++++++++++++++--
2 files changed, 89 insertions(+), 12 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 2b86be84..637b1edb 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1317,7 +1317,6 @@ def gc_state(g):
3: 'SWEEPSTRING',
4: 'SWEEP',
5: 'FINALIZE',
- 6: 'LAST',
}.get(int(g['gc']['state']), 'INVALID')
@@ -2923,7 +2922,7 @@ class LJState(dbg.LJBase):
lj-state
The command requires no args and dumps current VM and GC states:
* VM state: <{}>
-* GC state: <PAUSE|PROPAGATE|ATOMIC|SWEEPSTRING|SWEEP|FINALIZE|LAST>
+* GC state: <PAUSE|PROPAGATE|ATOMIC|SWEEPSTRING|SWEEP|FINALIZE>
* JIT state: <IDLE|ACTIVE|RECORD|START|END|ASM|ERR>
'''.format('|'.join(list(VM_STATES) + [vm_state_trace('TRACENO')]))
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index f56e6490..f80ce616 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -178,6 +178,23 @@ elif machine == 'arm64' or machine == 'aarch64':
RX_GPR = r'x\d+'
RX_FPR = r'd\d+'
+GCS_PAUSE = 'PAUSE'
+GCS_PROPAGATE = 'PROPAGATE'
+GCS_ATOMIC = 'ATOMIC'
+GCS_SWEEPSTRING = 'SWEEPSTRING'
+GCS_SWEEP = 'SWEEP'
+GCS_FINALIZE = 'FINALIZE'
+
+RX_VALID_GC_STATES = r'({})'.format('|'.join([
+ GCS_PAUSE,
+ GCS_PROPAGATE,
+ GCS_ATOMIC,
+ GCS_SWEEPSTRING,
+ GCS_SWEEP,
+ GCS_FINALIZE,
+]))
+RX_INVALID_GC_STATE = r'INVALID'
+
class TestCaseBase(unittest.TestCase):
@classmethod
@@ -327,23 +344,24 @@ RX_VM_STATE = r'({})'.format('|'.join([
]))
-class TestLJState(TestCaseBase):
- extension_cmds = 'lj-state'
- location = 'lj_cf_print'
- lua_script = 'print(1)'
- pattern = (
+def compose_lj_state_rx(rx_gc_state):
+ return (
r'VM state: ' + RX_VM_STATE + '\n'
- r'GC state: [A-Z]+\n'
+ r'GC state: ' + rx_gc_state + '\n'
r'JIT state: [A-Z]+\n'
)
-class TestLJGC(TestCaseBase):
- extension_cmds = 'lj-gc'
+class TestLJState(TestCaseBase):
+ extension_cmds = 'lj-state'
location = 'lj_cf_print'
lua_script = 'print(1)'
- pattern = (
- r'GC stats: [A-Z]+\n'
+ pattern = compose_lj_state_rx(RX_VALID_GC_STATES)
+
+
+def compose_gc_stats_rx(rx_gc_state):
+ return (
+ r'GC stats: ' + rx_gc_state + '\n'
r'\ttotal: \d+\n'
r'\tthreshold: \d+\n'
r'\tdebt: \d+\n'
@@ -359,6 +377,66 @@ class TestLJGC(TestCaseBase):
)
+class TestLJGC(TestCaseBase):
+ extension_cmds = 'lj-gc'
+ location = 'lj_cf_print'
+ lua_script = 'print(1)'
+ pattern = compose_gc_stats_rx(RX_VALID_GC_STATES)
+
+
+class TestGCStateBase(TestCaseBase):
+ extension_cmds = (
+ 'lj-state\n'
+ 'lj-gc\n'
+ )
+
+ # The same lua code is used to check all the GC states because
+ # it allows to reach any of them:
+ # 1) `gc_mark_start()` (PAUSE) is always present in the full
+ # GC cycle.
+ # 2) `propagatemark()` (PROPAGATE) is reachable because our
+ # build has FFI and the finalizer table is marked as a weak
+ # table, i.e. it is gray. Hence, the g->gc.gray list is not
+ # empty.
+ # 3) `atomic()` (ATOMIC) is always present in the full GC
+ # cycle.
+ # 4) `gc_sweep_str_chain()` (SWEEPSTRING) is always present in
+ # the full GC cycle.
+ # 5) `gc_sweep()` (SWEEP) is always present in the full GC
+ # cycle.
+ # 6) `gc_finalize()` (FINALIZE) is met due to the finalizer to
+ # userdata in the script.
+ lua_script = (
+ 'local obj = newproxy(true)\n'
+ 'getmetatable(obj).__gc = function() end\n'
+ 'obj = nil\n'
+ 'collectgarbage()\n'
+ )
+
+ @classmethod
+ def setUpClass(cls):
+ cls.pattern = (
+ compose_lj_state_rx(cls.gc_state) +
+ compose_gc_stats_rx(cls.gc_state)
+ )
+ super(TestGCStateBase, cls).setUpClass()
+
+
+# Generate the bunch of tests to check various GC states.
+for gc_state, location in [
+ (GCS_PAUSE, 'gc_mark_start'),
+ (GCS_PROPAGATE, 'propagatemark'),
+ (GCS_ATOMIC, 'atomic'),
+ (GCS_SWEEPSTRING, 'gc_sweep_str_chain'),
+ (GCS_SWEEP, 'gc_sweep'),
+ (GCS_FINALIZE, 'gc_finalize'),
+]:
+ test_class_name = 'TestGCState_' + gc_state
+ globals()[test_class_name] = \
+ type(test_class_name, (TestGCStateBase,),
+ dict(gc_state=gc_state, location=location))
+
+
STACK_RX = (
r'-+ Red zone:\s+\d+ slots -+\n'
r'(' + RX_ADDR + r'\s+' + RX_FRAME + r' VALUE: nil\n?)*\n'
--
2.55.0
prev parent reply other threads:[~2026-12-04 20:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:03 [Tarantool-patches] [PATCH luajit v2 0/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 1/7] dbg: simplify composing of all commands output Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 2/7] dbg: cleanup and unify `dbg.eval` Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 3/7] dbg: handle missing cmd arg in a dbg-agnostic way Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 4/7] dbg: add tests of deferred extension loading Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 5/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 6/7] dbg: display fast function name along with ffid Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` Mikhail Elhimov via Tarantool-patches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d1e8f3dfc3da72552592249767cd2f292733763.1796410322.git.m.elhimov@vk.team \
--to=tarantool-patches@dev.tarantool.org \
--cc=e.temirgaleev@tarantool.org \
--cc=m.elhimov@vk.team \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit v2 7/7] dbg: remove wrong GC state' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox