Clear fork on-kill callbacks and update disable-task bad test golden outputs.

This commit is contained in:
Nick Brereton 2026-02-24 22:17:52 -05:00
parent bc2b8535f5
commit c8132b3a77
5 changed files with 34 additions and 17 deletions

View File

@ -243,6 +243,12 @@ void VlProcess::forkSyncOnKill(VlForkSync* forkSyncp) {
m_forkSyncOnKillDone = false;
}
void VlProcess::forkSyncOnKillClear(VlForkSync* forkSyncp) {
if (m_forkSyncOnKillp != forkSyncp) return;
m_forkSyncOnKillp = nullptr;
m_forkSyncOnKillDone = false;
}
void VlProcess::state(int s) {
if (s == KILLED && m_state != KILLED && m_state != FINISHED && m_forkSyncOnKillp
&& !m_forkSyncOnKillDone) {
@ -254,8 +260,16 @@ void VlProcess::state(int s) {
m_state = s;
}
VlForkSync::~VlForkSync() {
for (std::weak_ptr<VlProcess>& weakp : m_onKillProcessps) {
if (VlProcessRef processp = weakp.lock()) processp->forkSyncOnKillClear(this);
}
}
void VlForkSync::onKill(VlProcessRef process) {
if (process) process->forkSyncOnKill(this);
if (!process) return;
m_onKillProcessps.emplace_back(process);
process->forkSyncOnKill(this);
}
void VlForkSync::done(const char* filename, int lineno) {

View File

@ -393,8 +393,10 @@ class VlForkSync final {
// The join info is shared among all forked processes
std::shared_ptr<VlJoin> m_join;
std::vector<std::weak_ptr<VlProcess>> m_onKillProcessps; // Branches registered for kill hooks
public:
~VlForkSync();
// Create the join object and set the counter to the specified number
void init(size_t count, VlProcessRef process) { m_join.reset(new VlJoin{count, {process}}); }
// Register process kill callback so killed fork branches still decrement join counter

View File

@ -157,6 +157,7 @@ public:
for (VlProcess* childp : m_children) childp->disable();
}
void forkSyncOnKill(VlForkSync* forkSyncp);
void forkSyncOnKillClear(VlForkSync* forkSyncp);
bool completed() const { return state() == FINISHED || state() == KILLED; }
bool completedFork() const {
for (const VlProcess* const childp : m_children)

View File

@ -1,20 +1,20 @@
%Error: t/t_disable_task_scope_bad.v:34:18: Can't find definition of 'missing_task' in dotted block/task: 'ifc1.missing_task'
34 | disable ifc1.missing_task;
%Error: t/t_disable_task_scope_bad.v:36:18: Can't find definition of 'missing_task' in dotted block/task: 'ifc1.missing_task'
36 | disable ifc1.missing_task;
| ^~~~~~~~~~~~
... Known scopes under 'ifc1': <no instances found>
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: t/t_disable_task_scope_bad.v:35:19: Can't find definition of 'missing_task' in dotted block/task: 'prog1.missing_task'
35 | disable prog1.missing_task;
%Error: t/t_disable_task_scope_bad.v:37:19: Can't find definition of 'missing_task' in dotted block/task: 'prog1.missing_task'
37 | disable prog1.missing_task;
| ^~~~~~~~~~~~
... Known scopes under 'prog1': <no instances found>
%Error: t/t_disable_task_scope_bad.v:36:26: Can't find definition of 'missing_task' in dotted block/task: 'outer1.inner.missing_task'
36 | disable outer1.inner.missing_task;
%Error: t/t_disable_task_scope_bad.v:38:26: Can't find definition of 'missing_task' in dotted block/task: 'outer1.inner.missing_task'
38 | disable outer1.inner.missing_task;
| ^~~~~~~~~~~~
... Known scopes under 'outer1.inner': <no instances found>
%Error: t/t_disable_task_scope_bad.v:37:18: Found definition of 'ifc1.data' as a VAR but expected a block/task
37 | disable ifc1.data;
%Error: t/t_disable_task_scope_bad.v:39:18: Found definition of 'ifc1.data' as a VAR but expected a block/task
39 | disable ifc1.data;
| ^~~~
%Error: t/t_disable_task_scope_bad.v:38:19: Found definition of 'prog1.data' as a VAR but expected a block/task
38 | disable prog1.data;
%Error: t/t_disable_task_scope_bad.v:40:19: Found definition of 'prog1.data' as a VAR but expected a block/task
40 | disable prog1.data;
| ^~~~
%Error: Exiting due to

View File

@ -1,11 +1,11 @@
%Error: t/t_disable_task_target_bad.v:21:13: Found definition of 'foo' as a VAR but expected a block/task
21 | disable foo;
%Error: t/t_disable_task_target_bad.v:23:13: Found definition of 'foo' as a VAR but expected a block/task
23 | disable foo;
| ^~~
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: t/t_disable_task_target_bad.v:22:13: Found definition of 'c' as a VAR but expected a block/task
22 | disable c.run;
%Error: t/t_disable_task_target_bad.v:24:13: Found definition of 'c' as a VAR but expected a block/task
24 | disable c.run;
| ^
%Error: t/t_disable_task_target_bad.v:22:15: Can't find definition of block/task: 'run'
22 | disable c.run;
%Error: t/t_disable_task_target_bad.v:24:15: Can't find definition of block/task: 'run'
24 | disable c.run;
| ^~~
%Error: Exiting due to