Skip to content

Commit

Permalink
Use replay debugger name in example command line
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed Nov 14, 2016
1 parent 440d355 commit 66118a3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/GdbConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ static void push_target_remote_cmd(vector<string>& vec, unsigned short port) {

unique_ptr<GdbConnection> GdbConnection::await_client_connection(
unsigned short desired_port, ProbePort probe, pid_t tgid,
const string& exe_image, const Features& features,
ScopedFd* client_params_fd) {
const string& debugger_name, const string& exe_image,
const Features& features, ScopedFd* client_params_fd) {
auto dbg = unique_ptr<GdbConnection>(new GdbConnection(tgid, features));
unsigned short port = desired_port;
ScopedFd listen_fd = open_socket(connection_addr, &port, probe);
Expand All @@ -155,7 +155,7 @@ unique_ptr<GdbConnection> GdbConnection::await_client_connection(
push_default_gdb_options(options);
push_target_remote_cmd(options, port);
cerr << "Launch gdb with \n"
<< " gdb ";
<< " " << debugger_name << " ";
for (auto& opt : options) {
cerr << "'" << opt << "' ";
}
Expand Down
4 changes: 2 additions & 2 deletions src/GdbConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ class GdbConnection {
};
static std::unique_ptr<GdbConnection> await_client_connection(
unsigned short desired_port, ProbePort probe, pid_t tgid,
const std::string& exe_image, const Features& features,
ScopedFd* client_params_fd = nullptr);
const std::string& debugger_name, const std::string& exe_image,
const Features& features, ScopedFd* client_params_fd = nullptr);

/**
* Exec gdb using the params that were written to
Expand Down
9 changes: 5 additions & 4 deletions src/GdbServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1304,10 +1304,11 @@ static uint32_t get_cpu_features(SupportedArch arch) {

static unique_ptr<GdbConnection> await_connection(
Task* t, unsigned short port, GdbConnection::ProbePort probe,
const GdbConnection::Features& features,
const GdbConnection::Features& features, const string& debugger_name,
ScopedFd* client_params_fd = nullptr) {
auto result = GdbConnection::await_client_connection(
port, probe, t->tgid(), t->vm()->exe_image(), features, client_params_fd);
port, probe, t->tgid(), debugger_name, t->vm()->exe_image(), features,
client_params_fd);

result->set_cpu_features(get_cpu_features(t->arch()));

Expand All @@ -1334,7 +1335,7 @@ void GdbServer::serve_replay(const ConnectionFlags& flags) {
: GdbConnection::PROBE_PORT;
Task* t = timeline.current_session().current_task();
dbg = await_connection(t, port, probe, GdbConnection::Features(),
flags.debugger_params_write_pipe);
flags.debugger_name, flags.debugger_params_write_pipe);
if (flags.debugger_params_write_pipe) {
flags.debugger_params_write_pipe->close();
}
Expand Down Expand Up @@ -1402,7 +1403,7 @@ void GdbServer::emergency_debug(Task* t) {
// mode (and we don't want to require users to do that)
features.reverse_execution = false;
unique_ptr<GdbConnection> dbg =
await_connection(t, t->tid, GdbConnection::PROBE_PORT, features);
await_connection(t, t->tid, GdbConnection::PROBE_PORT, features, "gdb");

GdbServer(dbg, t).process_debugger_requests();
}
Expand Down
3 changes: 3 additions & 0 deletions src/GdbServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class GdbServer {
// parameters through this pipe. GdbServer::launch_gdb is passed the
// other end of this pipe to exec gdb with the parameters.
ScopedFd* debugger_params_write_pipe;
// Name of the debugger to suggest. Only used if debugger_params_write_pipe
// is null.
std::string debugger_name;

ConnectionFlags() : dbg_port(-1), debugger_params_write_pipe(nullptr) {}
};
Expand Down
1 change: 1 addition & 0 deletions src/ReplayCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ static int replay(const string& trace_dir, const ReplayFlags& flags) {
auto session = ReplaySession::create(trace_dir);
GdbServer::ConnectionFlags conn_flags;
conn_flags.dbg_port = flags.dbg_port;
conn_flags.debugger_name = flags.gdb_binary_file_path;
GdbServer(session, session_flags(flags), target).serve_replay(conn_flags);
}
return 0;
Expand Down

0 comments on commit 66118a3

Please sign in to comment.