Fixed not being able to launch the i386 slice of a universal binary by adding

a new "QLaunchArch:<arch-name>" where <arch-name> is the architecture name.
This allows us to remotely launch a debugserver and then set the architecture
for the binary we will launch.

llvm-svn: 131064
This commit is contained in:
Greg Clayton 2011-05-08 04:53:50 +00:00
parent d9ca42aa4f
commit c4103b3c2f
5 changed files with 35 additions and 0 deletions

View File

@ -705,6 +705,26 @@ GDBRemoteCommunicationClient::SendEnvironmentPacket (char const *name_equal_valu
return -1;
}
int
GDBRemoteCommunicationClient::SendLaunchArchPacket (char const *arch)
{
if (arch && arch[0])
{
StreamString packet;
packet.Printf("QLaunchArch:%s", arch);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
{
if (response.IsOKResponse())
return 0;
uint8_t error = response.GetError();
if (error)
return error;
}
}
return -1;
}
bool
GDBRemoteCommunicationClient::GetOSVersion (uint32_t &major,
uint32_t &minor,

View File

@ -123,6 +123,8 @@ public:
int
SendEnvironmentPacket (char const *name_equal_value);
int
SendLaunchArchPacket (const char *arch);
//------------------------------------------------------------------
/// Sends a "vAttach:PID" where PID is in hex.
///

View File

@ -486,6 +486,7 @@ ProcessGDBRemote::DoLaunch
m_gdb_comm.SetDisableASLR (launch_flags & eLaunchFlagDisableASLR);
m_gdb_comm.SendLaunchArchPacket (m_target.GetArchitecture().GetArchitectureName());
if (working_dir && working_dir[0])
{

View File

@ -175,6 +175,7 @@ RNBRemote::CreatePacketTable ()
t.push_back (Packet (set_max_packet_size, &RNBRemote::HandlePacket_QSetMaxPacketSize , NULL, "QSetMaxPacketSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized packet gdb can handle"));
t.push_back (Packet (set_max_payload_size, &RNBRemote::HandlePacket_QSetMaxPayloadSize , NULL, "QSetMaxPayloadSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized payload gdb can handle"));
t.push_back (Packet (set_environment_variable, &RNBRemote::HandlePacket_QEnvironment , NULL, "QEnvironment:", "Add an environment variable to the inferior's environment"));
t.push_back (Packet (set_launch_arch, &RNBRemote::HandlePacket_QLaunchArch , NULL, "QLaunchArch:", "Set the architecture to use when launching a process for hosts that can run multiple architecture slices from universal files."));
t.push_back (Packet (set_disable_aslr, &RNBRemote::HandlePacket_QSetDisableASLR , NULL, "QSetDisableASLR:", "Set wether to disable ASLR when launching the process with the set argv ('A') packet"));
t.push_back (Packet (set_stdin, &RNBRemote::HandlePacket_QSetSTDIO , NULL, "QSetSTDIN:", "Set the standard input for a process to be launched with the 'A' packet"));
t.push_back (Packet (set_stdout, &RNBRemote::HandlePacket_QSetSTDIO , NULL, "QSetSTDOUT:", "Set the standard output for a process to be launched with the 'A' packet"));
@ -1883,6 +1884,15 @@ RNBRemote::HandlePacket_QEnvironment (const char *p)
return SendPacket ("OK");
}
rnb_err_t
RNBRemote::HandlePacket_QLaunchArch (const char *p)
{
p += sizeof ("QLaunchArch:") - 1;
if (DNBSetArchitecture(p))
return SendPacket ("OK");
return SendPacket ("E63");
}
void
append_hex_value (std::ostream& ostrm, const uint8_t* buf, size_t buf_size, bool swap)
{

View File

@ -98,6 +98,7 @@ public:
set_max_packet_size, // 'QSetMaxPacketSize:'
set_max_payload_size, // 'QSetMaxPayloadSize:'
set_environment_variable, // 'QEnvironment:'
set_launch_arch, // 'QLaunchArch:'
set_disable_aslr, // 'QSetDisableASLR:'
set_stdin, // 'QSetSTDIN:'
set_stdout, // 'QSetSTDOUT:'
@ -170,6 +171,7 @@ public:
rnb_err_t HandlePacket_QSetMaxPayloadSize (const char *p);
rnb_err_t HandlePacket_QSetMaxPacketSize (const char *p);
rnb_err_t HandlePacket_QEnvironment (const char *p);
rnb_err_t HandlePacket_QLaunchArch (const char *p);
rnb_err_t HandlePacket_QPrefixRegisterPacketsWithThreadID (const char *p);
rnb_err_t HandlePacket_last_signal (const char *p);
rnb_err_t HandlePacket_m (const char *p);