private string getPIDfromGDB(string processName, string IP, string password, bool isSimulator, string toolsPath, string publicKeyPath)
{
string PID = "";
string response = GDBParser.GetPIDsThroughGDB(IP, password, isSimulator, toolsPath, publicKeyPath, 7);
if ((response == "TIMEOUT!") || (response.IndexOf("1^error,msg=", 0) != -1)) //found an error
{
if (response == "TIMEOUT!") // Timeout error, normally happen when the device is not connected.
{
MessageBox.Show("Please, verify if the Device/Simulator IP in \"BlackBerry -> Settings\" menu is correct and check if it is connected.", "Device/Simulator not connected or not configured properly", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
if (response[29] == ':') // error: 1^error,msg="169.254.0.3:8000: The requested address is not valid in its context."
{
string txt = response.Substring(13, response.IndexOf(':', 13) - 13) + response.Substring(29, response.IndexOf('"', 31) - 29);
string caption = "";
if (txt.IndexOf("The requested address is not valid in its context.") != -1)
{
txt += "\n\nPlease, verify the BlackBerry device/simulator IP settings.";
caption = "Invalid IP";
}
else
{
txt += "\n\nPlease, verify if the device/simulator is connected.";
caption = "Connection failed";
}
MessageBox.Show(txt, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
response = "";
}
else if (response.Contains("^done"))
{
int i = response.IndexOf(processName + " - ");
if (i != -1)
{
i += processName.Length + 3;
PID = response.Substring(i, response.IndexOf('/', i) - i);
}
}
return PID;
}