2020-06-15 07:18:57 -07:00
|
|
|
#if 0
|
|
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
|
|
│ as it is written in the following disclaimers: │
|
|
|
|
│ • http://unlicense.org/ │
|
|
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
|
|
#endif
|
2024-09-11 02:14:38 -07:00
|
|
|
#include <cosmo.h>
|
2020-06-15 07:18:57 -07:00
|
|
|
|
|
|
|
/**
|
2021-03-05 06:09:12 -08:00
|
|
|
* @fileoverview How to print backtraces and cpu state on crash.
|
2020-06-15 07:18:57 -07:00
|
|
|
*
|
2021-03-05 06:09:12 -08:00
|
|
|
* make -j8 -O o//examples/crashreport.com
|
|
|
|
* o//examples/crashreport.com
|
2020-06-15 07:18:57 -07:00
|
|
|
*
|
|
|
|
* To prevent the GDB GUI from popping up:
|
|
|
|
*
|
2021-03-05 06:09:12 -08:00
|
|
|
* export GDB=
|
|
|
|
* make -j8 -O o//examples/crashreport.com
|
|
|
|
* o//examples/crashreport.com
|
2020-06-15 07:18:57 -07:00
|
|
|
*/
|
|
|
|
|
2024-05-30 15:11:45 -07:00
|
|
|
int Divide(int x, int y) {
|
|
|
|
volatile int z = 0; // force creation of stack frame
|
|
|
|
return x / y + z;
|
|
|
|
}
|
|
|
|
|
|
|
|
int (*pDivide)(int, int) = Divide;
|
|
|
|
|
2023-07-26 13:54:49 -07:00
|
|
|
dontubsan int main(int argc, char *argv[]) {
|
2022-10-17 11:02:04 -07:00
|
|
|
kprintf("----------------\n");
|
|
|
|
kprintf(" THIS IS A TEST \n");
|
|
|
|
kprintf("SIMULATING CRASH\n");
|
|
|
|
kprintf("----------------\n");
|
|
|
|
|
2022-03-21 03:46:16 -07:00
|
|
|
ShowCrashReports();
|
2023-06-04 08:19:45 -07:00
|
|
|
|
2024-05-30 15:11:45 -07:00
|
|
|
pDivide(1, 0);
|
|
|
|
pDivide(2, 0);
|
|
|
|
pDivide(3, 0);
|
2020-06-15 07:18:57 -07:00
|
|
|
}
|