+ std::string gdb_run_file= create_tmpfile(_exectuble_name);
+ std::fstream file_stream;
+ file_stream.open(gdb_run_file.c_str(), std::fstream::out | std::fstream::trunc);
+
+ _gdb_filename= create_tmpfile(_exectuble_name);
+ file_stream
+ << "set logging redirect on" << std::endl
+ << "set logging file " << _gdb_filename << std::endl
+ << "set logging overwrite on" << std::endl
+ << "set logging on" << std::endl
+ << "set environment LIBTEST_IN_GDB=1" << std::endl
+ << "run " << arguments() << std::endl
+ << "thread apply all bt" << std::endl
+ << "quit" << std::endl;
+
+ fatal_assert(file_stream.good());
+ file_stream.close();
+
+ if (_use_libtool)
+ {
+ // libtool --mode=execute gdb -f -x binary
+ char *argv[]= {
+ const_cast<char *>(libtool()),
+ const_cast<char *>("--mode=execute"),
+ const_cast<char *>("gdb"),
+ const_cast<char *>("-batch"),
+ const_cast<char *>("-f"),
+ const_cast<char *>("-x"),
+ const_cast<char *>(gdb_run_file.c_str()),
+ const_cast<char *>(_exectuble_with_path.c_str()),
+ 0};
+
+ spawn_ret= posix_spawnp(&_pid, libtool(), &file_actions, &spawnattr, argv, environ);
+ }
+ else
+ {
+ // gdb binary
+ char *argv[]= {
+ const_cast<char *>("gdb"),
+ const_cast<char *>("-batch"),
+ const_cast<char *>("-f"),
+ const_cast<char *>("-x"),
+ const_cast<char *>(gdb_run_file.c_str()),
+ const_cast<char *>(_exectuble_with_path.c_str()),
+ 0};
+ spawn_ret= posix_spawnp(&_pid, "gdb", &file_actions, &spawnattr, argv, environ);
+ }