mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-04 15:43:00 +00:00
@@ -625,6 +625,15 @@ final class ComputerExecutor
|
||||
}
|
||||
}
|
||||
|
||||
void printState( StringBuilder out )
|
||||
{
|
||||
out.append( "Enqueued command: " ).append( command ).append( '\n' );
|
||||
out.append( "Enqueued events: " ).append( eventQueue.size() ).append( '\n' );
|
||||
|
||||
ILuaMachine machine = this.machine;
|
||||
if( machine != null ) machine.printExecutionState( out );
|
||||
}
|
||||
|
||||
private void displayFailure( String message, String extra )
|
||||
{
|
||||
Terminal terminal = computer.getTerminal();
|
||||
|
||||
@@ -575,18 +575,22 @@ public final class ComputerThread
|
||||
StringBuilder builder = new StringBuilder()
|
||||
.append( "Terminating computer #" ).append( executor.getComputer().getID() )
|
||||
.append( " due to timeout (running for " ).append( time * 1e-9 )
|
||||
.append( " seconds). This is NOT a bug, but may mean a computer is misbehaving. " )
|
||||
.append( " seconds). This is NOT a bug, but may mean a computer is misbehaving.\n" )
|
||||
.append( "Thread " )
|
||||
.append( owner.getName() )
|
||||
.append( " is currently " )
|
||||
.append( owner.getState() );
|
||||
.append( owner.getState() )
|
||||
.append( '\n' );
|
||||
Object blocking = LockSupport.getBlocker( owner );
|
||||
if( blocking != null ) builder.append( "\n on " ).append( blocking );
|
||||
if( blocking != null ) builder.append( " on " ).append( blocking ).append( '\n' );
|
||||
|
||||
for( StackTraceElement element : owner.getStackTrace() )
|
||||
{
|
||||
builder.append( "\n at " ).append( element );
|
||||
builder.append( " at " ).append( element ).append( '\n' );
|
||||
}
|
||||
|
||||
executor.printState( builder );
|
||||
|
||||
ComputerCraft.log.warn( builder.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,6 +214,20 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printExecutionState( StringBuilder out )
|
||||
{
|
||||
LuaState state = this.state;
|
||||
if( state == null )
|
||||
{
|
||||
out.append( "CobaltLuaMachine is terminated\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
state.printExecutionState( out );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
@@ -61,6 +61,15 @@ public interface ILuaMachine
|
||||
*/
|
||||
MachineResult handleEvent( @Nullable String eventName, @Nullable Object[] arguments );
|
||||
|
||||
/**
|
||||
* Print some information about the internal execution state.
|
||||
* <p>
|
||||
* This function is purely intended for debugging, its output should not be relied on in any way.
|
||||
*
|
||||
* @param out The buffer to write to.
|
||||
*/
|
||||
void printExecutionState( StringBuilder out );
|
||||
|
||||
/**
|
||||
* Close the Lua machine, aborting any running functions and deleting the internal state.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user