Page MenuHomeGitPull.it

Libre BusTO Android Crash Analyzer
ActivePublic

Authored by valerio.bozzolan on Feb 15 2021, 21:24.
Referenced Files
F2628115: Libre BusTO Android Crash Analyzer
Thu, Jan 9, 15:54
F1485467: Libre BusTO Android Crash Analyzer
May 17 2021, 11:13
F1466049: Libre BusTO Android Crash Analyzer
Feb 15 2021, 21:29
F1466048: Libre BusTO Android Crash Analyzer
Feb 15 2021, 21:28
F1466047: Libre BusTO Android Crash Analyzer
Feb 15 2021, 21:24
F1466046: Libre BusTO Android Crash Analyzer
Feb 15 2021, 21:24
Subscribers
None
<?php
# Android Crash Dump exporter for Phabricator
# Copyright (C) 2021-2024 Valerio Bozzolan, crash report contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
/**
* Quick and dirty Android Crash Dump analyzer
*
* https://gitpull.it/P15
*/
$logcat_max_lines = 50;
// base of your Phabricator
define( 'BASE_URI', 'https://gitpull.it/maniphest/task/edit/form/3/?' );
// received data
$data_raw = $_POST['data'] ?? null;
$data_clean_text = null;
$task_args = null;
if( $data_raw ) {
$data = @json_decode( $data_raw );
if( $data ) {
$data_raw = json_encode( $data, JSON_PRETTY_PRINT );
$app_version_name = $data->APP_VERSION_NAME ?? null;
// Take only some lines of logcat.
$logcat_reduced = null;
$logcat = $data->LOGCAT ?? null;
if ($logcat) {
$lines = explode("\n", $logcat);
$last_lines = [];
for ($i = 0; $i < 50 && $lines; $i++) {
$last_lines[] = array_pop($lines);
}
$last_lines = array_reverse($last_lines);
$logcat_reduced = implode("\n", $last_lines);
}
// some useful informations
$data_clean = [
'Version code' => $data->APP_VERSION_CODE ?? null,
'Version name' => $app_version_name,
'Android version' => $data->ANDROID_VERSION ?? null,
'Phone' => $data->PHONE_MODEL ?? null,
'Brand' => $data->BRAND ?? null,
'Stack' => $data->STACK_TRACE ?? null,
"logcat (last $logcat_max_lines lines)" => $logcat_reduced,
];
// build an human phrase
$data_clean_parts = [];
foreach( $data_clean as $k => $v ) {
$data_clean_parts[] = "$k:\n$v";
}
$data_clean_text = implode( "\n\n", $data_clean_parts );
$data_clean_text = trim($data_clean_text);
// build query string
$task_args = [
'title' => "Fix crash caused by ... on version $app_version_name",
'description' => implode( "\n", [
"Dear Developers of the amazing Free/Libre and Open Source app #libre_busto,",
"Please triage my crash:",
'',
'```',
$data_clean_text,
'```',
'',
'',
"Thank you! :)",
'',
'',
"> Generated with https://lab.reyboz.it/libre-busto/crash-report/ (P15)",
] ),
];
} else {
$data_raw = 'invalid';
}
}
?>
<html>
<head>
<title>Libre BusTO - crash report dump</title>
</head>
<body>
<h1>Libre BusTO - crash report dump</h1>
<form method="post">
<?php if( $data_clean_text ): ?>
<h2>Generated Crash report</h2>
<?php if( $task_args ): ?>
<p>
<a href="<?= htmlspecialchars( BASE_URI . http_build_query( $task_args ) )?>" target="_blank">Create New Task in Phorge</a>
</p>
<?php endif ?>
<p>Preview of Task Content:<br />
<textarea readonly><?= htmlentities( $data_clean_text ) ?></textarea>
</p>
<?php endif ?>
<h2>Generate New Crash Report</h2>
<p>Paste here your JSON crash report:</p>
<p><textarea name="data"><?= htmlentities( $data_raw ) ?></textarea></p>
<p><button type="submit">OK</button></p>
</form>
<hr />
<p><a href="https://gitpull.it/tag/libre_busto/">Workboard</a></p>
<hr />
<p><a href="https://gitpull.it/P15" target="_blank">Source code and license</a></p>
</body>
</html>

Event Timeline