Commit 2c2c5cb6 authored by Kirill Smelkov's avatar Kirill Smelkov

tracing/runtime: Teach g_typedef to extract type definition for non-struct types

With previous sed expression it was failing e.g. on runtime.guintptr,
giving much more after type definition:

	$ go doc -c -u runtime.muintptr | sed -n -e '/^type /,/^}/p'
	type muintptr uintptr
	    muintptr is a *m that is not tracked by the garbage collector.

	    Because we do free Ms, there are some additional constrains on muintptrs:

	    1. Never hold an muintptr locally across a safe point.

	    2. Any muintptr in the heap must be owned by the M itself so it can

	    ensure it is not in use when the last true *m is released.

	func (mp muintptr) ptr() *m
	func (mp *muintptr) set(m *m)

Fix it since we'll need to extract more single-line types for Go1.11 support.

To verify it works de-stub {g,p,m}uintptr.
parent b7e99d87
......@@ -18,9 +18,17 @@ goset() {
# typedef <type> - print type definition
typedef() {
$goexec doc -c -u $1 |sed -n -e '/^type /,/^}/p'
}
$goexec doc -c -u $1 |sed -n -e '
# ignore anything not starting with `type `
/^type /!b
# if there is opening `{` - loop till closing `}`
/{/{:loop p; n; /^}/!b loop; p; b}
# else just print this single line
p
'
}
# typedef_g - print <g> & friends definitions
typedef_g() {
......@@ -33,7 +41,9 @@ typedef_g() {
#typedef runtime.sudog
#typedef runtime.hchan
typedef runtime.timer
#typedef runtime.guintptr
typedef runtime.guintptr
typedef runtime.puintptr
typedef runtime.muintptr
#typedef runtime.m
if (( $govern < 109 )); then
......@@ -46,9 +56,6 @@ typedef_g_fixed() {
typedef_g $1 | \
sed -e 's/\<sys.Uintreg\>/uintreg/'
echo "type guintptr uintptr // XXX stub"
echo "type puintptr uintptr // XXX stub"
echo "type muintptr uintptr // XXX stub"
echo "type uintreg uint // FIXME wrong on amd64p32"
echo "type m struct {} // FIXME stub"
echo "type sudog struct {} // FIXME stub"
......
......@@ -124,9 +124,9 @@ type timer struct {
arg interface{}
seq uintptr
}
type guintptr uintptr // XXX stub
type puintptr uintptr // XXX stub
type muintptr uintptr // XXX stub
type guintptr uintptr
type puintptr uintptr
type muintptr uintptr
type uintreg uint // FIXME wrong on amd64p32
type m struct {} // FIXME stub
type sudog struct {} // FIXME stub
......
......@@ -128,13 +128,13 @@ type timer struct {
arg interface{}
seq uintptr
}
type guintptr uintptr
type puintptr uintptr
type muintptr uintptr
type stkbar struct {
savedLRPtr uintptr // location overwritten by stack barrier PC
savedLRVal uintptr // value overwritten at savedLRPtr
}
type guintptr uintptr // XXX stub
type puintptr uintptr // XXX stub
type muintptr uintptr // XXX stub
type uintreg uint // FIXME wrong on amd64p32
type m struct {} // FIXME stub
type sudog struct {} // FIXME stub
......@@ -120,9 +120,9 @@ type timer struct {
arg interface{}
seq uintptr
}
type guintptr uintptr // XXX stub
type puintptr uintptr // XXX stub
type muintptr uintptr // XXX stub
type guintptr uintptr
type puintptr uintptr
type muintptr uintptr
type uintreg uint // FIXME wrong on amd64p32
type m struct {} // FIXME stub
type sudog struct {} // FIXME stub
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment