$crash_offset = parseblock($matches, $crash["applicationname"]); if ($crash_offset == "") { $crash_offset = parseblock($matches, $crash["bundleidentifier"]); } if ($crash_offset == "") { preg_match('%Thread [0-9]+ Crashed:.*?\\n(.*?)\\n\\n%is', $crash["logdata"], $matches); $crash_offset = parseblock($matches, $crash["applicationname"]); if ($crash_offset == "") { $crash_offset = parseblock($matches, $crash["bundleidentifier"]); } } if ($crash_offset == "") { preg_match('%Thread [0-9]+ Crashed:\\n(.*?)\\n\\n%is', $crash["logdata"], $matches); $crash_offset = parseblock($matches, $crash["applicationname"]); if ($crash_offset == "") { $crash_offset = parseblock($matches, $crash["bundleidentifier"]); } } // stores the group this crashlog is associated to, by default to none $log_groupid = 0; // if the offset string is not empty, we try a grouping if (strlen($crash_offset) > 0) { // get all the known bug patterns for the current app version $query = "SELECT id, fix, amount, description FROM " . $dbgrouptable . " WHERE bundleidentifier = '" . $crash["bundleidentifier"] . "' and affected = '" . $crash["version"] . "' and pattern = '" . mysql_real_escape_string($crash_offset) . "'"; $result = mysql_query($query) or die(xml_for_result(FAILURE_SQL_FIND_KNOWN_PATTERNS)); $numrows = mysql_num_rows($result); if ($numrows == 1) { // assign this bug to the group $row = mysql_fetch_row($result); $log_groupid = $row[0]; $amount = $row[2];
} // now try to find the offset of the crashing thread to assign this crash to a crash group // this stores the offset which we need for grouping $crash_offset = ""; // extract the block which contains the data of the crashing thread preg_match('%Thread [0-9]+ Crashed:.*?\\n(.*?)\\n\\n%is', $logdata, $matches); $crash_offset = parseblock($matches, $applicationname); if ($crash_offset == "") { $crash_offset = parseblock($matches, $bundleidentifier); } if ($crash_offset == "") { preg_match('%Thread [0-9]+ Crashed:\\n(.*?)\\n\\n%is', $logdata, $matches); $crash_offset = parseblock($matches, $applicationname); } if ($crash_offset == "") { $crash_offset = parseblock($matches, $bundleidentifier); } /* preg_match('%Thread [0-9]+ Crashed:\n(.*?)\n\n%is', $logdata, $matches); //make sure $matches[1] exists if (is_array($matches) && count($matches) >= 2) { $result = explode("\n", $matches[1]); foreach ($result as $line) { // search for the first occurance of the application name if (strpos($line, $applicationname) !== false) { preg_match('/[0-9]+\s+[^\s]+\s+([^\s]+) /', $line, $matches);
} if ($crash_offset == "") { /* error_log("Unable to locate crash offset, trying second approach: "); */ preg_match('%Thread [0-9]+ Crashed(.*)%is', $crash["logdata"], $matches); $crash_offset = parseblock($matches, $crash["applicationname"]); } if ($crash_offset == "") { $crash_offset = parseblock($matches, $crash["bundleidentifier"]); } if ($crash_offset == "") { # Catches our frameworks $crash_offset = parseblock($matches, 'com.panic'); } if ($crash_offset == "") { # Catches Apple's frameworks $crash_offset = parseblock($matches, 'com.apple'); } if ($crash_offset == "" && $crash['version'] == '???') { /* error_log("Unable to determine crash offset and version unknown\n"); */ continue; } else { if ($crash_offset == "") { /* error_log("Unable to determine crash offset\n"); */ exit(1); } } // print_r($crash_offset); // check if the version is already added and the status of the version and notify status $query = "SELECT id, status, notify FROM " . $dbversiontable . " WHERE bundleidentifier = '" . $crash["bundleidentifier"] . "' and version = '" . $crash["version"] . "'"; $result = mysql_query($query) or die(xml_for_result(FAILURE_SQL_CHECK_VERSION_EXISTS)); $numrows = mysql_num_rows($result);