@@ -26,6 +26,10 @@ use std::rt::io::File;
26
26
use std:: os;
27
27
use std:: str;
28
28
use std:: vec;
29
+ use std:: rt:: io:: net:: tcp;
30
+ use std:: rt:: io:: net:: ip:: { Ipv4Addr , SocketAddr } ;
31
+ use std:: task;
32
+ use std:: rt:: io:: timer;
29
33
30
34
use extra:: test:: MetricMap ;
31
35
@@ -245,6 +249,7 @@ actual:\n\
245
249
}
246
250
247
251
fn run_debuginfo_test( config: & config, props: & TestProps , testfile: & Path ) {
252
+
248
253
// do not optimize debuginfo tests
249
254
let mut config = match config. rustcflags {
250
255
Some ( ref flags) => config {
@@ -254,39 +259,125 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
254
259
None => ( * config) . clone( )
255
260
} ;
256
261
let config = & mut config;
257
- let cmds = props. debugger_cmds. connect( "\n ") ;
258
262
let check_lines = & props. check_lines;
263
+ let mut cmds = props. debugger_cmds. connect( "\n ") ;
259
264
260
265
// compile test file (it shoud have 'compile-flags:-g' in the header)
261
266
let mut ProcRes = compile_test( config, props, testfile) ;
262
267
if ProcRes . status != 0 {
263
268
fatal_ProcRes( ~"compilation failed!", & ProcRes) ;
264
269
}
265
270
266
- // write debugger script
267
- let script_str = [ ~"set charset UTF -8 ",
268
- cmds,
269
- ~"quit\n "] . connect( "\n ") ;
270
- debug!( "script_str = { } ", script_str) ;
271
- dump_output_file( config, testfile, script_str, "debugger. script") ;
272
-
273
- // run debugger script with gdb
274
- #[ cfg( windows) ]
275
- fn debugger( ) -> ~str { ~"gdb. exe" }
276
- #[ cfg( unix) ]
277
- fn debugger( ) -> ~str { ~"gdb" }
278
- let debugger_script = make_out_name( config, testfile, "debugger. script") ;
279
271
let exe_file = make_exe_name( config, testfile) ;
280
- // FIXME (#9639): This needs to handle non-utf8 paths
281
- let debugger_opts = ~[ ~"-quiet", ~"-batch", ~"-nx",
282
- ~"-command=" + debugger_script.as_str().unwrap().to_owned(),
283
- exe_file.as_str().unwrap().to_owned()];
284
- let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
285
- ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], " ", None ) ;
272
+
273
+ let mut ProcArgs ;
274
+ match config. target {
275
+ ~"arm-linux-androideabi" => {
276
+ if ( config. adb_device_status) {
277
+
278
+ cmds = cmds. replace( "run", "continue ") ;
279
+
280
+ // write debugger script
281
+ let script_str = [ ~"set charset UTF-8 ",
282
+ format!( "file { } ", exe_file. as_str( ) . unwrap( ) . to_owned( ) ) ,
283
+ ~"target remote : 5039 ",
284
+ cmds,
285
+ ~"quit"] . connect( "\n ") ;
286
+ debug!( "script_str = { } ", script_str) ;
287
+ dump_output_file( config, testfile, script_str, "debugger. script") ;
288
+
289
+
290
+ procsrv: : run( "" , config. adb_path. clone( ) ,
291
+ [ ~"push", exe_file. as_str( ) . unwrap( ) . to_owned( ) , config. adb_test_dir. clone( ) ] ,
292
+ ~[ ( ~"", ~"") ] , Some ( ~"") ) ;
293
+
294
+ procsrv:: run( "" , config. adb_path,
295
+ [ ~"forward", ~"tcp: 5039 ", ~"tcp: 5039 "] ,
296
+ ~[ ( ~"", ~"") ] , Some ( ~"") ) ;
297
+
298
+ let adb_arg = format!( "export LD_LIBRARY_PATH={}; gdbserver :5039 {}/{}" ,
299
+ config. adb_test_dir. clone( ) , config. adb_test_dir. clone( ) ,
300
+ str :: from_utf8( exe_file. filename( ) . unwrap( ) ) ) . clone( ) ;
301
+
302
+ let mut process = procsrv:: run_background( "" , config. adb_path. clone( ) ,
303
+ [ ~"shell",adb_arg.clone()],~[(~" ",~" ")], Some(~" "));
304
+ loop {
305
+ //waiting 1 second for gdbserver start
306
+ timer::sleep(1000);
307
+ let result = do task::try {
308
+ tcp::TcpStream::connect(
309
+ SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 5039 });
310
+ };
311
+ if result.is_err() {
312
+ continue;
313
+ }
314
+ break;
315
+ }
316
+
317
+ let args = split_maybe_args(&config.rustcflags);
318
+ let mut tool_path:~str = ~" ";
319
+ for arg in args.iter() {
320
+ if arg.contains(" --android-cross-path=") {
321
+ tool_path = arg.replace(" --android-cross-path="," ");
322
+ break;
323
+ }
324
+ }
325
+
326
+ if tool_path.equals(&~" ") {
327
+ fatal(~" cannot found android cross path");
328
+ }
329
+
330
+ let debugger_script = make_out_name(config, testfile, " debugger. script");
331
+ // FIXME (#9639): This needs to handle non-utf8 paths
332
+ let debugger_opts = ~[~" -quiet", ~" -batch", ~" -nx",
333
+ " -command=" + debugger_script.as_str().unwrap().to_owned()];
334
+
335
+ let procsrv::Result{ out, err, status }=
336
+ procsrv::run(" ",
337
+ tool_path.append(" /bin/arm-linux-androideabi-gdb"),
338
+ debugger_opts, ~[(~" ",~" ")], None);
339
+ let cmdline = {
340
+ let cmdline = make_cmdline(" ", " arm-linux-androideabi-gdb", debugger_opts);
341
+ logv(config, format!(" executing { } ", cmdline));
342
+ cmdline
343
+ };
344
+
345
+ ProcRes = ProcRes {status: status,
346
+ stdout: out,
347
+ stderr: err,
348
+ cmdline: cmdline};
349
+ process.force_destroy();
350
+ }
351
+ }
352
+
353
+ _=> {
354
+ // write debugger script
355
+ let script_str = [~" set charset UTF -8 ",
356
+ cmds,
357
+ ~" quit\n "] . connect( "\n " ) ;
358
+ debug!( "script_str = {}" , script_str) ;
359
+ dump_output_file( config, testfile, script_str, "debugger.script" ) ;
360
+
361
+ // run debugger script with gdb
362
+ #[ cfg( windows) ]
363
+ fn debugger( ) -> ~str { ~"gdb. exe" }
364
+ #[cfg(unix)]
365
+ fn debugger() -> ~str { ~" gdb" }
366
+
367
+ let debugger_script = make_out_name(config, testfile, " debugger. script");
368
+
369
+ // FIXME (#9639): This needs to handle non-utf8 paths
370
+ let debugger_opts = ~[~" -quiet", ~" -batch", ~" -nx",
371
+ " -command=" + debugger_script.as_str().unwrap().to_owned(),
372
+ exe_file.as_str().unwrap().to_owned()];
373
+ ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
374
+ ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], " ", None);
375
+ }
376
+ }
377
+
286
378
if ProcRes.status != 0 {
287
379
fatal(~" gdb failed to execute");
288
380
}
289
-
290
381
let num_check_lines = check_lines.len();
291
382
if num_check_lines > 0 {
292
383
// Allow check lines to leave parts unspecified (e.g., uninitialized
@@ -834,7 +925,6 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
834
925
for tv in args.args.iter() {
835
926
runargs.push(tv.to_owned());
836
927
}
837
-
838
928
procsrv::run(" ", config.adb_path, runargs, ~[(~" ",~" ")], Some(~" "));
839
929
840
930
// get exitcode of result
0 commit comments