Skip to content

Conversation

@nuive
Copy link
Contributor

@nuive nuive commented Sep 29, 2025

When mGBA used Threading, the debugger ignored this and would run even when the thread status was not RUNNING. This issue has been addressed by allowing the debugger to know thread's current status at every momment.
Mutex handling has also been added (when using threads) to prevent unwanted or unpredictable changes during critical sections.

Between this and #3602 issue #3355 should be fixed.

Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure what this fixes. It looks like it's just leaking the thread abstraction into the debugger, but only for one check on one callsite that could be done outside the function. Am I missing something?


void mDebuggerUnsetThread(struct mDebugger* debugger) {
if (debugger->threadImpl) {
debugger->threadImpl = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debugger->threadImpl = 0;
debugger->threadImpl = NULL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought 0 was the prefered C sintax and NULL for C++?

void mDebuggerAttachModule(struct mDebugger*, struct mDebuggerModule*);
void mDebuggerDetachModule(struct mDebugger*, struct mDebuggerModule*);
void mDebuggerRunTimeout(struct mDebugger* debugger, int32_t timeoutMs);
void mDebuggerRunTimeout(struct mDebugger*, int32_t);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave the name timeoutMs in the signature. I remove parameter names that are obvious, but timeoutMs includes the unit, which just int32_t doesn't.

debugger->platform->checkBreakpoints(debugger->platform);
bool hasBreakpoints = debugger->platform->hasBreakpoints(debugger->platform);
#ifndef DISABLE_THREADING
if (impl) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all of these checks can be put outside of the switch statement by just doing an unlock before and lock afterwards. The only exceptions are the early exit if the thread is paused, which doesn't really seem like it belongs in this function anyway (are there any other callsites that can't do the check itself?), and the two cases at the end, which you can do an early check for before unlocking. By doing the checks external to the switch statement, you can reduce duplication of code and massively reduce the diff size at the same time.

@nuive
Copy link
Contributor Author

nuive commented Nov 2, 2025

I'm really not sure what this fixes. It looks like it's just leaking the thread abstraction into the debugger, but only for one check on one callsite that could be done outside the function. Am I missing something?

I tried it, but if I do that inside _mCoreThreadRun all commands entered in the debugger window never reach debugger. It never pauses, it never shows help...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants