mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Make examples folder somewhat more focused
This commit is contained in:
parent
5141d00992
commit
e26bdbec52
29 changed files with 133 additions and 1225 deletions
|
@ -7,88 +7,23 @@
|
|||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/bits/pushpop.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/nt/enum/errormodeflags.h"
|
||||
#include "libc/nt/signals.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Demonstrates SEGFAULT via NULL pointer dereference.
|
||||
* @fileoverview How to print backtraces and cpu state on crash.
|
||||
*
|
||||
* In MODE=dbg mode, UBSAN should catch this and display a backtrace.
|
||||
* In most other modes, e.g. MODE=balanced, the oncrash.c sig handler
|
||||
* will either launch GDB or display a very fancy report.
|
||||
*
|
||||
* make -j8 -O MODE=opt o/opt/examples/crashreportdemo.com
|
||||
* o/opt/examples/crashreportdemo.com
|
||||
* make -j8 -O o//examples/crashreport.com
|
||||
* o//examples/crashreport.com
|
||||
*
|
||||
* To prevent the GDB GUI from popping up:
|
||||
*
|
||||
* export GDB=""
|
||||
* make -j8 -O MODE=opt o/opt/examples/crashreportdemo.com
|
||||
* o/opt/examples/crashreportdemo.com
|
||||
* export GDB=
|
||||
* make -j8 -O o//examples/crashreport.com
|
||||
* o//examples/crashreport.com
|
||||
*/
|
||||
|
||||
int boo;
|
||||
|
||||
void boop(void);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int64_t res;
|
||||
volatile int64_t x;
|
||||
showcrashreports();
|
||||
res = 0;
|
||||
|
||||
asm volatile("mov\t$0x1111111111111111,%rax\n\t"
|
||||
"mov\t$0x3333333333333333,%rcx\n\t"
|
||||
"mov\t$0x4444444444444444,%rdx\n\t"
|
||||
"mov\t$0x8888888888888888,%r8\n\t"
|
||||
"mov\t$0x9999999999999999,%r9d\n\t"
|
||||
"mov\t$0xaaaaaaaaaaaaaaaa,%r10d\n\t"
|
||||
"mov\t$0xbbbbbbbbbbbbbbbb,%r11d\n\t"
|
||||
"mov\t$0x0000000000000000,%rax\n\t"
|
||||
"movd\t%rax,%xmm0\n\t"
|
||||
"mov\t$0x1111111111111111,%rax\n\t"
|
||||
"push\t%rax\n\t"
|
||||
"push\t%rax\n\t"
|
||||
"movdqu\t(%rsp),%xmm1\n\t"
|
||||
"pop\t%rax\n\t"
|
||||
"pop\t%rax\n\t"
|
||||
"mov\t$0x2222222222220022,%rax\n\t"
|
||||
"movd\t%rax,%xmm2\n\t"
|
||||
"mov\t$0x3333333333333333,%rax\n\t"
|
||||
"movd\t%rax,%xmm3\n\t"
|
||||
"mov\t$0x4444444444444444,%rax\n\t"
|
||||
"movd\t%rax,%xmm4\n\t"
|
||||
"mov\t$0x5555555555555555,%rax\n\t"
|
||||
"movd\t%rax,%xmm5\n\t"
|
||||
"mov\t$0x6666666666666666,%rax\n\t"
|
||||
"movd\t%rax,%xmm6\n\t"
|
||||
"mov\t$0x7777777777777777,%rax\n\t"
|
||||
"movd\t%rax,%xmm7\n\t"
|
||||
"mov\t$0x8888888888888888,%rax\n\t"
|
||||
"movd\t%rax,%xmm8\n\t"
|
||||
"mov\t$0x9999999999999999,%rax\n\t"
|
||||
"movd\t%rax,%xmm9\n\t"
|
||||
"mov\t$0xaaaaaaaaaaaaaaaa,%rax\n\t"
|
||||
"movd\t%rax,%xmm10\n\t"
|
||||
"mov\t$0xbbbbbbbbbbbbbbbb,%rax\n\t"
|
||||
"movd\t%rax,%xmm11\n\t"
|
||||
"mov\t$0xcccccccccccccccc,%rax\n\t"
|
||||
"movd\t%rax,%xmm12\n\t"
|
||||
"mov\t$0xdddddddddddddddd,%rax\n\t"
|
||||
"movd\t%rax,%xmm13\n\t"
|
||||
"mov\t$0xeeeeeeeeeeeeeeee,%rax\n\t"
|
||||
"movd\t%rax,%xmm14\n\t"
|
||||
"mov\t$0xffffffffffffffff,%rax\n\t"
|
||||
"movd\t%rax,%xmm15\n\t"
|
||||
"fldpi\n\t"
|
||||
"xor\t%eax,%eax\n\t"
|
||||
"div\t%eax\n\t");
|
||||
|
||||
return res;
|
||||
return 1 / (x = 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue