repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
segmentio/objconv | struct.go | newStructType | func newStructType(t reflect.Type, c map[reflect.Type]*structType) *structType {
if s := c[t]; s != nil {
return s
}
n := t.NumField()
s := &structType{
fields: make([]structField, 0, n),
fieldsByName: make(map[string]*structField),
}
c[t] = s
for i := 0; i != n; i++ {
ft := t.Field(i)
if ft.A... | go | func newStructType(t reflect.Type, c map[reflect.Type]*structType) *structType {
if s := c[t]; s != nil {
return s
}
n := t.NumField()
s := &structType{
fields: make([]structField, 0, n),
fieldsByName: make(map[string]*structField),
}
c[t] = s
for i := 0; i != n; i++ {
ft := t.Field(i)
if ft.A... | [
"func",
"newStructType",
"(",
"t",
"reflect",
".",
"Type",
",",
"c",
"map",
"[",
"reflect",
".",
"Type",
"]",
"*",
"structType",
")",
"*",
"structType",
"{",
"if",
"s",
":=",
"c",
"[",
"t",
"]",
";",
"s",
"!=",
"nil",
"{",
"return",
"s",
"\n",
... | // newStructType takes a Go type as argument and extract information to make a
// new structType value.
// The type has to be a struct type or a panic will be raised. | [
"newStructType",
"takes",
"a",
"Go",
"type",
"as",
"argument",
"and",
"extract",
"information",
"to",
"make",
"a",
"new",
"structType",
"value",
".",
"The",
"type",
"has",
"to",
"be",
"a",
"struct",
"type",
"or",
"a",
"panic",
"will",
"be",
"raised",
"."... | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/struct.go#L87-L117 | test |
segmentio/objconv | struct.go | lookup | func (cache *structTypeCache) lookup(t reflect.Type) (s *structType) {
cache.mutex.RLock()
s = cache.store[t]
cache.mutex.RUnlock()
if s == nil {
// There's a race confition here where this value may be generated
// multiple times.
// The impact in practice is really small as it's unlikely to happen
// oft... | go | func (cache *structTypeCache) lookup(t reflect.Type) (s *structType) {
cache.mutex.RLock()
s = cache.store[t]
cache.mutex.RUnlock()
if s == nil {
// There's a race confition here where this value may be generated
// multiple times.
// The impact in practice is really small as it's unlikely to happen
// oft... | [
"func",
"(",
"cache",
"*",
"structTypeCache",
")",
"lookup",
"(",
"t",
"reflect",
".",
"Type",
")",
"(",
"s",
"*",
"structType",
")",
"{",
"cache",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"s",
"=",
"cache",
".",
"store",
"[",
"t",
"]",
"\n",
... | // lookup takes a Go type as argument and returns the matching structType value,
// potentially creating it if it didn't already exist.
// This method is safe to call from multiple goroutines. | [
"lookup",
"takes",
"a",
"Go",
"type",
"as",
"argument",
"and",
"returns",
"the",
"matching",
"structType",
"value",
"potentially",
"creating",
"it",
"if",
"it",
"didn",
"t",
"already",
"exist",
".",
"This",
"method",
"is",
"safe",
"to",
"call",
"from",
"mu... | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/struct.go#L128-L147 | test |
segmentio/objconv | struct.go | clear | func (cache *structTypeCache) clear() {
cache.mutex.Lock()
for typ := range cache.store {
delete(cache.store, typ)
}
cache.mutex.Unlock()
} | go | func (cache *structTypeCache) clear() {
cache.mutex.Lock()
for typ := range cache.store {
delete(cache.store, typ)
}
cache.mutex.Unlock()
} | [
"func",
"(",
"cache",
"*",
"structTypeCache",
")",
"clear",
"(",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"for",
"typ",
":=",
"range",
"cache",
".",
"store",
"{",
"delete",
"(",
"cache",
".",
"store",
",",
"typ",
")",
"\n",
"... | // clear empties the cache. | [
"clear",
"empties",
"the",
"cache",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/struct.go#L150-L156 | test |
segmentio/objconv | objutil/limits.go | CheckUint64Bounds | func CheckUint64Bounds(v uint64, max uint64, t reflect.Type) (err error) {
if v > max {
err = fmt.Errorf("objconv: %d overflows the maximum value of %d for %s", v, max, t)
}
return
} | go | func CheckUint64Bounds(v uint64, max uint64, t reflect.Type) (err error) {
if v > max {
err = fmt.Errorf("objconv: %d overflows the maximum value of %d for %s", v, max, t)
}
return
} | [
"func",
"CheckUint64Bounds",
"(",
"v",
"uint64",
",",
"max",
"uint64",
",",
"t",
"reflect",
".",
"Type",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
">",
"max",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"objconv: %d overflows the maximum value of %d... | // CheckUint64Bounds verifies that v is smaller than max, t represents the
// original type of v. | [
"CheckUint64Bounds",
"verifies",
"that",
"v",
"is",
"smaller",
"than",
"max",
"t",
"represents",
"the",
"original",
"type",
"of",
"v",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/objutil/limits.go#L90-L95 | test |
segmentio/objconv | objutil/limits.go | CheckInt64Bounds | func CheckInt64Bounds(v int64, min int64, max uint64, t reflect.Type) (err error) {
if v < min {
err = fmt.Errorf("objconv: %d overflows the minimum value of %d for %s", v, min, t)
}
if v > 0 && uint64(v) > max {
err = fmt.Errorf("objconv: %d overflows the maximum value of %d for %s", v, max, t)
}
return
} | go | func CheckInt64Bounds(v int64, min int64, max uint64, t reflect.Type) (err error) {
if v < min {
err = fmt.Errorf("objconv: %d overflows the minimum value of %d for %s", v, min, t)
}
if v > 0 && uint64(v) > max {
err = fmt.Errorf("objconv: %d overflows the maximum value of %d for %s", v, max, t)
}
return
} | [
"func",
"CheckInt64Bounds",
"(",
"v",
"int64",
",",
"min",
"int64",
",",
"max",
"uint64",
",",
"t",
"reflect",
".",
"Type",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"<",
"min",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"objconv: %d overflow... | // CheckInt64Bounds verifies that v is within min and max, t represents the
// original type of v. | [
"CheckInt64Bounds",
"verifies",
"that",
"v",
"is",
"within",
"min",
"and",
"max",
"t",
"represents",
"the",
"original",
"type",
"of",
"v",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/objutil/limits.go#L99-L107 | test |
segmentio/objconv | decode.go | NewDecoder | func NewDecoder(p Parser) *Decoder {
if p == nil {
panic("objconv: the parser is nil")
}
return &Decoder{Parser: p}
} | go | func NewDecoder(p Parser) *Decoder {
if p == nil {
panic("objconv: the parser is nil")
}
return &Decoder{Parser: p}
} | [
"func",
"NewDecoder",
"(",
"p",
"Parser",
")",
"*",
"Decoder",
"{",
"if",
"p",
"==",
"nil",
"{",
"panic",
"(",
"\"objconv: the parser is nil\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"Decoder",
"{",
"Parser",
":",
"p",
"}",
"\n",
"}"
] | // NewDecoder returns a decoder object that uses p, will panic if p is nil. | [
"NewDecoder",
"returns",
"a",
"decoder",
"object",
"that",
"uses",
"p",
"will",
"panic",
"if",
"p",
"is",
"nil",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L31-L36 | test |
segmentio/objconv | decode.go | Decode | func (d Decoder) Decode(v interface{}) error {
to := reflect.ValueOf(v)
if d.off != 0 {
var err error
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return err
}
}
if !to.IsValid() {
// This special case for a nil value is used to make it possible to
// discard decoded values.
_, ... | go | func (d Decoder) Decode(v interface{}) error {
to := reflect.ValueOf(v)
if d.off != 0 {
var err error
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return err
}
}
if !to.IsValid() {
// This special case for a nil value is used to make it possible to
// discard decoded values.
_, ... | [
"func",
"(",
"d",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"to",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"if",
"d",
".",
"off",
"!=",
"0",
"{",
"var",
"err",
"error",
"\n",
"if",
"d",
".",
"o... | // Decode expects v to be a pointer to a value in which the decoder will load
// the next parsed data.
//
// The method panics if v is neither a pointer type nor implements the
// ValueDecoder interface, or if v is a nil pointer. | [
"Decode",
"expects",
"v",
"to",
"be",
"a",
"pointer",
"to",
"a",
"value",
"in",
"which",
"the",
"decoder",
"will",
"load",
"the",
"next",
"parsed",
"data",
".",
"The",
"method",
"panics",
"if",
"v",
"is",
"neither",
"a",
"pointer",
"type",
"nor",
"impl... | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L43-L78 | test |
segmentio/objconv | decode.go | DecodeArray | func (d Decoder) DecodeArray(f func(Decoder) error) (err error) {
var typ Type
if d.off != 0 {
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return
}
}
if typ, err = d.Parser.ParseType(); err != nil {
return
}
err = d.decodeArrayImpl(typ, f)
return
} | go | func (d Decoder) DecodeArray(f func(Decoder) error) (err error) {
var typ Type
if d.off != 0 {
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return
}
}
if typ, err = d.Parser.ParseType(); err != nil {
return
}
err = d.decodeArrayImpl(typ, f)
return
} | [
"func",
"(",
"d",
"Decoder",
")",
"DecodeArray",
"(",
"f",
"func",
"(",
"Decoder",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"var",
"typ",
"Type",
"\n",
"if",
"d",
".",
"off",
"!=",
"0",
"{",
"if",
"d",
".",
"off",
",",
"err",
"=",
"0... | // DecodeArray provides the implementation of the algorithm for decoding arrays,
// where f is called to decode each element of the array. | [
"DecodeArray",
"provides",
"the",
"implementation",
"of",
"the",
"algorithm",
"for",
"decoding",
"arrays",
"where",
"f",
"is",
"called",
"to",
"decode",
"each",
"element",
"of",
"the",
"array",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1133-L1148 | test |
segmentio/objconv | decode.go | DecodeMap | func (d Decoder) DecodeMap(f func(Decoder, Decoder) error) (err error) {
var typ Type
if d.off != 0 {
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return
}
}
if typ, err = d.Parser.ParseType(); err != nil {
return
}
err = d.decodeMapImpl(typ, f)
return
} | go | func (d Decoder) DecodeMap(f func(Decoder, Decoder) error) (err error) {
var typ Type
if d.off != 0 {
if d.off, err = 0, d.Parser.ParseMapValue(d.off-1); err != nil {
return
}
}
if typ, err = d.Parser.ParseType(); err != nil {
return
}
err = d.decodeMapImpl(typ, f)
return
} | [
"func",
"(",
"d",
"Decoder",
")",
"DecodeMap",
"(",
"f",
"func",
"(",
"Decoder",
",",
"Decoder",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"var",
"typ",
"Type",
"\n",
"if",
"d",
".",
"off",
"!=",
"0",
"{",
"if",
"d",
".",
"off",
",",
... | // DecodeMap provides the implementation of the algorithm for decoding maps,
// where f is called to decode each pair of key and value.
//
// The function f is expected to decode two values from the map, the first one
// being the key and the second the associated value. The first decoder must be
// used to decode the ... | [
"DecodeMap",
"provides",
"the",
"implementation",
"of",
"the",
"algorithm",
"for",
"decoding",
"maps",
"where",
"f",
"is",
"called",
"to",
"decode",
"each",
"pair",
"of",
"key",
"and",
"value",
".",
"The",
"function",
"f",
"is",
"expected",
"to",
"decode",
... | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1197-L1212 | test |
segmentio/objconv | decode.go | NewStreamDecoder | func NewStreamDecoder(p Parser) *StreamDecoder {
if p == nil {
panic("objconv: the parser is nil")
}
return &StreamDecoder{Parser: p}
} | go | func NewStreamDecoder(p Parser) *StreamDecoder {
if p == nil {
panic("objconv: the parser is nil")
}
return &StreamDecoder{Parser: p}
} | [
"func",
"NewStreamDecoder",
"(",
"p",
"Parser",
")",
"*",
"StreamDecoder",
"{",
"if",
"p",
"==",
"nil",
"{",
"panic",
"(",
"\"objconv: the parser is nil\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"StreamDecoder",
"{",
"Parser",
":",
"p",
"}",
"\n",
"}"
] | // NewStreamDecoder returns a new stream decoder that takes input from p.
//
// The function panics if p is nil. | [
"NewStreamDecoder",
"returns",
"a",
"new",
"stream",
"decoder",
"that",
"takes",
"input",
"from",
"p",
".",
"The",
"function",
"panics",
"if",
"p",
"is",
"nil",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1282-L1287 | test |
segmentio/objconv | decode.go | Len | func (d *StreamDecoder) Len() int {
if d.err != nil {
return 0
}
if d.typ == Unknown {
if d.init() != nil {
return 0
}
}
return d.max - d.cnt
} | go | func (d *StreamDecoder) Len() int {
if d.err != nil {
return 0
}
if d.typ == Unknown {
if d.init() != nil {
return 0
}
}
return d.max - d.cnt
} | [
"func",
"(",
"d",
"*",
"StreamDecoder",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"d",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"if",
"d",
".",
"typ",
"==",
"Unknown",
"{",
"if",
"d",
".",
"init",
"(",
")",
"!=",
"nil",
"... | // Len returns the number of values remaining to be read from the stream, which
// may be -1 if the underlying format doesn't provide this information. If an
// error occurred while decoding the stream the method returns zero because no
// more values can be read. | [
"Len",
"returns",
"the",
"number",
"of",
"values",
"remaining",
"to",
"be",
"read",
"from",
"the",
"stream",
"which",
"may",
"be",
"-",
"1",
"if",
"the",
"underlying",
"format",
"doesn",
"t",
"provide",
"this",
"information",
".",
"If",
"an",
"error",
"o... | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1293-L1305 | test |
segmentio/objconv | decode.go | Err | func (d *StreamDecoder) Err() error {
if d.err == End {
return nil
}
return d.err
} | go | func (d *StreamDecoder) Err() error {
if d.err == End {
return nil
}
return d.err
} | [
"func",
"(",
"d",
"*",
"StreamDecoder",
")",
"Err",
"(",
")",
"error",
"{",
"if",
"d",
".",
"err",
"==",
"End",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"d",
".",
"err",
"\n",
"}"
] | // Err returns the last error returned by the Decode method.
//
// The method returns nil if the stream reached its natural end. | [
"Err",
"returns",
"the",
"last",
"error",
"returned",
"by",
"the",
"Decode",
"method",
".",
"The",
"method",
"returns",
"nil",
"if",
"the",
"stream",
"reached",
"its",
"natural",
"end",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1310-L1315 | test |
segmentio/objconv | decode.go | Decode | func (d *StreamDecoder) Decode(v interface{}) error {
if d.err != nil {
return d.err
}
err := error(nil)
cnt := d.cnt
max := d.max
dec := Decoder{
Parser: d.Parser,
MapType: d.MapType,
}
switch d.typ {
case Unknown:
err = d.init()
max = d.max
case Array:
if cnt == max {
err = dec.Parser.Pars... | go | func (d *StreamDecoder) Decode(v interface{}) error {
if d.err != nil {
return d.err
}
err := error(nil)
cnt := d.cnt
max := d.max
dec := Decoder{
Parser: d.Parser,
MapType: d.MapType,
}
switch d.typ {
case Unknown:
err = d.init()
max = d.max
case Array:
if cnt == max {
err = dec.Parser.Pars... | [
"func",
"(",
"d",
"*",
"StreamDecoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"d",
".",
"err",
"!=",
"nil",
"{",
"return",
"d",
".",
"err",
"\n",
"}",
"\n",
"err",
":=",
"error",
"(",
"nil",
")",
"\n",
"cnt",
... | // Decodes the next value from the stream into v. | [
"Decodes",
"the",
"next",
"value",
"from",
"the",
"stream",
"into",
"v",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1318-L1365 | test |
segmentio/objconv | decode.go | Encoder | func (d *StreamDecoder) Encoder(e Emitter) (enc *StreamEncoder, err error) {
var typ Type
if typ, err = d.Parser.ParseType(); err == nil {
enc = NewStreamEncoder(e)
enc.oneshot = typ != Array
}
return
} | go | func (d *StreamDecoder) Encoder(e Emitter) (enc *StreamEncoder, err error) {
var typ Type
if typ, err = d.Parser.ParseType(); err == nil {
enc = NewStreamEncoder(e)
enc.oneshot = typ != Array
}
return
} | [
"func",
"(",
"d",
"*",
"StreamDecoder",
")",
"Encoder",
"(",
"e",
"Emitter",
")",
"(",
"enc",
"*",
"StreamEncoder",
",",
"err",
"error",
")",
"{",
"var",
"typ",
"Type",
"\n",
"if",
"typ",
",",
"err",
"=",
"d",
".",
"Parser",
".",
"ParseType",
"(",
... | // Encoder returns a new StreamEncoder which can be used to re-encode the stream
// decoded by d into e.
//
// The method panics if e is nil. | [
"Encoder",
"returns",
"a",
"new",
"StreamEncoder",
"which",
"can",
"be",
"used",
"to",
"re",
"-",
"encode",
"the",
"stream",
"decoded",
"by",
"d",
"into",
"e",
".",
"The",
"method",
"panics",
"if",
"e",
"is",
"nil",
"."
] | 7a1d7b8e6f3551b30751e6b2ea6bae500883870e | https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/decode.go#L1371-L1380 | test |
btcsuite/btclog | log.go | init | func init() {
for _, f := range strings.Split(os.Getenv("LOGFLAGS"), ",") {
switch f {
case "longfile":
defaultFlags |= Llongfile
case "shortfile":
defaultFlags |= Lshortfile
}
}
} | go | func init() {
for _, f := range strings.Split(os.Getenv("LOGFLAGS"), ",") {
switch f {
case "longfile":
defaultFlags |= Llongfile
case "shortfile":
defaultFlags |= Lshortfile
}
}
} | [
"func",
"init",
"(",
")",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"strings",
".",
"Split",
"(",
"os",
".",
"Getenv",
"(",
"\"LOGFLAGS\"",
")",
",",
"\",\"",
")",
"{",
"switch",
"f",
"{",
"case",
"\"longfile\"",
":",
"defaultFlags",
"|=",
"Llongfile... | // Read logger flags from the LOGFLAGS environment variable. Multiple flags can
// be set at once, separated by commas. | [
"Read",
"logger",
"flags",
"from",
"the",
"LOGFLAGS",
"environment",
"variable",
".",
"Multiple",
"flags",
"can",
"be",
"set",
"at",
"once",
"separated",
"by",
"commas",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L66-L75 | test |
btcsuite/btclog | log.go | LevelFromString | func LevelFromString(s string) (l Level, ok bool) {
switch strings.ToLower(s) {
case "trace", "trc":
return LevelTrace, true
case "debug", "dbg":
return LevelDebug, true
case "info", "inf":
return LevelInfo, true
case "warn", "wrn":
return LevelWarn, true
case "error", "err":
return LevelError, true
ca... | go | func LevelFromString(s string) (l Level, ok bool) {
switch strings.ToLower(s) {
case "trace", "trc":
return LevelTrace, true
case "debug", "dbg":
return LevelDebug, true
case "info", "inf":
return LevelInfo, true
case "warn", "wrn":
return LevelWarn, true
case "error", "err":
return LevelError, true
ca... | [
"func",
"LevelFromString",
"(",
"s",
"string",
")",
"(",
"l",
"Level",
",",
"ok",
"bool",
")",
"{",
"switch",
"strings",
".",
"ToLower",
"(",
"s",
")",
"{",
"case",
"\"trace\"",
",",
"\"trc\"",
":",
"return",
"LevelTrace",
",",
"true",
"\n",
"case",
... | // LevelFromString returns a level based on the input string s. If the input
// can't be interpreted as a valid log level, the info level and false is
// returned. | [
"LevelFromString",
"returns",
"a",
"level",
"based",
"on",
"the",
"input",
"string",
"s",
".",
"If",
"the",
"input",
"can",
"t",
"be",
"interpreted",
"as",
"a",
"valid",
"log",
"level",
"the",
"info",
"level",
"and",
"false",
"is",
"returned",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L98-L117 | test |
btcsuite/btclog | log.go | NewBackend | func NewBackend(w io.Writer, opts ...BackendOption) *Backend {
b := &Backend{w: w, flag: defaultFlags}
for _, o := range opts {
o(b)
}
return b
} | go | func NewBackend(w io.Writer, opts ...BackendOption) *Backend {
b := &Backend{w: w, flag: defaultFlags}
for _, o := range opts {
o(b)
}
return b
} | [
"func",
"NewBackend",
"(",
"w",
"io",
".",
"Writer",
",",
"opts",
"...",
"BackendOption",
")",
"*",
"Backend",
"{",
"b",
":=",
"&",
"Backend",
"{",
"w",
":",
"w",
",",
"flag",
":",
"defaultFlags",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"... | // NewBackend creates a logger backend from a Writer. | [
"NewBackend",
"creates",
"a",
"logger",
"backend",
"from",
"a",
"Writer",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L129-L135 | test |
btcsuite/btclog | log.go | callsite | func callsite(flag uint32) (string, int) {
_, file, line, ok := runtime.Caller(calldepth)
if !ok {
return "???", 0
}
if flag&Lshortfile != 0 {
short := file
for i := len(file) - 1; i > 0; i-- {
if os.IsPathSeparator(file[i]) {
short = file[i+1:]
break
}
}
file = short
}
return file, line
} | go | func callsite(flag uint32) (string, int) {
_, file, line, ok := runtime.Caller(calldepth)
if !ok {
return "???", 0
}
if flag&Lshortfile != 0 {
short := file
for i := len(file) - 1; i > 0; i-- {
if os.IsPathSeparator(file[i]) {
short = file[i+1:]
break
}
}
file = short
}
return file, line
} | [
"func",
"callsite",
"(",
"flag",
"uint32",
")",
"(",
"string",
",",
"int",
")",
"{",
"_",
",",
"file",
",",
"line",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"calldepth",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"???\"",
",",
"0",
"\n",... | // callsite returns the file name and line number of the callsite to the
// subsystem logger. | [
"callsite",
"returns",
"the",
"file",
"name",
"and",
"line",
"number",
"of",
"the",
"callsite",
"to",
"the",
"subsystem",
"logger",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L243-L259 | test |
btcsuite/btclog | log.go | print | func (b *Backend) print(lvl, tag string, args ...interface{}) {
t := time.Now() // get as early as possible
bytebuf := buffer()
var file string
var line int
if b.flag&(Lshortfile|Llongfile) != 0 {
file, line = callsite(b.flag)
}
formatHeader(bytebuf, t, lvl, tag, file, line)
buf := bytes.NewBuffer(*bytebuf... | go | func (b *Backend) print(lvl, tag string, args ...interface{}) {
t := time.Now() // get as early as possible
bytebuf := buffer()
var file string
var line int
if b.flag&(Lshortfile|Llongfile) != 0 {
file, line = callsite(b.flag)
}
formatHeader(bytebuf, t, lvl, tag, file, line)
buf := bytes.NewBuffer(*bytebuf... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"print",
"(",
"lvl",
",",
"tag",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"bytebuf",
":=",
"buffer",
"(",
")",
"\n",
"var",
"file",
"str... | // print outputs a log message to the writer associated with the backend after
// creating a prefix for the given level and tag according to the formatHeader
// function and formatting the provided arguments using the default formatting
// rules. | [
"print",
"outputs",
"a",
"log",
"message",
"to",
"the",
"writer",
"associated",
"with",
"the",
"backend",
"after",
"creating",
"a",
"prefix",
"for",
"the",
"given",
"level",
"and",
"tag",
"according",
"to",
"the",
"formatHeader",
"function",
"and",
"formatting... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L265-L286 | test |
btcsuite/btclog | log.go | Logger | func (b *Backend) Logger(subsystemTag string) Logger {
return &slog{LevelInfo, subsystemTag, b}
} | go | func (b *Backend) Logger(subsystemTag string) Logger {
return &slog{LevelInfo, subsystemTag, b}
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"Logger",
"(",
"subsystemTag",
"string",
")",
"Logger",
"{",
"return",
"&",
"slog",
"{",
"LevelInfo",
",",
"subsystemTag",
",",
"b",
"}",
"\n",
"}"
] | // Logger returns a new logger for a particular subsystem that writes to the
// Backend b. A tag describes the subsystem and is included in all log
// messages. The logger uses the info verbosity level by default. | [
"Logger",
"returns",
"a",
"new",
"logger",
"for",
"a",
"particular",
"subsystem",
"that",
"writes",
"to",
"the",
"Backend",
"b",
".",
"A",
"tag",
"describes",
"the",
"subsystem",
"and",
"is",
"included",
"in",
"all",
"log",
"messages",
".",
"The",
"logger"... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L318-L320 | test |
btcsuite/btclog | log.go | Trace | func (l *slog) Trace(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.print("TRC", l.tag, args...)
}
} | go | func (l *slog) Trace(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.print("TRC", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Trace",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelTrace",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"TRC\"",
",",
"l",
"."... | // Trace formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelTrace.
//
// This is part of the Logger interface implementation. | [
"Trace",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelTrace",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L333-L338 | test |
btcsuite/btclog | log.go | Tracef | func (l *slog) Tracef(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.printf("TRC", l.tag, format, args...)
}
} | go | func (l *slog) Tracef(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.printf("TRC", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Tracef",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelTrace",
"{",
"l",
".",
"b",
".",
"printf",
"(",... | // Tracef formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelTrace.
//
// This is part of the Logger interface implementation. | [
"Tracef",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelTrace",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L344-L349 | test |
btcsuite/btclog | log.go | Debug | func (l *slog) Debug(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.print("DBG", l.tag, args...)
}
} | go | func (l *slog) Debug(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.print("DBG", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Debug",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelDebug",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"DBG\"",
",",
"l",
"."... | // Debug formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelDebug.
//
// This is part of the Logger interface implementation. | [
"Debug",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelDebug",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L355-L360 | test |
btcsuite/btclog | log.go | Debugf | func (l *slog) Debugf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.printf("DBG", l.tag, format, args...)
}
} | go | func (l *slog) Debugf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.printf("DBG", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Debugf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelDebug",
"{",
"l",
".",
"b",
".",
"printf",
"(",... | // Debugf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelDebug.
//
// This is part of the Logger interface implementation. | [
"Debugf",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelDebug",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L366-L371 | test |
btcsuite/btclog | log.go | Info | func (l *slog) Info(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.print("INF", l.tag, args...)
}
} | go | func (l *slog) Info(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.print("INF", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Info",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelInfo",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"INF\"",
",",
"l",
".",
... | // Info formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelInfo.
//
// This is part of the Logger interface implementation. | [
"Info",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelInfo",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"i... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L377-L382 | test |
btcsuite/btclog | log.go | Infof | func (l *slog) Infof(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.printf("INF", l.tag, format, args...)
}
} | go | func (l *slog) Infof(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.printf("INF", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelInfo",
"{",
"l",
".",
"b",
".",
"printf",
"(",
... | // Infof formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelInfo.
//
// This is part of the Logger interface implementation. | [
"Infof",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelInfo",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L388-L393 | test |
btcsuite/btclog | log.go | Warn | func (l *slog) Warn(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.print("WRN", l.tag, args...)
}
} | go | func (l *slog) Warn(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.print("WRN", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Warn",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelWarn",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"WRN\"",
",",
"l",
".",
... | // Warn formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelWarn.
//
// This is part of the Logger interface implementation. | [
"Warn",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelWarn",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"i... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L399-L404 | test |
btcsuite/btclog | log.go | Warnf | func (l *slog) Warnf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.printf("WRN", l.tag, format, args...)
}
} | go | func (l *slog) Warnf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.printf("WRN", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Warnf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelWarn",
"{",
"l",
".",
"b",
".",
"printf",
"(",
... | // Warnf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelWarn.
//
// This is part of the Logger interface implementation. | [
"Warnf",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelWarn",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L410-L415 | test |
btcsuite/btclog | log.go | Error | func (l *slog) Error(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.print("ERR", l.tag, args...)
}
} | go | func (l *slog) Error(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.print("ERR", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Error",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelError",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"ERR\"",
",",
"l",
"."... | // Error formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelError.
//
// This is part of the Logger interface implementation. | [
"Error",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelError",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L421-L426 | test |
btcsuite/btclog | log.go | Errorf | func (l *slog) Errorf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.printf("ERR", l.tag, format, args...)
}
} | go | func (l *slog) Errorf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.printf("ERR", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Errorf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelError",
"{",
"l",
".",
"b",
".",
"printf",
"(",... | // Errorf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelError.
//
// This is part of the Logger interface implementation. | [
"Errorf",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelError",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L432-L437 | test |
btcsuite/btclog | log.go | Critical | func (l *slog) Critical(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.print("CRT", l.tag, args...)
}
} | go | func (l *slog) Critical(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.print("CRT", l.tag, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Critical",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelCritical",
"{",
"l",
".",
"b",
".",
"print",
"(",
"\"CRT\"",
",",
"l",... | // Critical formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelCritical.
//
// This is part of the Logger interface implementation. | [
"Critical",
"formats",
"message",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelCritical",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interfac... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L443-L448 | test |
btcsuite/btclog | log.go | Criticalf | func (l *slog) Criticalf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.printf("CRT", l.tag, format, args...)
}
} | go | func (l *slog) Criticalf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.printf("CRT", l.tag, format, args...)
}
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Criticalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"lvl",
":=",
"l",
".",
"Level",
"(",
")",
"\n",
"if",
"lvl",
"<=",
"LevelCritical",
"{",
"l",
".",
"b",
".",
"printf",
... | // Criticalf formats message according to format specifier, prepends the prefix
// as necessary, and writes to log with LevelCritical.
//
// This is part of the Logger interface implementation. | [
"Criticalf",
"formats",
"message",
"according",
"to",
"format",
"specifier",
"prepends",
"the",
"prefix",
"as",
"necessary",
"and",
"writes",
"to",
"log",
"with",
"LevelCritical",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"... | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L454-L459 | test |
btcsuite/btclog | log.go | Level | func (l *slog) Level() Level {
return Level(atomic.LoadUint32((*uint32)(&l.lvl)))
} | go | func (l *slog) Level() Level {
return Level(atomic.LoadUint32((*uint32)(&l.lvl)))
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"Level",
"(",
")",
"Level",
"{",
"return",
"Level",
"(",
"atomic",
".",
"LoadUint32",
"(",
"(",
"*",
"uint32",
")",
"(",
"&",
"l",
".",
"lvl",
")",
")",
")",
"\n",
"}"
] | // Level returns the current logging level
//
// This is part of the Logger interface implementation. | [
"Level",
"returns",
"the",
"current",
"logging",
"level",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L464-L466 | test |
btcsuite/btclog | log.go | SetLevel | func (l *slog) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&l.lvl), uint32(level))
} | go | func (l *slog) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&l.lvl), uint32(level))
} | [
"func",
"(",
"l",
"*",
"slog",
")",
"SetLevel",
"(",
"level",
"Level",
")",
"{",
"atomic",
".",
"StoreUint32",
"(",
"(",
"*",
"uint32",
")",
"(",
"&",
"l",
".",
"lvl",
")",
",",
"uint32",
"(",
"level",
")",
")",
"\n",
"}"
] | // SetLevel changes the logging level to the passed level.
//
// This is part of the Logger interface implementation. | [
"SetLevel",
"changes",
"the",
"logging",
"level",
"to",
"the",
"passed",
"level",
".",
"This",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"implementation",
"."
] | 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a | https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L471-L473 | test |
qor/roles | permission.go | Concat | func (permission *Permission) Concat(newPermission *Permission) *Permission {
var result = Permission{
Role: Global,
AllowedRoles: map[PermissionMode][]string{},
DeniedRoles: map[PermissionMode][]string{},
}
var appendRoles = func(p *Permission) {
if p != nil {
result.Role = p.Role
for mode,... | go | func (permission *Permission) Concat(newPermission *Permission) *Permission {
var result = Permission{
Role: Global,
AllowedRoles: map[PermissionMode][]string{},
DeniedRoles: map[PermissionMode][]string{},
}
var appendRoles = func(p *Permission) {
if p != nil {
result.Role = p.Role
for mode,... | [
"func",
"(",
"permission",
"*",
"Permission",
")",
"Concat",
"(",
"newPermission",
"*",
"Permission",
")",
"*",
"Permission",
"{",
"var",
"result",
"=",
"Permission",
"{",
"Role",
":",
"Global",
",",
"AllowedRoles",
":",
"map",
"[",
"PermissionMode",
"]",
... | // Concat concat two permissions into a new one | [
"Concat",
"concat",
"two",
"permissions",
"into",
"a",
"new",
"one"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/permission.go#L50-L74 | test |
qor/roles | permission.go | HasPermission | func (permission Permission) HasPermission(mode PermissionMode, roles ...interface{}) bool {
var roleNames []string
for _, role := range roles {
if r, ok := role.(string); ok {
roleNames = append(roleNames, r)
} else if roler, ok := role.(Roler); ok {
roleNames = append(roleNames, roler.GetRoles()...)
} e... | go | func (permission Permission) HasPermission(mode PermissionMode, roles ...interface{}) bool {
var roleNames []string
for _, role := range roles {
if r, ok := role.(string); ok {
roleNames = append(roleNames, r)
} else if roler, ok := role.(Roler); ok {
roleNames = append(roleNames, roler.GetRoles()...)
} e... | [
"func",
"(",
"permission",
"Permission",
")",
"HasPermission",
"(",
"mode",
"PermissionMode",
",",
"roles",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"var",
"roleNames",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"role",
":=",
"range",
"roles",
"{"... | // HasPermission check roles has permission for mode or not | [
"HasPermission",
"check",
"roles",
"has",
"permission",
"for",
"mode",
"or",
"not"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/permission.go#L103-L136 | test |
qor/roles | permissioner.go | ConcatPermissioner | func ConcatPermissioner(ps ...Permissioner) Permissioner {
var newPS []Permissioner
for _, p := range ps {
if p != nil {
newPS = append(newPS, p)
}
}
return permissioners(newPS)
} | go | func ConcatPermissioner(ps ...Permissioner) Permissioner {
var newPS []Permissioner
for _, p := range ps {
if p != nil {
newPS = append(newPS, p)
}
}
return permissioners(newPS)
} | [
"func",
"ConcatPermissioner",
"(",
"ps",
"...",
"Permissioner",
")",
"Permissioner",
"{",
"var",
"newPS",
"[",
"]",
"Permissioner",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"ps",
"{",
"if",
"p",
"!=",
"nil",
"{",
"newPS",
"=",
"append",
"(",
"newPS",... | // ConcatPermissioner concat permissioner | [
"ConcatPermissioner",
"concat",
"permissioner"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/permissioner.go#L9-L17 | test |
qor/roles | permissioner.go | HasPermission | func (ps permissioners) HasPermission(mode PermissionMode, roles ...interface{}) bool {
for _, p := range ps {
if p != nil && !p.HasPermission(mode, roles) {
return false
}
}
return true
} | go | func (ps permissioners) HasPermission(mode PermissionMode, roles ...interface{}) bool {
for _, p := range ps {
if p != nil && !p.HasPermission(mode, roles) {
return false
}
}
return true
} | [
"func",
"(",
"ps",
"permissioners",
")",
"HasPermission",
"(",
"mode",
"PermissionMode",
",",
"roles",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"ps",
"{",
"if",
"p",
"!=",
"nil",
"&&",
"!",
"p",
".",
"Has... | // HasPermission check has permission for permissioners or not | [
"HasPermission",
"check",
"has",
"permission",
"for",
"permissioners",
"or",
"not"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/permissioner.go#L22-L30 | test |
qor/roles | role.go | Register | func (role *Role) Register(name string, fc Checker) {
if role.definitions == nil {
role.definitions = map[string]Checker{}
}
definition := role.definitions[name]
if definition != nil {
fmt.Printf("Role `%v` already defined, overwrited it!\n", name)
}
role.definitions[name] = fc
} | go | func (role *Role) Register(name string, fc Checker) {
if role.definitions == nil {
role.definitions = map[string]Checker{}
}
definition := role.definitions[name]
if definition != nil {
fmt.Printf("Role `%v` already defined, overwrited it!\n", name)
}
role.definitions[name] = fc
} | [
"func",
"(",
"role",
"*",
"Role",
")",
"Register",
"(",
"name",
"string",
",",
"fc",
"Checker",
")",
"{",
"if",
"role",
".",
"definitions",
"==",
"nil",
"{",
"role",
".",
"definitions",
"=",
"map",
"[",
"string",
"]",
"Checker",
"{",
"}",
"\n",
"}"... | // Register register role with conditions | [
"Register",
"register",
"role",
"with",
"conditions"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/role.go#L27-L37 | test |
qor/roles | role.go | NewPermission | func (role *Role) NewPermission() *Permission {
return &Permission{
Role: role,
AllowedRoles: map[PermissionMode][]string{},
DeniedRoles: map[PermissionMode][]string{},
}
} | go | func (role *Role) NewPermission() *Permission {
return &Permission{
Role: role,
AllowedRoles: map[PermissionMode][]string{},
DeniedRoles: map[PermissionMode][]string{},
}
} | [
"func",
"(",
"role",
"*",
"Role",
")",
"NewPermission",
"(",
")",
"*",
"Permission",
"{",
"return",
"&",
"Permission",
"{",
"Role",
":",
"role",
",",
"AllowedRoles",
":",
"map",
"[",
"PermissionMode",
"]",
"[",
"]",
"string",
"{",
"}",
",",
"DeniedRole... | // NewPermission initialize permission | [
"NewPermission",
"initialize",
"permission"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/role.go#L40-L46 | test |
qor/roles | role.go | Get | func (role *Role) Get(name string) (Checker, bool) {
fc, ok := role.definitions[name]
return fc, ok
} | go | func (role *Role) Get(name string) (Checker, bool) {
fc, ok := role.definitions[name]
return fc, ok
} | [
"func",
"(",
"role",
"*",
"Role",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"Checker",
",",
"bool",
")",
"{",
"fc",
",",
"ok",
":=",
"role",
".",
"definitions",
"[",
"name",
"]",
"\n",
"return",
"fc",
",",
"ok",
"\n",
"}"
] | // Get role defination | [
"Get",
"role",
"defination"
] | d6375609fe3e5da46ad3a574fae244fb633e79c1 | https://github.com/qor/roles/blob/d6375609fe3e5da46ad3a574fae244fb633e79c1/role.go#L59-L62 | test |
golang/debug | internal/gocore/object.go | isPtrFromHeap | func (p *Process) isPtrFromHeap(a core.Address) bool {
return p.findHeapInfo(a).IsPtr(a, p.proc.PtrSize())
} | go | func (p *Process) isPtrFromHeap(a core.Address) bool {
return p.findHeapInfo(a).IsPtr(a, p.proc.PtrSize())
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"isPtrFromHeap",
"(",
"a",
"core",
".",
"Address",
")",
"bool",
"{",
"return",
"p",
".",
"findHeapInfo",
"(",
"a",
")",
".",
"IsPtr",
"(",
"a",
",",
"p",
".",
"proc",
".",
"PtrSize",
"(",
")",
")",
"\n",
"... | // isPtrFromHeap reports whether the inferior at address a contains a pointer.
// a must be somewhere in the heap. | [
"isPtrFromHeap",
"reports",
"whether",
"the",
"inferior",
"at",
"address",
"a",
"contains",
"a",
"pointer",
".",
"a",
"must",
"be",
"somewhere",
"in",
"the",
"heap",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L133-L135 | test |
golang/debug | internal/gocore/object.go | IsPtr | func (p *Process) IsPtr(a core.Address) bool {
h := p.findHeapInfo(a)
if h != nil {
return h.IsPtr(a, p.proc.PtrSize())
}
for _, m := range p.modules {
for _, s := range [2]string{"data", "bss"} {
min := core.Address(m.r.Field(s).Uintptr())
max := core.Address(m.r.Field("e" + s).Uintptr())
if a < min |... | go | func (p *Process) IsPtr(a core.Address) bool {
h := p.findHeapInfo(a)
if h != nil {
return h.IsPtr(a, p.proc.PtrSize())
}
for _, m := range p.modules {
for _, s := range [2]string{"data", "bss"} {
min := core.Address(m.r.Field(s).Uintptr())
max := core.Address(m.r.Field("e" + s).Uintptr())
if a < min |... | [
"func",
"(",
"p",
"*",
"Process",
")",
"IsPtr",
"(",
"a",
"core",
".",
"Address",
")",
"bool",
"{",
"h",
":=",
"p",
".",
"findHeapInfo",
"(",
"a",
")",
"\n",
"if",
"h",
"!=",
"nil",
"{",
"return",
"h",
".",
"IsPtr",
"(",
"a",
",",
"p",
".",
... | // IsPtr reports whether the inferior at address a contains a pointer. | [
"IsPtr",
"reports",
"whether",
"the",
"inferior",
"at",
"address",
"a",
"contains",
"a",
"pointer",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L138-L159 | test |
golang/debug | internal/gocore/object.go | FindObject | func (p *Process) FindObject(a core.Address) (Object, int64) {
// Round down to the start of an object.
h := p.findHeapInfo(a)
if h == nil {
// Not in Go heap, or in a span
// that doesn't hold Go objects (freed, stacks, ...)
return 0, 0
}
x := h.base.Add(a.Sub(h.base) / h.size * h.size)
// Check if object ... | go | func (p *Process) FindObject(a core.Address) (Object, int64) {
// Round down to the start of an object.
h := p.findHeapInfo(a)
if h == nil {
// Not in Go heap, or in a span
// that doesn't hold Go objects (freed, stacks, ...)
return 0, 0
}
x := h.base.Add(a.Sub(h.base) / h.size * h.size)
// Check if object ... | [
"func",
"(",
"p",
"*",
"Process",
")",
"FindObject",
"(",
"a",
"core",
".",
"Address",
")",
"(",
"Object",
",",
"int64",
")",
"{",
"h",
":=",
"p",
".",
"findHeapInfo",
"(",
"a",
")",
"\n",
"if",
"h",
"==",
"nil",
"{",
"return",
"0",
",",
"0",
... | // FindObject finds the object containing a. Returns that object and the offset within
// that object to which a points.
// Returns 0,0 if a doesn't point to a live heap object. | [
"FindObject",
"finds",
"the",
"object",
"containing",
"a",
".",
"Returns",
"that",
"object",
"and",
"the",
"offset",
"within",
"that",
"object",
"to",
"which",
"a",
"points",
".",
"Returns",
"0",
"0",
"if",
"a",
"doesn",
"t",
"point",
"to",
"a",
"live",
... | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L164-L179 | test |
golang/debug | internal/gocore/object.go | ForEachObject | func (p *Process) ForEachObject(fn func(x Object) bool) {
for _, k := range p.pages {
pt := p.pageTable[k]
for i := range pt {
h := &pt[i]
m := h.mark
for m != 0 {
j := bits.TrailingZeros64(m)
m &= m - 1
x := Object(k)*pageTableSize*heapInfoSize + Object(i)*heapInfoSize + Object(j)*8
if !f... | go | func (p *Process) ForEachObject(fn func(x Object) bool) {
for _, k := range p.pages {
pt := p.pageTable[k]
for i := range pt {
h := &pt[i]
m := h.mark
for m != 0 {
j := bits.TrailingZeros64(m)
m &= m - 1
x := Object(k)*pageTableSize*heapInfoSize + Object(i)*heapInfoSize + Object(j)*8
if !f... | [
"func",
"(",
"p",
"*",
"Process",
")",
"ForEachObject",
"(",
"fn",
"func",
"(",
"x",
"Object",
")",
"bool",
")",
"{",
"for",
"_",
",",
"k",
":=",
"range",
"p",
".",
"pages",
"{",
"pt",
":=",
"p",
".",
"pageTable",
"[",
"k",
"]",
"\n",
"for",
... | // ForEachObject calls fn with each object in the Go heap.
// If fn returns false, ForEachObject returns immediately. | [
"ForEachObject",
"calls",
"fn",
"with",
"each",
"object",
"in",
"the",
"Go",
"heap",
".",
"If",
"fn",
"returns",
"false",
"ForEachObject",
"returns",
"immediately",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L192-L208 | test |
golang/debug | internal/gocore/object.go | ForEachRoot | func (p *Process) ForEachRoot(fn func(r *Root) bool) {
for _, r := range p.globals {
if !fn(r) {
return
}
}
for _, g := range p.goroutines {
for _, f := range g.frames {
for _, r := range f.roots {
if !fn(r) {
return
}
}
}
}
} | go | func (p *Process) ForEachRoot(fn func(r *Root) bool) {
for _, r := range p.globals {
if !fn(r) {
return
}
}
for _, g := range p.goroutines {
for _, f := range g.frames {
for _, r := range f.roots {
if !fn(r) {
return
}
}
}
}
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ForEachRoot",
"(",
"fn",
"func",
"(",
"r",
"*",
"Root",
")",
"bool",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"p",
".",
"globals",
"{",
"if",
"!",
"fn",
"(",
"r",
")",
"{",
"return",
"\n",
"}",
... | // ForEachRoot calls fn with each garbage collection root.
// If fn returns false, ForEachRoot returns immediately. | [
"ForEachRoot",
"calls",
"fn",
"with",
"each",
"garbage",
"collection",
"root",
".",
"If",
"fn",
"returns",
"false",
"ForEachRoot",
"returns",
"immediately",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L212-L227 | test |
golang/debug | internal/gocore/object.go | Addr | func (p *Process) Addr(x Object) core.Address {
return core.Address(x)
} | go | func (p *Process) Addr(x Object) core.Address {
return core.Address(x)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Addr",
"(",
"x",
"Object",
")",
"core",
".",
"Address",
"{",
"return",
"core",
".",
"Address",
"(",
"x",
")",
"\n",
"}"
] | // Addr returns the starting address of x. | [
"Addr",
"returns",
"the",
"starting",
"address",
"of",
"x",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L230-L232 | test |
golang/debug | internal/gocore/object.go | Size | func (p *Process) Size(x Object) int64 {
return p.findHeapInfo(core.Address(x)).size
} | go | func (p *Process) Size(x Object) int64 {
return p.findHeapInfo(core.Address(x)).size
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Size",
"(",
"x",
"Object",
")",
"int64",
"{",
"return",
"p",
".",
"findHeapInfo",
"(",
"core",
".",
"Address",
"(",
"x",
")",
")",
".",
"size",
"\n",
"}"
] | // Size returns the size of x in bytes. | [
"Size",
"returns",
"the",
"size",
"of",
"x",
"in",
"bytes",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L235-L237 | test |
golang/debug | internal/gocore/object.go | Type | func (p *Process) Type(x Object) (*Type, int64) {
p.typeHeap()
i, _ := p.findObjectIndex(core.Address(x))
return p.types[i].t, p.types[i].r
} | go | func (p *Process) Type(x Object) (*Type, int64) {
p.typeHeap()
i, _ := p.findObjectIndex(core.Address(x))
return p.types[i].t, p.types[i].r
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Type",
"(",
"x",
"Object",
")",
"(",
"*",
"Type",
",",
"int64",
")",
"{",
"p",
".",
"typeHeap",
"(",
")",
"\n",
"i",
",",
"_",
":=",
"p",
".",
"findObjectIndex",
"(",
"core",
".",
"Address",
"(",
"x",
"... | // Type returns the type and repeat count for the object x.
// x contains at least repeat copies of the returned type. | [
"Type",
"returns",
"the",
"type",
"and",
"repeat",
"count",
"for",
"the",
"object",
"x",
".",
"x",
"contains",
"at",
"least",
"repeat",
"copies",
"of",
"the",
"returned",
"type",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L241-L246 | test |
golang/debug | internal/gocore/object.go | ForEachRootPtr | func (p *Process) ForEachRootPtr(r *Root, fn func(int64, Object, int64) bool) {
edges1(p, r, 0, r.Type, fn)
} | go | func (p *Process) ForEachRootPtr(r *Root, fn func(int64, Object, int64) bool) {
edges1(p, r, 0, r.Type, fn)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ForEachRootPtr",
"(",
"r",
"*",
"Root",
",",
"fn",
"func",
"(",
"int64",
",",
"Object",
",",
"int64",
")",
"bool",
")",
"{",
"edges1",
"(",
"p",
",",
"r",
",",
"0",
",",
"r",
".",
"Type",
",",
"fn",
")"... | // ForEachRootPtr behaves like ForEachPtr but it starts with a Root instead of an Object. | [
"ForEachRootPtr",
"behaves",
"like",
"ForEachPtr",
"but",
"it",
"starts",
"with",
"a",
"Root",
"instead",
"of",
"an",
"Object",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L274-L276 | test |
golang/debug | internal/gocore/object.go | edges1 | func edges1(p *Process, r *Root, off int64, t *Type, fn func(int64, Object, int64) bool) bool {
switch t.Kind {
case KindBool, KindInt, KindUint, KindFloat, KindComplex:
// no edges here
case KindIface, KindEface:
// The first word is a type or itab.
// Itabs are never in the heap.
// Types might be, though.... | go | func edges1(p *Process, r *Root, off int64, t *Type, fn func(int64, Object, int64) bool) bool {
switch t.Kind {
case KindBool, KindInt, KindUint, KindFloat, KindComplex:
// no edges here
case KindIface, KindEface:
// The first word is a type or itab.
// Itabs are never in the heap.
// Types might be, though.... | [
"func",
"edges1",
"(",
"p",
"*",
"Process",
",",
"r",
"*",
"Root",
",",
"off",
"int64",
",",
"t",
"*",
"Type",
",",
"fn",
"func",
"(",
"int64",
",",
"Object",
",",
"int64",
")",
"bool",
")",
"bool",
"{",
"switch",
"t",
".",
"Kind",
"{",
"case",... | // edges1 calls fn for the edges found in an object of type t living at offset off in the root r.
// If fn returns false, return immediately with false. | [
"edges1",
"calls",
"fn",
"for",
"the",
"edges",
"found",
"in",
"an",
"object",
"of",
"type",
"t",
"living",
"at",
"offset",
"off",
"in",
"the",
"root",
"r",
".",
"If",
"fn",
"returns",
"false",
"return",
"immediately",
"with",
"false",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L280-L325 | test |
golang/debug | internal/gocore/object.go | setHeapPtr | func (p *Process) setHeapPtr(a core.Address) {
h := p.allocHeapInfo(a)
if p.proc.PtrSize() == 8 {
i := uint(a%heapInfoSize) / 8
h.ptr[0] |= uint64(1) << i
return
}
i := a % heapInfoSize / 4
h.ptr[i/64] |= uint64(1) << (i % 64)
} | go | func (p *Process) setHeapPtr(a core.Address) {
h := p.allocHeapInfo(a)
if p.proc.PtrSize() == 8 {
i := uint(a%heapInfoSize) / 8
h.ptr[0] |= uint64(1) << i
return
}
i := a % heapInfoSize / 4
h.ptr[i/64] |= uint64(1) << (i % 64)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"setHeapPtr",
"(",
"a",
"core",
".",
"Address",
")",
"{",
"h",
":=",
"p",
".",
"allocHeapInfo",
"(",
"a",
")",
"\n",
"if",
"p",
".",
"proc",
".",
"PtrSize",
"(",
")",
"==",
"8",
"{",
"i",
":=",
"uint",
"... | // setHeapPtr records that the memory at heap address a contains a pointer. | [
"setHeapPtr",
"records",
"that",
"the",
"memory",
"at",
"heap",
"address",
"a",
"contains",
"a",
"pointer",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L351-L360 | test |
golang/debug | internal/gocore/object.go | findHeapInfo | func (p *Process) findHeapInfo(a core.Address) *heapInfo {
k := a / heapInfoSize / pageTableSize
i := a / heapInfoSize % pageTableSize
t := p.pageTable[k]
if t == nil {
return nil
}
h := &t[i]
if h.base == 0 {
return nil
}
return h
} | go | func (p *Process) findHeapInfo(a core.Address) *heapInfo {
k := a / heapInfoSize / pageTableSize
i := a / heapInfoSize % pageTableSize
t := p.pageTable[k]
if t == nil {
return nil
}
h := &t[i]
if h.base == 0 {
return nil
}
return h
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"findHeapInfo",
"(",
"a",
"core",
".",
"Address",
")",
"*",
"heapInfo",
"{",
"k",
":=",
"a",
"/",
"heapInfoSize",
"/",
"pageTableSize",
"\n",
"i",
":=",
"a",
"/",
"heapInfoSize",
"%",
"pageTableSize",
"\n",
"t",
... | // findHeapInfo finds the heapInfo structure for a.
// Returns nil if a is not a heap address. | [
"findHeapInfo",
"finds",
"the",
"heapInfo",
"structure",
"for",
"a",
".",
"Returns",
"nil",
"if",
"a",
"is",
"not",
"a",
"heap",
"address",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L370-L382 | test |
golang/debug | internal/gocore/object.go | allocHeapInfo | func (p *Process) allocHeapInfo(a core.Address) *heapInfo {
k := a / heapInfoSize / pageTableSize
i := a / heapInfoSize % pageTableSize
t := p.pageTable[k]
if t == nil {
t = new(pageTableEntry)
for j := 0; j < pageTableSize; j++ {
t[j].firstIdx = -1
}
p.pageTable[k] = t
p.pages = append(p.pages, k)
}
... | go | func (p *Process) allocHeapInfo(a core.Address) *heapInfo {
k := a / heapInfoSize / pageTableSize
i := a / heapInfoSize % pageTableSize
t := p.pageTable[k]
if t == nil {
t = new(pageTableEntry)
for j := 0; j < pageTableSize; j++ {
t[j].firstIdx = -1
}
p.pageTable[k] = t
p.pages = append(p.pages, k)
}
... | [
"func",
"(",
"p",
"*",
"Process",
")",
"allocHeapInfo",
"(",
"a",
"core",
".",
"Address",
")",
"*",
"heapInfo",
"{",
"k",
":=",
"a",
"/",
"heapInfoSize",
"/",
"pageTableSize",
"\n",
"i",
":=",
"a",
"/",
"heapInfoSize",
"%",
"pageTableSize",
"\n",
"t",
... | // Same as findHeapInfo, but allocates the heapInfo if it
// hasn't been allocated yet. | [
"Same",
"as",
"findHeapInfo",
"but",
"allocates",
"the",
"heapInfo",
"if",
"it",
"hasn",
"t",
"been",
"allocated",
"yet",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L386-L399 | test |
golang/debug | internal/gocore/dwarf.go | runtimeName | func runtimeName(dt dwarf.Type) string {
switch x := dt.(type) {
case *dwarf.PtrType:
if _, ok := x.Type.(*dwarf.VoidType); ok {
return "unsafe.Pointer"
}
return "*" + runtimeName(x.Type)
case *dwarf.ArrayType:
return fmt.Sprintf("[%d]%s", x.Count, runtimeName(x.Type))
case *dwarf.StructType:
if !strin... | go | func runtimeName(dt dwarf.Type) string {
switch x := dt.(type) {
case *dwarf.PtrType:
if _, ok := x.Type.(*dwarf.VoidType); ok {
return "unsafe.Pointer"
}
return "*" + runtimeName(x.Type)
case *dwarf.ArrayType:
return fmt.Sprintf("[%d]%s", x.Count, runtimeName(x.Type))
case *dwarf.StructType:
if !strin... | [
"func",
"runtimeName",
"(",
"dt",
"dwarf",
".",
"Type",
")",
"string",
"{",
"switch",
"x",
":=",
"dt",
".",
"(",
"type",
")",
"{",
"case",
"*",
"dwarf",
".",
"PtrType",
":",
"if",
"_",
",",
"ok",
":=",
"x",
".",
"Type",
".",
"(",
"*",
"dwarf",
... | // Generate the name the runtime uses for a dwarf type. The DWARF generator
// and the runtime use slightly different names for the same underlying type. | [
"Generate",
"the",
"name",
"the",
"runtime",
"uses",
"for",
"a",
"dwarf",
"type",
".",
"The",
"DWARF",
"generator",
"and",
"the",
"runtime",
"use",
"slightly",
"different",
"names",
"for",
"the",
"same",
"underlying",
"type",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/dwarf.go#L278-L330 | test |
golang/debug | internal/gocore/dwarf.go | readRuntimeConstants | func (p *Process) readRuntimeConstants() {
p.rtConstants = map[string]int64{}
// Hardcoded values for Go 1.9.
// (Go did not have constants in DWARF before 1.10.)
m := p.rtConstants
m["_MSpanDead"] = 0
m["_MSpanInUse"] = 1
m["_MSpanManual"] = 2
m["_MSpanFree"] = 3
m["_Gidle"] = 0
m["_Grunnable"] = 1
m["_Gru... | go | func (p *Process) readRuntimeConstants() {
p.rtConstants = map[string]int64{}
// Hardcoded values for Go 1.9.
// (Go did not have constants in DWARF before 1.10.)
m := p.rtConstants
m["_MSpanDead"] = 0
m["_MSpanInUse"] = 1
m["_MSpanManual"] = 2
m["_MSpanFree"] = 3
m["_Gidle"] = 0
m["_Grunnable"] = 1
m["_Gru... | [
"func",
"(",
"p",
"*",
"Process",
")",
"readRuntimeConstants",
"(",
")",
"{",
"p",
".",
"rtConstants",
"=",
"map",
"[",
"string",
"]",
"int64",
"{",
"}",
"\n",
"m",
":=",
"p",
".",
"rtConstants",
"\n",
"m",
"[",
"\"_MSpanDead\"",
"]",
"=",
"0",
"\n... | // readRuntimeConstants populates the p.rtConstants map. | [
"readRuntimeConstants",
"populates",
"the",
"p",
".",
"rtConstants",
"map",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/dwarf.go#L346-L394 | test |
golang/debug | internal/gocore/module.go | add | func (t *funcTab) add(min, max core.Address, f *Func) {
t.entries = append(t.entries, funcTabEntry{min: min, max: max, f: f})
} | go | func (t *funcTab) add(min, max core.Address, f *Func) {
t.entries = append(t.entries, funcTabEntry{min: min, max: max, f: f})
} | [
"func",
"(",
"t",
"*",
"funcTab",
")",
"add",
"(",
"min",
",",
"max",
"core",
".",
"Address",
",",
"f",
"*",
"Func",
")",
"{",
"t",
".",
"entries",
"=",
"append",
"(",
"t",
".",
"entries",
",",
"funcTabEntry",
"{",
"min",
":",
"min",
",",
"max"... | // add records that PCs in the range [min,max) map to function f. | [
"add",
"records",
"that",
"PCs",
"in",
"the",
"range",
"[",
"min",
"max",
")",
"map",
"to",
"function",
"f",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/module.go#L98-L100 | test |
golang/debug | internal/gocore/module.go | sort | func (t *funcTab) sort() {
sort.Slice(t.entries, func(i, j int) bool {
return t.entries[i].min < t.entries[j].min
})
} | go | func (t *funcTab) sort() {
sort.Slice(t.entries, func(i, j int) bool {
return t.entries[i].min < t.entries[j].min
})
} | [
"func",
"(",
"t",
"*",
"funcTab",
")",
"sort",
"(",
")",
"{",
"sort",
".",
"Slice",
"(",
"t",
".",
"entries",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"t",
".",
"entries",
"[",
"i",
"]",
".",
"min",
"<",
"t",
".",... | // sort must be called after all the adds, but before any find. | [
"sort",
"must",
"be",
"called",
"after",
"all",
"the",
"adds",
"but",
"before",
"any",
"find",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/module.go#L103-L107 | test |
golang/debug | internal/gocore/module.go | find | func (t *funcTab) find(pc core.Address) *Func {
n := sort.Search(len(t.entries), func(i int) bool {
return t.entries[i].max > pc
})
if n == len(t.entries) || pc < t.entries[n].min || pc >= t.entries[n].max {
return nil
}
return t.entries[n].f
} | go | func (t *funcTab) find(pc core.Address) *Func {
n := sort.Search(len(t.entries), func(i int) bool {
return t.entries[i].max > pc
})
if n == len(t.entries) || pc < t.entries[n].min || pc >= t.entries[n].max {
return nil
}
return t.entries[n].f
} | [
"func",
"(",
"t",
"*",
"funcTab",
")",
"find",
"(",
"pc",
"core",
".",
"Address",
")",
"*",
"Func",
"{",
"n",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"t",
".",
"entries",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"t... | // Finds a Func for the given address. Sort must have been called already. | [
"Finds",
"a",
"Func",
"for",
"the",
"given",
"address",
".",
"Sort",
"must",
"have",
"been",
"called",
"already",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/module.go#L110-L118 | test |
golang/debug | internal/gocore/module.go | read | func (t *pcTab) read(core *core.Process, data core.Address) {
var pcQuantum int64
switch core.Arch() {
case "386", "amd64", "amd64p32":
pcQuantum = 1
case "s390x":
pcQuantum = 2
case "arm", "arm64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le":
pcQuantum = 4
default:
panic("unknown architect... | go | func (t *pcTab) read(core *core.Process, data core.Address) {
var pcQuantum int64
switch core.Arch() {
case "386", "amd64", "amd64p32":
pcQuantum = 1
case "s390x":
pcQuantum = 2
case "arm", "arm64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le":
pcQuantum = 4
default:
panic("unknown architect... | [
"func",
"(",
"t",
"*",
"pcTab",
")",
"read",
"(",
"core",
"*",
"core",
".",
"Process",
",",
"data",
"core",
".",
"Address",
")",
"{",
"var",
"pcQuantum",
"int64",
"\n",
"switch",
"core",
".",
"Arch",
"(",
")",
"{",
"case",
"\"386\"",
",",
"\"amd64\... | // read parses a pctab from the core file at address data. | [
"read",
"parses",
"a",
"pctab",
"from",
"the",
"core",
"file",
"at",
"address",
"data",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/module.go#L131-L164 | test |
golang/debug | internal/gocore/module.go | readVarint | func readVarint(core *core.Process, a core.Address) (val, n int64) {
for {
b := core.ReadUint8(a)
val |= int64(b&0x7f) << uint(n*7)
n++
a++
if b&0x80 == 0 {
return
}
}
} | go | func readVarint(core *core.Process, a core.Address) (val, n int64) {
for {
b := core.ReadUint8(a)
val |= int64(b&0x7f) << uint(n*7)
n++
a++
if b&0x80 == 0 {
return
}
}
} | [
"func",
"readVarint",
"(",
"core",
"*",
"core",
".",
"Process",
",",
"a",
"core",
".",
"Address",
")",
"(",
"val",
",",
"n",
"int64",
")",
"{",
"for",
"{",
"b",
":=",
"core",
".",
"ReadUint8",
"(",
"a",
")",
"\n",
"val",
"|=",
"int64",
"(",
"b"... | // readVarint reads a varint from the core file.
// val is the value, n is the number of bytes consumed. | [
"readVarint",
"reads",
"a",
"varint",
"from",
"the",
"core",
"file",
".",
"val",
"is",
"the",
"value",
"n",
"is",
"the",
"number",
"of",
"bytes",
"consumed",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/module.go#L182-L192 | test |
golang/debug | cmd/viewcore/main.go | useLine | func useLine(c *cobra.Command) string {
var useline string
if c.HasParent() {
useline = commandPath(c.Parent()) + " " + c.Use
} else {
useline = c.Use
}
if c.DisableFlagsInUseLine {
return useline
}
if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
useline += " [flags]"
}
return useli... | go | func useLine(c *cobra.Command) string {
var useline string
if c.HasParent() {
useline = commandPath(c.Parent()) + " " + c.Use
} else {
useline = c.Use
}
if c.DisableFlagsInUseLine {
return useline
}
if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
useline += " [flags]"
}
return useli... | [
"func",
"useLine",
"(",
"c",
"*",
"cobra",
".",
"Command",
")",
"string",
"{",
"var",
"useline",
"string",
"\n",
"if",
"c",
".",
"HasParent",
"(",
")",
"{",
"useline",
"=",
"commandPath",
"(",
"c",
".",
"Parent",
"(",
")",
")",
"+",
"\" \"",
"+",
... | // useLine is like cobra.Command.UseLine but tweaked to use commandPath. | [
"useLine",
"is",
"like",
"cobra",
".",
"Command",
".",
"UseLine",
"but",
"tweaked",
"to",
"use",
"commandPath",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L180-L194 | test |
golang/debug | cmd/viewcore/main.go | commandPath | func commandPath(c *cobra.Command) string {
if c.HasParent() {
return commandPath(c) + " " + c.Name()
}
return c.Use
} | go | func commandPath(c *cobra.Command) string {
if c.HasParent() {
return commandPath(c) + " " + c.Name()
}
return c.Use
} | [
"func",
"commandPath",
"(",
"c",
"*",
"cobra",
".",
"Command",
")",
"string",
"{",
"if",
"c",
".",
"HasParent",
"(",
")",
"{",
"return",
"commandPath",
"(",
"c",
")",
"+",
"\" \"",
"+",
"c",
".",
"Name",
"(",
")",
"\n",
"}",
"\n",
"return",
"c",
... | // commandPath is like cobra.Command.CommandPath but tweaked to
// use c.Use instead of c.Name for the root command so it works
// with viewcore's unusual command structure. | [
"commandPath",
"is",
"like",
"cobra",
".",
"Command",
".",
"CommandPath",
"but",
"tweaked",
"to",
"use",
"c",
".",
"Use",
"instead",
"of",
"c",
".",
"Name",
"for",
"the",
"root",
"command",
"so",
"it",
"works",
"with",
"viewcore",
"s",
"unusual",
"comman... | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L199-L204 | test |
golang/debug | cmd/viewcore/main.go | readCore | func readCore() (*core.Process, *gocore.Process, error) {
cc := coreCache
if cc.cfg == cfg {
return cc.coreP, cc.gocoreP, cc.err
}
c, err := core.Core(cfg.corefile, cfg.base, cfg.exePath)
if err != nil {
return nil, nil, err
}
p, err := gocore.Core(c)
if os.IsNotExist(err) && cfg.exePath == "" {
return ni... | go | func readCore() (*core.Process, *gocore.Process, error) {
cc := coreCache
if cc.cfg == cfg {
return cc.coreP, cc.gocoreP, cc.err
}
c, err := core.Core(cfg.corefile, cfg.base, cfg.exePath)
if err != nil {
return nil, nil, err
}
p, err := gocore.Core(c)
if os.IsNotExist(err) && cfg.exePath == "" {
return ni... | [
"func",
"readCore",
"(",
")",
"(",
"*",
"core",
".",
"Process",
",",
"*",
"gocore",
".",
"Process",
",",
"error",
")",
"{",
"cc",
":=",
"coreCache",
"\n",
"if",
"cc",
".",
"cfg",
"==",
"cfg",
"{",
"return",
"cc",
".",
"coreP",
",",
"cc",
".",
"... | // readCore reads corefile and returns core and gocore process states. | [
"readCore",
"reads",
"corefile",
"and",
"returns",
"core",
"and",
"gocore",
"process",
"states",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L251-L275 | test |
golang/debug | cmd/viewcore/main.go | typeName | func typeName(c *gocore.Process, x gocore.Object) string {
size := c.Size(x)
typ, repeat := c.Type(x)
if typ == nil {
return fmt.Sprintf("unk%d", size)
}
name := typ.String()
n := size / typ.Size
if n > 1 {
if repeat < n {
name = fmt.Sprintf("[%d+%d?]%s", repeat, n-repeat, name)
} else {
name = fmt.S... | go | func typeName(c *gocore.Process, x gocore.Object) string {
size := c.Size(x)
typ, repeat := c.Type(x)
if typ == nil {
return fmt.Sprintf("unk%d", size)
}
name := typ.String()
n := size / typ.Size
if n > 1 {
if repeat < n {
name = fmt.Sprintf("[%d+%d?]%s", repeat, n-repeat, name)
} else {
name = fmt.S... | [
"func",
"typeName",
"(",
"c",
"*",
"gocore",
".",
"Process",
",",
"x",
"gocore",
".",
"Object",
")",
"string",
"{",
"size",
":=",
"c",
".",
"Size",
"(",
"x",
")",
"\n",
"typ",
",",
"repeat",
":=",
"c",
".",
"Type",
"(",
"x",
")",
"\n",
"if",
... | // typeName returns a string representing the type of this object. | [
"typeName",
"returns",
"a",
"string",
"representing",
"the",
"type",
"of",
"this",
"object",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L749-L765 | test |
golang/debug | cmd/viewcore/main.go | fieldName | func fieldName(c *gocore.Process, x gocore.Object, off int64) string {
size := c.Size(x)
typ, repeat := c.Type(x)
if typ == nil {
return fmt.Sprintf("f%d", off)
}
n := size / typ.Size
i := off / typ.Size
if i == 0 && repeat == 1 {
// Probably a singleton object, no need for array notation.
return typeField... | go | func fieldName(c *gocore.Process, x gocore.Object, off int64) string {
size := c.Size(x)
typ, repeat := c.Type(x)
if typ == nil {
return fmt.Sprintf("f%d", off)
}
n := size / typ.Size
i := off / typ.Size
if i == 0 && repeat == 1 {
// Probably a singleton object, no need for array notation.
return typeField... | [
"func",
"fieldName",
"(",
"c",
"*",
"gocore",
".",
"Process",
",",
"x",
"gocore",
".",
"Object",
",",
"off",
"int64",
")",
"string",
"{",
"size",
":=",
"c",
".",
"Size",
"(",
"x",
")",
"\n",
"typ",
",",
"repeat",
":=",
"c",
".",
"Type",
"(",
"x... | // fieldName returns the name of the field at offset off in x. | [
"fieldName",
"returns",
"the",
"name",
"of",
"the",
"field",
"at",
"offset",
"off",
"in",
"x",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L768-L790 | test |
golang/debug | cmd/viewcore/main.go | typeFieldName | func typeFieldName(t *gocore.Type, off int64) string {
switch t.Kind {
case gocore.KindBool, gocore.KindInt, gocore.KindUint, gocore.KindFloat:
return ""
case gocore.KindComplex:
if off == 0 {
return ".real"
}
return ".imag"
case gocore.KindIface, gocore.KindEface:
if off == 0 {
return ".type"
}
... | go | func typeFieldName(t *gocore.Type, off int64) string {
switch t.Kind {
case gocore.KindBool, gocore.KindInt, gocore.KindUint, gocore.KindFloat:
return ""
case gocore.KindComplex:
if off == 0 {
return ".real"
}
return ".imag"
case gocore.KindIface, gocore.KindEface:
if off == 0 {
return ".type"
}
... | [
"func",
"typeFieldName",
"(",
"t",
"*",
"gocore",
".",
"Type",
",",
"off",
"int64",
")",
"string",
"{",
"switch",
"t",
".",
"Kind",
"{",
"case",
"gocore",
".",
"KindBool",
",",
"gocore",
".",
"KindInt",
",",
"gocore",
".",
"KindUint",
",",
"gocore",
... | // typeFieldName returns the name of the field at offset off in t. | [
"typeFieldName",
"returns",
"the",
"name",
"of",
"the",
"field",
"at",
"offset",
"off",
"in",
"t",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/cmd/viewcore/main.go#L793-L834 | test |
golang/debug | internal/gocore/process.go | FindFunc | func (p *Process) FindFunc(pc core.Address) *Func {
return p.funcTab.find(pc)
} | go | func (p *Process) FindFunc(pc core.Address) *Func {
return p.funcTab.find(pc)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"FindFunc",
"(",
"pc",
"core",
".",
"Address",
")",
"*",
"Func",
"{",
"return",
"p",
".",
"funcTab",
".",
"find",
"(",
"pc",
")",
"\n",
"}"
] | // FindFunc returns the function which contains the code at address pc, if any. | [
"FindFunc",
"returns",
"the",
"function",
"which",
"contains",
"the",
"code",
"at",
"address",
"pc",
"if",
"any",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/process.go#L99-L101 | test |
golang/debug | internal/gocore/process.go | Core | func Core(proc *core.Process) (p *Process, err error) {
// Make sure we have DWARF info.
if _, err := proc.DWARF(); err != nil {
return nil, err
}
// Guard against failures of proc.Read* routines.
/*
defer func() {
e := recover()
if e == nil {
return
}
p = nil
if x, ok := e.(error); ok {
... | go | func Core(proc *core.Process) (p *Process, err error) {
// Make sure we have DWARF info.
if _, err := proc.DWARF(); err != nil {
return nil, err
}
// Guard against failures of proc.Read* routines.
/*
defer func() {
e := recover()
if e == nil {
return
}
p = nil
if x, ok := e.(error); ok {
... | [
"func",
"Core",
"(",
"proc",
"*",
"core",
".",
"Process",
")",
"(",
"p",
"*",
"Process",
",",
"err",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"proc",
".",
"DWARF",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // Core takes a loaded core file and extracts Go information from it. | [
"Core",
"takes",
"a",
"loaded",
"core",
"file",
"and",
"extracts",
"Go",
"information",
"from",
"it",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/process.go#L112-L162 | test |
golang/debug | internal/gocore/region.go | Address | func (r region) Address() core.Address {
if r.typ.Kind != KindPtr {
panic("can't ask for the Address of a non-pointer " + r.typ.Name)
}
return r.p.proc.ReadPtr(r.a)
} | go | func (r region) Address() core.Address {
if r.typ.Kind != KindPtr {
panic("can't ask for the Address of a non-pointer " + r.typ.Name)
}
return r.p.proc.ReadPtr(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Address",
"(",
")",
"core",
".",
"Address",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindPtr",
"{",
"panic",
"(",
"\"can't ask for the Address of a non-pointer \"",
"+",
"r",
".",
"typ",
".",
"Name",
")",
"\n",
... | // Address returns the address that a region of pointer type points to. | [
"Address",
"returns",
"the",
"address",
"that",
"a",
"region",
"of",
"pointer",
"type",
"points",
"to",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L20-L25 | test |
golang/debug | internal/gocore/region.go | Int | func (r region) Int() int64 {
if r.typ.Kind != KindInt || r.typ.Size != r.p.proc.PtrSize() {
panic("not an int: " + r.typ.Name)
}
return r.p.proc.ReadInt(r.a)
} | go | func (r region) Int() int64 {
if r.typ.Kind != KindInt || r.typ.Size != r.p.proc.PtrSize() {
panic("not an int: " + r.typ.Name)
}
return r.p.proc.ReadInt(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Int",
"(",
")",
"int64",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindInt",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"r",
".",
"p",
".",
"proc",
".",
"PtrSize",
"(",
")",
"{",
"panic",
"(",
"\"not an ... | // Int returns the int value stored in r. | [
"Int",
"returns",
"the",
"int",
"value",
"stored",
"in",
"r",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L28-L33 | test |
golang/debug | internal/gocore/region.go | Uintptr | func (r region) Uintptr() uint64 {
if r.typ.Kind != KindUint || r.typ.Size != r.p.proc.PtrSize() {
panic("not a uintptr: " + r.typ.Name)
}
return r.p.proc.ReadUintptr(r.a)
} | go | func (r region) Uintptr() uint64 {
if r.typ.Kind != KindUint || r.typ.Size != r.p.proc.PtrSize() {
panic("not a uintptr: " + r.typ.Name)
}
return r.p.proc.ReadUintptr(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Uintptr",
"(",
")",
"uint64",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindUint",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"r",
".",
"p",
".",
"proc",
".",
"PtrSize",
"(",
")",
"{",
"panic",
"(",
"\"n... | // Uintptr returns the uintptr value stored in r. | [
"Uintptr",
"returns",
"the",
"uintptr",
"value",
"stored",
"in",
"r",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L36-L41 | test |
golang/debug | internal/gocore/region.go | Cast | func (r region) Cast(typ string) region {
return region{p: r.p, a: r.a, typ: r.p.findType(typ)}
} | go | func (r region) Cast(typ string) region {
return region{p: r.p, a: r.a, typ: r.p.findType(typ)}
} | [
"func",
"(",
"r",
"region",
")",
"Cast",
"(",
"typ",
"string",
")",
"region",
"{",
"return",
"region",
"{",
"p",
":",
"r",
".",
"p",
",",
"a",
":",
"r",
".",
"a",
",",
"typ",
":",
"r",
".",
"p",
".",
"findType",
"(",
"typ",
")",
"}",
"\n",
... | // Cast the region to the given type. | [
"Cast",
"the",
"region",
"to",
"the",
"given",
"type",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L44-L46 | test |
golang/debug | internal/gocore/region.go | Deref | func (r region) Deref() region {
if r.typ.Kind != KindPtr {
panic("can't deref on non-pointer: " + r.typ.Name)
}
if r.typ.Elem == nil {
panic("can't deref unsafe.Pointer")
}
p := r.p.proc.ReadPtr(r.a)
return region{p: r.p, a: p, typ: r.typ.Elem}
} | go | func (r region) Deref() region {
if r.typ.Kind != KindPtr {
panic("can't deref on non-pointer: " + r.typ.Name)
}
if r.typ.Elem == nil {
panic("can't deref unsafe.Pointer")
}
p := r.p.proc.ReadPtr(r.a)
return region{p: r.p, a: p, typ: r.typ.Elem}
} | [
"func",
"(",
"r",
"region",
")",
"Deref",
"(",
")",
"region",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindPtr",
"{",
"panic",
"(",
"\"can't deref on non-pointer: \"",
"+",
"r",
".",
"typ",
".",
"Name",
")",
"\n",
"}",
"\n",
"if",
"r",
".",
... | // Deref loads from a pointer. r must contain a pointer. | [
"Deref",
"loads",
"from",
"a",
"pointer",
".",
"r",
"must",
"contain",
"a",
"pointer",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L49-L58 | test |
golang/debug | internal/gocore/region.go | Uint64 | func (r region) Uint64() uint64 {
if r.typ.Kind != KindUint || r.typ.Size != 8 {
panic("bad uint64 type " + r.typ.Name)
}
return r.p.proc.ReadUint64(r.a)
} | go | func (r region) Uint64() uint64 {
if r.typ.Kind != KindUint || r.typ.Size != 8 {
panic("bad uint64 type " + r.typ.Name)
}
return r.p.proc.ReadUint64(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Uint64",
"(",
")",
"uint64",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindUint",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"8",
"{",
"panic",
"(",
"\"bad uint64 type \"",
"+",
"r",
".",
"typ",
".",
"Name",... | // Uint64 returns the uint64 value stored in r.
// r must have type uint64. | [
"Uint64",
"returns",
"the",
"uint64",
"value",
"stored",
"in",
"r",
".",
"r",
"must",
"have",
"type",
"uint64",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L62-L67 | test |
golang/debug | internal/gocore/region.go | Uint32 | func (r region) Uint32() uint32 {
if r.typ.Kind != KindUint || r.typ.Size != 4 {
panic("bad uint32 type " + r.typ.Name)
}
return r.p.proc.ReadUint32(r.a)
} | go | func (r region) Uint32() uint32 {
if r.typ.Kind != KindUint || r.typ.Size != 4 {
panic("bad uint32 type " + r.typ.Name)
}
return r.p.proc.ReadUint32(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Uint32",
"(",
")",
"uint32",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindUint",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"4",
"{",
"panic",
"(",
"\"bad uint32 type \"",
"+",
"r",
".",
"typ",
".",
"Name",... | // Uint32 returns the uint32 value stored in r.
// r must have type uint32. | [
"Uint32",
"returns",
"the",
"uint32",
"value",
"stored",
"in",
"r",
".",
"r",
"must",
"have",
"type",
"uint32",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L71-L76 | test |
golang/debug | internal/gocore/region.go | Int32 | func (r region) Int32() int32 {
if r.typ.Kind != KindInt || r.typ.Size != 4 {
panic("bad int32 type " + r.typ.Name)
}
return r.p.proc.ReadInt32(r.a)
} | go | func (r region) Int32() int32 {
if r.typ.Kind != KindInt || r.typ.Size != 4 {
panic("bad int32 type " + r.typ.Name)
}
return r.p.proc.ReadInt32(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Int32",
"(",
")",
"int32",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindInt",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"4",
"{",
"panic",
"(",
"\"bad int32 type \"",
"+",
"r",
".",
"typ",
".",
"Name",
"... | // Int32 returns the int32 value stored in r.
// r must have type int32. | [
"Int32",
"returns",
"the",
"int32",
"value",
"stored",
"in",
"r",
".",
"r",
"must",
"have",
"type",
"int32",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L80-L85 | test |
golang/debug | internal/gocore/region.go | Uint16 | func (r region) Uint16() uint16 {
if r.typ.Kind != KindUint || r.typ.Size != 2 {
panic("bad uint16 type " + r.typ.Name)
}
return r.p.proc.ReadUint16(r.a)
} | go | func (r region) Uint16() uint16 {
if r.typ.Kind != KindUint || r.typ.Size != 2 {
panic("bad uint16 type " + r.typ.Name)
}
return r.p.proc.ReadUint16(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Uint16",
"(",
")",
"uint16",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindUint",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"2",
"{",
"panic",
"(",
"\"bad uint16 type \"",
"+",
"r",
".",
"typ",
".",
"Name",... | // Uint16 returns the uint16 value stored in r.
// r must have type uint16. | [
"Uint16",
"returns",
"the",
"uint16",
"value",
"stored",
"in",
"r",
".",
"r",
"must",
"have",
"type",
"uint16",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L89-L94 | test |
golang/debug | internal/gocore/region.go | Uint8 | func (r region) Uint8() uint8 {
if r.typ.Kind != KindUint || r.typ.Size != 1 {
panic("bad uint8 type " + r.typ.Name)
}
return r.p.proc.ReadUint8(r.a)
} | go | func (r region) Uint8() uint8 {
if r.typ.Kind != KindUint || r.typ.Size != 1 {
panic("bad uint8 type " + r.typ.Name)
}
return r.p.proc.ReadUint8(r.a)
} | [
"func",
"(",
"r",
"region",
")",
"Uint8",
"(",
")",
"uint8",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindUint",
"||",
"r",
".",
"typ",
".",
"Size",
"!=",
"1",
"{",
"panic",
"(",
"\"bad uint8 type \"",
"+",
"r",
".",
"typ",
".",
"Name",
... | // Uint8 returns the uint8 value stored in r.
// r must have type uint8. | [
"Uint8",
"returns",
"the",
"uint8",
"value",
"stored",
"in",
"r",
".",
"r",
"must",
"have",
"type",
"uint8",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L98-L103 | test |
golang/debug | internal/gocore/region.go | String | func (r region) String() string {
if r.typ.Kind != KindString {
panic("bad string type " + r.typ.Name)
}
p := r.p.proc.ReadPtr(r.a)
n := r.p.proc.ReadUintptr(r.a.Add(r.p.proc.PtrSize()))
b := make([]byte, n)
r.p.proc.ReadAt(b, p)
return string(b)
} | go | func (r region) String() string {
if r.typ.Kind != KindString {
panic("bad string type " + r.typ.Name)
}
p := r.p.proc.ReadPtr(r.a)
n := r.p.proc.ReadUintptr(r.a.Add(r.p.proc.PtrSize()))
b := make([]byte, n)
r.p.proc.ReadAt(b, p)
return string(b)
} | [
"func",
"(",
"r",
"region",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindString",
"{",
"panic",
"(",
"\"bad string type \"",
"+",
"r",
".",
"typ",
".",
"Name",
")",
"\n",
"}",
"\n",
"p",
":=",
"r",
".",
... | // String returns the value of the string stored in r. | [
"String",
"returns",
"the",
"value",
"of",
"the",
"string",
"stored",
"in",
"r",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L106-L115 | test |
golang/debug | internal/gocore/region.go | SlicePtr | func (r region) SlicePtr() region {
if r.typ.Kind != KindSlice {
panic("can't Ptr a non-slice")
}
return region{p: r.p, a: r.a, typ: &Type{Name: "*" + r.typ.Name[2:], Size: r.p.proc.PtrSize(), Kind: KindPtr, Elem: r.typ.Elem}}
} | go | func (r region) SlicePtr() region {
if r.typ.Kind != KindSlice {
panic("can't Ptr a non-slice")
}
return region{p: r.p, a: r.a, typ: &Type{Name: "*" + r.typ.Name[2:], Size: r.p.proc.PtrSize(), Kind: KindPtr, Elem: r.typ.Elem}}
} | [
"func",
"(",
"r",
"region",
")",
"SlicePtr",
"(",
")",
"region",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindSlice",
"{",
"panic",
"(",
"\"can't Ptr a non-slice\"",
")",
"\n",
"}",
"\n",
"return",
"region",
"{",
"p",
":",
"r",
".",
"p",
","... | // SlicePtr returns the pointer inside a slice. r must contain a slice. | [
"SlicePtr",
"returns",
"the",
"pointer",
"inside",
"a",
"slice",
".",
"r",
"must",
"contain",
"a",
"slice",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L128-L133 | test |
golang/debug | internal/gocore/region.go | SliceLen | func (r region) SliceLen() int64 {
if r.typ.Kind != KindSlice {
panic("can't len a non-slice")
}
return r.p.proc.ReadInt(r.a.Add(r.p.proc.PtrSize()))
} | go | func (r region) SliceLen() int64 {
if r.typ.Kind != KindSlice {
panic("can't len a non-slice")
}
return r.p.proc.ReadInt(r.a.Add(r.p.proc.PtrSize()))
} | [
"func",
"(",
"r",
"region",
")",
"SliceLen",
"(",
")",
"int64",
"{",
"if",
"r",
".",
"typ",
".",
"Kind",
"!=",
"KindSlice",
"{",
"panic",
"(",
"\"can't len a non-slice\"",
")",
"\n",
"}",
"\n",
"return",
"r",
".",
"p",
".",
"proc",
".",
"ReadInt",
... | // SliceLen returns the length of a slice. r must contain a slice. | [
"SliceLen",
"returns",
"the",
"length",
"of",
"a",
"slice",
".",
"r",
"must",
"contain",
"a",
"slice",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L136-L141 | test |
golang/debug | internal/gocore/region.go | Field | func (r region) Field(f string) region {
finfo := r.typ.field(f)
if finfo == nil {
panic("can't find field " + r.typ.Name + "." + f)
}
return region{p: r.p, a: r.a.Add(finfo.Off), typ: finfo.Type}
} | go | func (r region) Field(f string) region {
finfo := r.typ.field(f)
if finfo == nil {
panic("can't find field " + r.typ.Name + "." + f)
}
return region{p: r.p, a: r.a.Add(finfo.Off), typ: finfo.Type}
} | [
"func",
"(",
"r",
"region",
")",
"Field",
"(",
"f",
"string",
")",
"region",
"{",
"finfo",
":=",
"r",
".",
"typ",
".",
"field",
"(",
"f",
")",
"\n",
"if",
"finfo",
"==",
"nil",
"{",
"panic",
"(",
"\"can't find field \"",
"+",
"r",
".",
"typ",
"."... | // Field returns the part of r which contains the field f.
// r must contain a struct, and f must be one of its fields. | [
"Field",
"returns",
"the",
"part",
"of",
"r",
"which",
"contains",
"the",
"field",
"f",
".",
"r",
"must",
"contain",
"a",
"struct",
"and",
"f",
"must",
"be",
"one",
"of",
"its",
"fields",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/region.go#L153-L159 | test |
golang/debug | internal/core/read.go | ReadUint8 | func (p *Process) ReadUint8(a Address) uint8 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
return m.contents[a.Sub(m.min)]
} | go | func (p *Process) ReadUint8(a Address) uint8 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
return m.contents[a.Sub(m.min)]
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadUint8",
"(",
"a",
"Address",
")",
"uint8",
"{",
"m",
":=",
"p",
".",
"findMapping",
"(",
"a",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"address %x is not mapped in ... | // ReadUint8 returns a uint8 read from address a of the inferior. | [
"ReadUint8",
"returns",
"a",
"uint8",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L33-L39 | test |
golang/debug | internal/core/read.go | ReadUint16 | func (p *Process) ReadUint16(a Address) uint16 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 2 {
var buf [2]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint16(b)
}... | go | func (p *Process) ReadUint16(a Address) uint16 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 2 {
var buf [2]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint16(b)
}... | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadUint16",
"(",
"a",
"Address",
")",
"uint16",
"{",
"m",
":=",
"p",
".",
"findMapping",
"(",
"a",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"address %x is not mapped i... | // ReadUint16 returns a uint16 read from address a of the inferior. | [
"ReadUint16",
"returns",
"a",
"uint16",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L42-L57 | test |
golang/debug | internal/core/read.go | ReadUint32 | func (p *Process) ReadUint32(a Address) uint32 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 4 {
var buf [4]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint32(b)
}... | go | func (p *Process) ReadUint32(a Address) uint32 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 4 {
var buf [4]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint32(b)
}... | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadUint32",
"(",
"a",
"Address",
")",
"uint32",
"{",
"m",
":=",
"p",
".",
"findMapping",
"(",
"a",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"address %x is not mapped i... | // ReadUint32 returns a uint32 read from address a of the inferior. | [
"ReadUint32",
"returns",
"a",
"uint32",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L60-L75 | test |
golang/debug | internal/core/read.go | ReadUint64 | func (p *Process) ReadUint64(a Address) uint64 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 8 {
var buf [8]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint64(b)
}... | go | func (p *Process) ReadUint64(a Address) uint64 {
m := p.findMapping(a)
if m == nil {
panic(fmt.Errorf("address %x is not mapped in the core file", a))
}
b := m.contents[a.Sub(m.min):]
if len(b) < 8 {
var buf [8]byte
b = buf[:]
p.ReadAt(b, a)
}
if p.littleEndian {
return binary.LittleEndian.Uint64(b)
}... | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadUint64",
"(",
"a",
"Address",
")",
"uint64",
"{",
"m",
":=",
"p",
".",
"findMapping",
"(",
"a",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"address %x is not mapped i... | // ReadUint64 returns a uint64 read from address a of the inferior. | [
"ReadUint64",
"returns",
"a",
"uint64",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L78-L93 | test |
golang/debug | internal/core/read.go | ReadInt8 | func (p *Process) ReadInt8(a Address) int8 {
return int8(p.ReadUint8(a))
} | go | func (p *Process) ReadInt8(a Address) int8 {
return int8(p.ReadUint8(a))
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadInt8",
"(",
"a",
"Address",
")",
"int8",
"{",
"return",
"int8",
"(",
"p",
".",
"ReadUint8",
"(",
"a",
")",
")",
"\n",
"}"
] | // ReadInt8 returns an int8 read from address a of the inferior. | [
"ReadInt8",
"returns",
"an",
"int8",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L96-L98 | test |
golang/debug | internal/core/read.go | ReadInt16 | func (p *Process) ReadInt16(a Address) int16 {
return int16(p.ReadUint16(a))
} | go | func (p *Process) ReadInt16(a Address) int16 {
return int16(p.ReadUint16(a))
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadInt16",
"(",
"a",
"Address",
")",
"int16",
"{",
"return",
"int16",
"(",
"p",
".",
"ReadUint16",
"(",
"a",
")",
")",
"\n",
"}"
] | // ReadInt16 returns an int16 read from address a of the inferior. | [
"ReadInt16",
"returns",
"an",
"int16",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L101-L103 | test |
golang/debug | internal/core/read.go | ReadInt32 | func (p *Process) ReadInt32(a Address) int32 {
return int32(p.ReadUint32(a))
} | go | func (p *Process) ReadInt32(a Address) int32 {
return int32(p.ReadUint32(a))
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadInt32",
"(",
"a",
"Address",
")",
"int32",
"{",
"return",
"int32",
"(",
"p",
".",
"ReadUint32",
"(",
"a",
")",
")",
"\n",
"}"
] | // ReadInt32 returns an int32 read from address a of the inferior. | [
"ReadInt32",
"returns",
"an",
"int32",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L106-L108 | test |
golang/debug | internal/core/read.go | ReadInt64 | func (p *Process) ReadInt64(a Address) int64 {
return int64(p.ReadUint64(a))
} | go | func (p *Process) ReadInt64(a Address) int64 {
return int64(p.ReadUint64(a))
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadInt64",
"(",
"a",
"Address",
")",
"int64",
"{",
"return",
"int64",
"(",
"p",
".",
"ReadUint64",
"(",
"a",
")",
")",
"\n",
"}"
] | // ReadInt64 returns an int64 read from address a of the inferior. | [
"ReadInt64",
"returns",
"an",
"int64",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L111-L113 | test |
golang/debug | internal/core/read.go | ReadUintptr | func (p *Process) ReadUintptr(a Address) uint64 {
if p.ptrSize == 4 {
return uint64(p.ReadUint32(a))
}
return p.ReadUint64(a)
} | go | func (p *Process) ReadUintptr(a Address) uint64 {
if p.ptrSize == 4 {
return uint64(p.ReadUint32(a))
}
return p.ReadUint64(a)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadUintptr",
"(",
"a",
"Address",
")",
"uint64",
"{",
"if",
"p",
".",
"ptrSize",
"==",
"4",
"{",
"return",
"uint64",
"(",
"p",
".",
"ReadUint32",
"(",
"a",
")",
")",
"\n",
"}",
"\n",
"return",
"p",
".",
... | // ReadUintptr returns a uint of pointer size read from address a of the inferior. | [
"ReadUintptr",
"returns",
"a",
"uint",
"of",
"pointer",
"size",
"read",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L116-L121 | test |
golang/debug | internal/core/read.go | ReadPtr | func (p *Process) ReadPtr(a Address) Address {
return Address(p.ReadUintptr(a))
} | go | func (p *Process) ReadPtr(a Address) Address {
return Address(p.ReadUintptr(a))
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadPtr",
"(",
"a",
"Address",
")",
"Address",
"{",
"return",
"Address",
"(",
"p",
".",
"ReadUintptr",
"(",
"a",
")",
")",
"\n",
"}"
] | // ReadPtr returns a pointer loaded from address a of the inferior. | [
"ReadPtr",
"returns",
"a",
"pointer",
"loaded",
"from",
"address",
"a",
"of",
"the",
"inferior",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L132-L134 | test |
golang/debug | internal/core/read.go | ReadCString | func (p *Process) ReadCString(a Address) string {
for n := int64(0); ; n++ {
if p.ReadUint8(a.Add(n)) == 0 {
b := make([]byte, n)
p.ReadAt(b, a)
return string(b)
}
}
} | go | func (p *Process) ReadCString(a Address) string {
for n := int64(0); ; n++ {
if p.ReadUint8(a.Add(n)) == 0 {
b := make([]byte, n)
p.ReadAt(b, a)
return string(b)
}
}
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"ReadCString",
"(",
"a",
"Address",
")",
"string",
"{",
"for",
"n",
":=",
"int64",
"(",
"0",
")",
";",
";",
"n",
"++",
"{",
"if",
"p",
".",
"ReadUint8",
"(",
"a",
".",
"Add",
"(",
"n",
")",
")",
"==",
... | // ReadCString reads a null-terminated string starting at address a. | [
"ReadCString",
"reads",
"a",
"null",
"-",
"terminated",
"string",
"starting",
"at",
"address",
"a",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L137-L145 | test |
golang/debug | internal/core/mapping.go | Source | func (m *Mapping) Source() (string, int64) {
if m.f == nil {
return "", 0
}
return m.f.Name(), m.off
} | go | func (m *Mapping) Source() (string, int64) {
if m.f == nil {
return "", 0
}
return m.f.Name(), m.off
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"Source",
"(",
")",
"(",
"string",
",",
"int64",
")",
"{",
"if",
"m",
".",
"f",
"==",
"nil",
"{",
"return",
"\"\"",
",",
"0",
"\n",
"}",
"\n",
"return",
"m",
".",
"f",
".",
"Name",
"(",
")",
",",
"m",
... | // Source returns the backing file and offset for the mapping, or "", 0 if none. | [
"Source",
"returns",
"the",
"backing",
"file",
"and",
"offset",
"for",
"the",
"mapping",
"or",
"0",
"if",
"none",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/mapping.go#L53-L58 | test |
golang/debug | internal/core/mapping.go | findMapping | func (p *Process) findMapping(a Address) *Mapping {
t3 := p.pageTable[a>>52]
if t3 == nil {
return nil
}
t2 := t3[a>>42%(1<<10)]
if t2 == nil {
return nil
}
t1 := t2[a>>32%(1<<10)]
if t1 == nil {
return nil
}
t0 := t1[a>>22%(1<<10)]
if t0 == nil {
return nil
}
return t0[a>>12%(1<<10)]
} | go | func (p *Process) findMapping(a Address) *Mapping {
t3 := p.pageTable[a>>52]
if t3 == nil {
return nil
}
t2 := t3[a>>42%(1<<10)]
if t2 == nil {
return nil
}
t1 := t2[a>>32%(1<<10)]
if t1 == nil {
return nil
}
t0 := t1[a>>22%(1<<10)]
if t0 == nil {
return nil
}
return t0[a>>12%(1<<10)]
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"findMapping",
"(",
"a",
"Address",
")",
"*",
"Mapping",
"{",
"t3",
":=",
"p",
".",
"pageTable",
"[",
"a",
">>",
"52",
"]",
"\n",
"if",
"t3",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"t2",
":=",... | // findMapping is simple enough that it inlines. | [
"findMapping",
"is",
"simple",
"enough",
"that",
"it",
"inlines",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/mapping.go#L115-L133 | test |
golang/debug | internal/core/address.go | Max | func (a Address) Max(b Address) Address {
if a > b {
return a
}
return b
} | go | func (a Address) Max(b Address) Address {
if a > b {
return a
}
return b
} | [
"func",
"(",
"a",
"Address",
")",
"Max",
"(",
"b",
"Address",
")",
"Address",
"{",
"if",
"a",
">",
"b",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // Max returns the larger of a and b. | [
"Max",
"returns",
"the",
"larger",
"of",
"a",
"and",
"b",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/address.go#L21-L26 | test |
golang/debug | internal/core/address.go | Min | func (a Address) Min(b Address) Address {
if a < b {
return a
}
return b
} | go | func (a Address) Min(b Address) Address {
if a < b {
return a
}
return b
} | [
"func",
"(",
"a",
"Address",
")",
"Min",
"(",
"b",
"Address",
")",
"Address",
"{",
"if",
"a",
"<",
"b",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // Min returns the smaller of a and b. | [
"Min",
"returns",
"the",
"smaller",
"of",
"a",
"and",
"b",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/address.go#L29-L34 | test |
golang/debug | internal/core/address.go | Align | func (a Address) Align(x int64) Address {
return (a + Address(x) - 1) & ^(Address(x) - 1)
} | go | func (a Address) Align(x int64) Address {
return (a + Address(x) - 1) & ^(Address(x) - 1)
} | [
"func",
"(",
"a",
"Address",
")",
"Align",
"(",
"x",
"int64",
")",
"Address",
"{",
"return",
"(",
"a",
"+",
"Address",
"(",
"x",
")",
"-",
"1",
")",
"&",
"^",
"(",
"Address",
"(",
"x",
")",
"-",
"1",
")",
"\n",
"}"
] | // Align rounds a up to a multiple of x.
// x must be a power of 2. | [
"Align",
"rounds",
"a",
"up",
"to",
"a",
"multiple",
"of",
"x",
".",
"x",
"must",
"be",
"a",
"power",
"of",
"2",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/address.go#L38-L40 | test |
golang/debug | internal/gocore/dominator.go | initialize | func (d *ltDom) initialize() {
type workItem struct {
name vName
parentName vName
}
// Initialize objs for mapping from object index back to Object.
i := 0
d.p.ForEachObject(func(x Object) bool {
d.objs[i] = x
i++
return true
})
// Add roots to the work stack, essentially pretending to visit
/... | go | func (d *ltDom) initialize() {
type workItem struct {
name vName
parentName vName
}
// Initialize objs for mapping from object index back to Object.
i := 0
d.p.ForEachObject(func(x Object) bool {
d.objs[i] = x
i++
return true
})
// Add roots to the work stack, essentially pretending to visit
/... | [
"func",
"(",
"d",
"*",
"ltDom",
")",
"initialize",
"(",
")",
"{",
"type",
"workItem",
"struct",
"{",
"name",
"vName",
"\n",
"parentName",
"vName",
"\n",
"}",
"\n",
"i",
":=",
"0",
"\n",
"d",
".",
"p",
".",
"ForEachObject",
"(",
"func",
"(",
"x",
... | // initialize implements step 1 of LT. | [
"initialize",
"implements",
"step",
"1",
"of",
"LT",
"."
] | 19561fee47cf8cd0400d1b094c5898002f97cf90 | https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/dominator.go#L121-L176 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.