@@ -1798,22 +1798,25 @@ export class Kernel implements IKernel {
1798
1798
doSyscall ( syscall : Syscall ) : void {
1799
1799
if ( syscall . name in this . syscalls ) {
1800
1800
if ( STRACE ) {
1801
- let argfmt = ( arg : any ) : any => {
1802
- if ( arg instanceof Uint8Array ) {
1801
+ let argfmt = ( arg : any ) : string => {
1802
+ if ( arg . constructor === Uint8Array ) {
1803
1803
let len = arg . length ;
1804
1804
if ( len > 0 && arg [ len - 1 ] === 0 )
1805
1805
len -- ;
1806
- return utf8Slice ( arg , 0 , len ) ;
1806
+ return '(' + len + ') ' + utf8Slice ( arg , 0 , len > 32 ? 32 : len ) ;
1807
+ } else if ( typeof arg === 'string' && arg . length > 32 ) {
1808
+ return arg . slice ( 0 , 32 ) ;
1807
1809
} else {
1808
- return arg ;
1810
+ return '' + arg ;
1809
1811
}
1810
1812
} ;
1811
1813
1812
1814
if ( syscall . args === undefined )
1813
1815
syscall . args = [ undefined ] ;
1814
1816
let arg = argfmt ( syscall . args [ 0 ] ) ;
1815
- if ( syscall . args [ 1 ] )
1817
+ if ( syscall . args [ 1 ] ) {
1816
1818
arg += '\t' + argfmt ( syscall . args [ 1 ] ) ;
1819
+ }
1817
1820
console . log ( '[' + syscall . ctx . task . pid + '|' + syscall . ctx . id + '] \tsys_' + syscall . name + '\t' + arg ) ;
1818
1821
}
1819
1822
this . syscalls [ syscall . name ] . apply ( this . syscalls , syscall . callArgs ( ) ) ;
@@ -2351,8 +2354,16 @@ export class Task implements ITask {
2351
2354
2352
2355
this . state = TaskState . Running ;
2353
2356
2354
- if ( STRACE )
2355
- console . log ( '[' + this . pid + '|' + msg . id + '] \tCOMPLETE' ) ; // ' + JSON.stringify(msg));
2357
+ if ( STRACE ) {
2358
+ let add = ' ' ;
2359
+ if ( msg . args && msg . args . length > 1 ) {
2360
+ if ( msg . args [ 1 ] . constructor !== Uint8Array )
2361
+ add += msg . args [ 1 ] ;
2362
+ else
2363
+ add += msg . args [ 1 ] . byteLength ;
2364
+ }
2365
+ console . log ( '[' + this . pid + '|' + msg . id + '] \tDONE' + add ) ; // ' + JSON.stringify(msg));
2366
+ }
2356
2367
this . worker . postMessage ( msg , transferrable || [ ] ) ;
2357
2368
}
2358
2369
0 commit comments