Skip to content

Bug: Terminal Silently Drops Consecutive Duplicate Commands #106

@Jayant-kernel

Description

@Jayant-kernel

� Bug: Terminal Silently Drops Consecutive Duplicate Commands

Description

When using the debug control buttons (e.g., clicking "Next" or "Step" twice in a row), the second click is completely ignored by the terminal and backend.

Root Cause

In TerminalComp.jsx, the useEffect that triggers commands relies on toggling commandPress to run:

  useEffect(() => {
    if (terminalOutput) {
      defaultHandler(terminalOutput);
    }
  }, [commandPress]); 

However:

  1. If the same command is sent consecutively, terminalOutput remains the same.
  2. commandPress toggles back to its previous boolean state.
  3. React bails out of the effect because the dependencies haven't changed in a way that triggers a re-render/effect execution.
  4. terminalOutput is missing from the dependency array, violating React hooks exhaustive-deps rules.

Expected behaviour

Clicking "Next" three times should execute the next GDB command three times.

To Reproduce

  1. Start a debugging session.
  2. Click the "Next" (arrow right) button in the DebugHeader.
  3. The terminal executes next.
  4. Click the same "Next" button again.
  5. Bug: Nothing happens. The command is dropped.

Suggested Fix

Refactor the global state to use an event emitter or replace the boolean toggle with an incrementing counter (e.g., setCommandCount(prev => prev + 1)) so the dependency array always sees a new value on every button click.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions