@@ -1083,18 +1083,16 @@ function getCharacterCodePoint(ch: string) {
1083
1083
class GDBStandardOutputAdapter extends stream . Transform {
1084
1084
private utf8StringDecoder = new string_decoder . StringDecoder ( "utf8" ) ;
1085
1085
1086
- constructor ( private deviceIdentifier : string ,
1087
- private $deviceLogProvider : Mobile . IDeviceLogProvider ,
1088
- private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ) {
1089
- super ( ) ;
1086
+ constructor ( opts ?:stream . TransformOptions ) {
1087
+ super ( opts ) ;
1090
1088
}
1091
1089
1092
- public _transform ( packet : any , encoding : string , done : Function ) : void {
1090
+ public _transform ( packet :any , encoding :string , done :Function ) :void {
1093
1091
try {
1094
1092
let result = "" ;
1095
1093
1096
1094
for ( let i = 0 ; i < packet . length ; i ++ ) {
1097
- if ( packet [ i ] === getCharacterCodePoint ( "$" ) ) {
1095
+ if ( packet [ i ] === getCharacterCodePoint ( "$" ) ) {
1098
1096
let start = ++ i ;
1099
1097
1100
1098
while ( packet [ i ] !== getCharacterCodePoint ( "#" ) ) {
@@ -1106,7 +1104,7 @@ class GDBStandardOutputAdapter extends stream.Transform {
1106
1104
i ++ ;
1107
1105
i ++ ;
1108
1106
1109
- if ( ! ( packet [ start ] === getCharacterCodePoint ( "O" ) && packet [ start + 1 ] !== getCharacterCodePoint ( "K" ) ) ) {
1107
+ if ( ! ( packet [ start ] === getCharacterCodePoint ( "O" ) && packet [ start + 1 ] !== getCharacterCodePoint ( "K" ) ) ) {
1110
1108
continue ;
1111
1109
}
1112
1110
start ++ ;
@@ -1116,13 +1114,6 @@ class GDBStandardOutputAdapter extends stream.Transform {
1116
1114
result += this . utf8StringDecoder . write ( hex ) ;
1117
1115
}
1118
1116
}
1119
-
1120
- if ( this . $deviceLogProvider ) {
1121
- fiberBootstrap . run ( ( ) =>
1122
- this . $deviceLogProvider . logData ( result , this . $devicePlatformsConstants . iOS , this . deviceIdentifier )
1123
- ) ;
1124
- }
1125
-
1126
1117
done ( null , result ) ;
1127
1118
} catch ( e ) {
1128
1119
done ( e ) ;
@@ -1159,11 +1150,26 @@ class GDBSignalWatcher extends stream.Writable {
1159
1150
}
1160
1151
}
1161
1152
}
1153
+ class GDBEchoStream extends stream . Writable {
1154
+ constructor ( private deviceIdentifier : string ,
1155
+ private $deviceLogProvider : Mobile . IDeviceLogProvider ,
1156
+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ) {
1157
+ super ( ) ;
1158
+ }
1159
+
1160
+ _write ( chunk :any , enc :string , done :Function ) {
1161
+ if ( this . $deviceLogProvider ) {
1162
+ fiberBootstrap . run ( ( ) => {
1163
+ this . $deviceLogProvider . logData ( chunk . toString ( ) , this . $devicePlatformsConstants . iOS , this . deviceIdentifier ) ;
1164
+ } ) ;
1165
+ }
1166
+ done ( ) ;
1167
+ }
1168
+ }
1162
1169
1163
1170
export class GDBServer implements Mobile . IGDBServer {
1164
1171
private okResponse = "$OK#" ;
1165
1172
private isInitilized = false ;
1166
-
1167
1173
constructor ( private socket : any , // socket is fd on Windows and net.Socket on mac
1168
1174
private deviceIdentifier : string ,
1169
1175
private $injector : IInjector ,
@@ -1192,7 +1198,6 @@ export class GDBServer implements Mobile.IGDBServer {
1192
1198
this . awaitResponse ( "QSetDisableASLR:1" ) . wait ( ) ;
1193
1199
let encodedArguments = _ . map ( argv , ( arg , index ) => util . format ( "%d,%d,%s" , arg . length * 2 , index , this . toHex ( arg ) ) ) . join ( "," ) ;
1194
1200
this . awaitResponse ( "A" + encodedArguments ) . wait ( ) ;
1195
-
1196
1201
this . isInitilized = true ;
1197
1202
}
1198
1203
} ) . future < void > ( ) ( ) ;
@@ -1215,7 +1220,7 @@ export class GDBServer implements Mobile.IGDBServer {
1215
1220
this . sendCore ( this . encodeData ( "D" ) ) ;
1216
1221
}
1217
1222
} else {
1218
- this . socket . pipe ( this . $injector . resolve ( GDBStandardOutputAdapter , { deviceIdentifier : this . deviceIdentifier } ) ) ;
1223
+ this . socket . pipe ( new GDBStandardOutputAdapter ( ) ) . pipe ( this . $injector . resolve ( GDBEchoStream , { deviceIdentifier : this . deviceIdentifier } ) ) ;
1219
1224
this . socket . pipe ( new GDBSignalWatcher ( ) ) ;
1220
1225
this . sendCore ( this . encodeData ( "vCont;c" ) ) ;
1221
1226
}
0 commit comments