Skip to content

Instantly share code, notes, and snippets.

View marijnh's full-sized avatar

Marijn Haverbeke marijnh

View GitHub Profile
(gdb) bt
#0 0xf7fdf430 in __kernel_vsyscall ()
#1 0xf6d02ea1 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0xf6d062ce in abort () at abort.c:92
#3 0xf6cfb7c8 in __assert_fail (assertion=0xf7b3b818 "Ty && \"Invalid GetElementPtrInst indices for type!\"",
file=0xf7b3b544 "/home/marijn/prog/llvm/include/llvm/Instructions.h", line=703, function=0xf7dc5540 "llvm::Type* llvm::checkGEPType(llvm::Type*)")
at assert.c:81
#4 0xf7a045b1 in llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateInBoundsGEP(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) () from /home/marijn/src/rust/stage1/librustllvm.so
#5 0xf6b9f068 in ?? ()
#6 0x79543a3a in ?? ()
@marijnh
marijnh / gist:1174086
Created August 26, 2011 18:36
win32 rust backtrace (stage2 with new vec representation)
(gdb) run -c -o stage2/lib/glue.o --glue
Starting program: e:\rust/stage2/rustc.exe -c -o stage2/lib/glue.o --glue
[New Thread 980.0x910]
Program received signal SIGSEGV, Segmentation fault.
0x00ffffff in ?? ()
(gdb) bt
#0 0x00ffffff in ?? ()
#1 0x63cb4ad2 in __do_global_ctors () from e:\rust\stage2\std.dll
#2 0x63c41167 in DllMainCRTStartup@12 () from e:\rust\stage2\std.dll
opt -lint stage1/rustc.bc
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
Undefined behavior: Call argument type mismatches callee parameter type
tail call void bitcast (void (%task*, i8*, i8*, i32)* @upcall_fail to void (%struct.rust_task*, i8*, i8*, i32)*)(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 45)
@marijnh
marijnh / foo.ll
Created September 22, 2011 15:15
LLVM optimization issue
; optimize with 'opt -O2 -S' to get the file below. note the undef on line 30 of the result
declare i32 @upcall_rust_personality()
declare i32 @extern_fn(i32*)
define internal void @cleanup_fn() alwaysinline {
ret void
}
@marijnh
marijnh / gist:1488059
Created December 16, 2011 21:25
Rust implementation demo
impl util for uint {
fn str() -> str { uint::str(self) }
fn times(f: block(uint)) {
let c = 0u;
while c < self { f(c); c += 1u; }
}
}
impl util<T> for [T] {
fn len() -> uint { vec::len(self) }
fn main() {
let x = vec::init_elt(5000u, 20), y = 0;
int::range(0, 10000, {|_i|
y += vec::foldl(1, x, {|a, b| a + b});
vec::iteri(x, {|i, e| y += i as int + e;});
y += vec::map(x, {|x| x + 2}).len() as int;
});
log(error, y);
}
for vec::iter2(arr1, arr2) {|elt1, elt2|
if elt1 == "" { cont; }
if elt2 == "stop" { break; }
}
fn find_key(map: map<key, thing>, x: thing) -> key {
for map.items {|key, val|
if val == x { ret key; }
}
fail "not found";
@marijnh
marijnh / gist:2488301
Created April 25, 2012 08:53
html + css preview
<!doctype html>
<html>
<head>
<title>HTML&CSS SANDBOX</title>
<meta charset=utf-8>
<script src=lib/codemirror.js></script>
<script src=mode/xml/xml.js></script>
<script src=mode/javascript/javascript.js></script>
<script src=mode/css/css.js></script>
<script src=mode/htmlmixed/htmlmixed.js></script>
<h2> Hello </h2>
<p>Here is some content...</p>
@marijnh
marijnh / gist:3632766
Created September 5, 2012 07:43
CodeMirror centerOnCursor extension
CodeMirror.defineExtension("centerOnCursor", function() {
var coords = this.cursorCoords(null, "local");
this.scrollTo(null, (coords.y + coords.yBot) / 2 -
(this.getScrollerElement().clientHeight / 2));
});