public GdbSetup(AndroidProcess process, string gdbToolPath)
{
LoggingUtils.PrintFunction ();
Process = process;
Host = "localhost";
Port = 5039;
if (!Process.HostDevice.IsOverWiFi)
{
Socket = "debug-socket";
}
string sanitisedDeviceId = Process.HostDevice.ID.Replace (':', '-');
CacheDirectory = string.Format (@"{0}\Android++\Cache\{1}\{2}", Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), sanitisedDeviceId, Process.Name);
Directory.CreateDirectory (CacheDirectory);
CacheSysRoot = Path.Combine (CacheDirectory, "sysroot");
Directory.CreateDirectory (CacheSysRoot);
SymbolDirectories = new HashSet<string> ();
GdbToolPath = gdbToolPath;
GdbToolArguments = "--interpreter=mi ";
if (!File.Exists (gdbToolPath))
{
throw new FileNotFoundException ("Could not find requested GDB instance. Expected: " + gdbToolPath);
}
//
// Spawn an initial GDB instance to evaluate the client version.
//
GdbToolVersionMajor = 1;
GdbToolVersionMinor = 0;
using (SyncRedirectProcess gdbProcess = new SyncRedirectProcess (GdbToolPath, "--version"))
{
gdbProcess.StartAndWaitForExit ();
string [] versionDetails = gdbProcess.StandardOutput.Replace ("\r", "").Split (new char [] { '\n' });
string versionPrefix = "GNU gdb (GDB) ";
for (int i = 0; i < versionDetails.Length; ++i)
{
if (versionDetails [i].StartsWith (versionPrefix))
{
string gdbVersion = versionDetails [i].Substring (versionPrefix.Length); ;
string [] gdbVersionComponents = gdbVersion.Split ('.');
if (gdbVersionComponents.Length > 0)
{
GdbToolVersionMajor = int.Parse (gdbVersionComponents [0]);
}
if (gdbVersionComponents.Length > 1)
{
GdbToolVersionMinor = int.Parse (gdbVersionComponents [1]);
}
break;
}
}
}
}