Skip to content

Instantly share code, notes, and snippets.

View dr2chase's full-sized avatar
💭
I am working on Go stuff

David Chase dr2chase

💭
I am working on Go stuff
View GitHub Profile
@dr2chase
dr2chase / duffsteptest.go
Last active June 15, 2016 15:15
Test file for delve stepping
package main
// A delve stepping test.
// dlv debug
// b main.foo
// c
// s
// s
// Expect to be stopped in fmt.Printf or runtime.duffzero
import "fmt"
@dr2chase
dr2chase / duffsteptest_expected.txt
Created June 15, 2016 15:16
Expected output debugging duffsteptest.go
dlv debug
Type 'help' for list of commands.
(dlv) b main.foo
Breakpoint 1 set at 0x2058 for main.foo() ./code.go:14
(dlv) c
> main.foo() ./code.go:14 (hits goroutine(1):1 total:1) (PC: 0x2058)
9: // Expect to be stopped in fmt.Printf or runtime.duffzero
10: import "fmt"
11:
12: var v int = 99
@dr2chase
dr2chase / duffsteptest_bug.txt
Created June 15, 2016 15:21
Buggy output debugging duffsteptest.go
dlv debug
Type 'help' for list of commands.
(dlv) b main.foo
Breakpoint 1 set at 0x2058 for main.foo() ./code.go:14
(dlv) c
> main.foo() ./code.go:14 (hits goroutine(1):1 total:1) (PC: 0x2058)
9: // Expect to be stopped in fmt.Printf or runtime.duffzero
10: import "fmt"
11:
12: var v int = 99
package main
import (
"fmt"
"time"
)
var v int = 99
var s string
dlv debug
Type 'help' for list of commands.
(dlv) b step_hide.go:35
Breakpoint 1 set at 0x237c for main.main() ./step_hide.go:35
(dlv) c
> main.main() ./step_hide.go:35 (hits goroutine(1):1 total:1) (PC: 0x237c)
30: x := v
31: y := x * x
32: var z int
33: threads()
~/GoogleDrive/work/tmp/ttmp$ dlv debug
Type 'help' for list of commands.
(dlv) b main.foo
Breakpoint 1 set at 0x2058 for main.foo() ./step_hide.go:12
(dlv) c
> main.foo() ./step_hide.go:12 (hits goroutine(11):1 total:3) (PC: 0x2058)
> main.foo() ./step_hide.go:12 (hits goroutine(7):1 total:3) (PC: 0x2058)
> main.foo() ./step_hide.go:12 (hits goroutine(5):1 total:3) (PC: 0x2058)
7:
8: var v int = 99
@dr2chase
dr2chase / javabugdemo.bash
Created May 15, 2017 20:17
Shell script that unpacks and runs a Java bug. Verification does not ensure static correctness of interface types.
echo "interface I1 { }" > I1.java
echo "interface I2 { }" > I2.java
echo "interface I3 { }" > I3.java
echo "class I1I2 implements I1, I2 { }" > I1I2.java_good
echo "class I1I2 implements I1 { }" > I1I2.java_bad
echo "class I1I3I2 implements I1, I3, I2 { }" > I1I3I2.java
cat > tricky.java <<'//EOF'
class tricky {
I2 i2;
#!/bin/bash
# filter output of multiple benchmarking experiments into a spreadsheet-friendly form
egrep '^[[a-zA-Z/]' "$1" | egrep -v "B/s|old speed" | \
sed -e '1,$s/[^0-9]*s ±[ 0-9]*%//g' | sed -e '1,$s/(p.*)//g' | \
sed -e '1,$s?[-_.a-z/]*git-codereview: changed to branch ?,?g' | \
sed -e '1,$s/ * /,/g' | \
sed -e '1,$s/,~//g' | \
sed -e '1,$s/,[-+][0-9.]*%//g' | \
@dr2chase
dr2chase / ex3.bash
Created May 26, 2017 15:44
Sample script for running experiment.bash on several branches
#!/bin/bash
git change master
variant=master_2017_05_24 bash -x ./experiment.bash
echo
git change rotate_in_layout
variant=rotate_in_layout bash -x ./experiment.bash
echo
@dr2chase
dr2chase / experiment.bash
Last active May 26, 2017 15:45
Script for running a number of benchmarks comparing performance of GOEXPERIMENT=preemptibleloops
#!/bin/bash
# Run with environment variable "variant" set to some useful string legal in a file name.
N=25
if [[ `arch` == "ppc64le" ]] ; then
dohttp=
else
dohttp=1
done