Skip to content

Commit

Permalink
feat(#172): Timeout of mutex augmented
Browse files Browse the repository at this point in the history
  • Loading branch information
prb28 committed Dec 16, 2021
1 parent a0296a8 commit 125951f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/breakpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BreakpointManager {
/** Temporary breakpoints arrays */
private temporaryBreakpointArrays = new Array<GdbTemporaryBreakpointArray>();
/** Mutex to just have one call to gdb */
protected mutex = new Mutex(100, 1200);
protected mutex = new Mutex(100, 180000);
/** Lock for breakpoint management function */
protected breakpointLock?: () => void;

Expand All @@ -45,6 +45,14 @@ export class BreakpointManager {
this.debugInfo = debugInfo;
}

/**
* Set the mutex timeout
* @param timeout Mutex timeout
*/
public setMutexTimeout(timeout: number): void {
this.mutex = new Mutex(100, timeout);
}

public addPendingBreakpoint(breakpoint: GdbBreakpoint, err?: Error): void {
breakpoint.verified = false;
if (err) {
Expand Down
9 changes: 8 additions & 1 deletion src/fsUAEDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
}

export class FsUAEDebugSession extends DebugSession implements DebugVariableResolver {
// a Mock runtime (or debugger)
/** Timeout of the mutex */
protected static readonly MUTEX_TIMEOUT = 100000;

/** a Mock runtime (or debugger) */
protected variableHandles = new Handles<string>();

/** Proxy to Gdb */
Expand Down Expand Up @@ -123,10 +126,12 @@ export class FsUAEDebugSession extends DebugSession implements DebugVariableReso
this.setDebuggerLinesStartAt1(false);
this.setDebuggerColumnsStartAt1(false);
this.gdbProxy = this.createGdbProxy();
this.gdbProxy.setMutexTimeout(FsUAEDebugSession.MUTEX_TIMEOUT);
this.initProxy();
this.executor = new ExecutorHelper();
this.debugDisassembledManager = new DebugDisassembledManager(this.gdbProxy, undefined, this);
this.breakpointManager = new BreakpointManager(this.gdbProxy, this.debugDisassembledManager);
this.breakpointManager.setMutexTimeout(FsUAEDebugSession.MUTEX_TIMEOUT);
}

/**
Expand All @@ -145,11 +150,13 @@ export class FsUAEDebugSession extends DebugSession implements DebugVariableReso
public setTestContext(gdbProxy: GdbProxy, executor: ExecutorHelper, capstone: Capstone): void {
this.executor = executor;
this.gdbProxy = gdbProxy;
this.gdbProxy.setMutexTimeout(1000);
this.initProxy();
this.testMode = true;
this.capstone = capstone;
this.debugDisassembledManager = new DebugDisassembledManager(gdbProxy, capstone, this);
this.breakpointManager = new BreakpointManager(this.gdbProxy, this.debugDisassembledManager);
this.breakpointManager.setMutexTimeout(1000);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/gdbProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class GdbProxy extends EventEmitter {
/** Flag for the first stop - to install the breakpoints */
protected firstStop = true;
/** Mutex to just have one call to gdb */
protected mutex = new Mutex(100, 1200);
protected mutex = new Mutex(100, 60000);
/** vCont commands are supported */
protected supportVCont = false;
/** Created threads */
Expand Down Expand Up @@ -78,6 +78,14 @@ export class GdbProxy extends EventEmitter {
this.threadsNative = new Map<string, GdbThread>();
}

/**
* Set the mutex timeout
* @param timeout Mutex timeout
*/
public setMutexTimeout(timeout: number): void {
this.mutex = new Mutex(100, timeout);
}

/**
* Waits for the debugger connected
*/
Expand Down

0 comments on commit 125951f

Please sign in to comment.