Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdb: No struct type named runtime.rtype #9326

Closed
andredasilvapinto opened this issue Dec 15, 2014 · 19 comments
Closed

gdb: No struct type named runtime.rtype #9326

andredasilvapinto opened this issue Dec 15, 2014 · 19 comments
Milestone

Comments

@andredasilvapinto
Copy link

@andredasilvapinto andredasilvapinto commented Dec 15, 2014

I'm having an error while trying to manually load runtime-gdb.py on GDB.

go1.4 linux/amd64
gdb 7.8
Ubuntu 14.04.1 LTS

gdb ./collect-jmx.test -d $GOROOT
...
(gdb) source /usr/local/go/src/runtime/runtime-gdb.py 
Loading Go Runtime support.
Traceback (most recent call last):
  File "/usr/local/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.
@ianlancetaylor ianlancetaylor changed the title GDB - No struct type named runtime.rtype gdb: No struct type named runtime.rtype Dec 15, 2014
@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@pnasrat
Copy link

@pnasrat pnasrat commented Dec 16, 2014

Replicated using https://github.com/golang/example/tree/master/stringutil

go test -c .

Using GDB:

gdb -q ./stringutil.test
Reading symbols from ./stringutil.test...done.
(gdb) source /usr/src/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "/usr/src/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.
(gdb) set pagination off
(gdb) set logging on
Copying output to gdb.txt.
(gdb) info types
# much output
(gdb) quit

Examining the types we see

grep runtime gdb.txt   | grep type;
struct []*runtime._type;
typedef struct runtime.iface error;
typedef struct runtime.iface flag.Value;
typedef struct runtime.iface flag.boolFlag;
typedef struct runtime.iface fmt.Formatter;
typedef struct runtime.iface fmt.GoStringer;
typedef struct runtime.iface fmt.Scanner;
typedef struct runtime.iface fmt.Stringer;
typedef struct runtime.iface fmt.runeUnreader;
typedef void (struct runtime.g *) func(*runtime.g);
typedef void (struct runtime.stkframe *, void *, bool *) func(*runtime.stkframe, unsafe.Pointer) bool;
typedef void (struct []runtime.StackRecord, int *, bool *) func([]runtime.StackRecord) (int, bool);
typedef struct runtime.iface interface { runtime.f() };
typedef struct runtime.eface interface {};
typedef struct runtime.iface io.Reader;
typedef struct runtime.iface io.ReaderFrom;
typedef struct runtime.iface io.RuneReader;
typedef struct runtime.iface io.Writer;
typedef struct runtime.iface io.WriterTo;
typedef struct hash<string,*runtime/pprof.Profile> * map[string]*runtime/pprof.Profile;
typedef struct runtime.iface os.FileInfo;
typedef struct runtime.iface os.Signal;
typedef struct runtime.iface reflect.Type;
typedef struct runtime.iface regexp.input;
struct runtime._type;
typedef runtime.bucketType;
struct runtime.chantype;
typedef struct runtime.iface runtime.fInterface;
struct runtime.functype;
struct runtime.interfacetype;
typedef runtime.intptr;
struct runtime.maptype;
typedef runtime.pageID;
struct runtime.ptrtype;
struct runtime.slicetype;
typedef struct runtime.iface runtime.stringer;
struct runtime.typeAlg;
typedef runtime.uintreg;
struct runtime.uncommontype;
typedef struct runtime.iface runtime/pprof.countProfile;
typedef struct runtime.iface sort.Interface;
typedef struct runtime.iface sync.Locker;
@pnasrat
Copy link

@pnasrat pnasrat commented Dec 16, 2014

Looking at the dist source http://golang.org/src/runtime/type.h versus https://github.com/golang/go/blob/master/src/reflect/type.go

It kind of works (there seems to be some issue still) if I change runtime-gdb.py to lookup reflect.rtype. I can set a breakpoint and list and use next.

(gdb) break reverse.go:21
Breakpoint 1 at 0x45a4e0: file /go/src/stringutil/reverse.go, line 21.
Starting program: /go/src/stringutil/stringutil.test



^CPython Exception <class 'KeyboardInterrupt'> Quit:
Breakpoint 1, stringutil.Reverse (s="Hello, world", ~r1=) at /go/src/stringutil/reverse.go:21
21  func Reverse(s string) string {
(gdb) p s
$1 = "Hello, world"
@randall77
Copy link
Contributor

@randall77 randall77 commented Dec 16, 2014

Did you also try runtime._type? That's what runtime.type is now called.

@pnasrat
Copy link

@pnasrat pnasrat commented Dec 16, 2014

@randall77 it's looking for runtime.rtype which was copied from reflect.rtype for gdb not _type

@pnasrat
Copy link

@pnasrat pnasrat commented Dec 16, 2014

Would it be helpful to have some test cases for the python gdb support that could be run?

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Dec 16, 2014

Yes, I think some test cases would be helpful. We couldn't run them in all cases, but perhaps we could run them if a suitable version of gdb was installed.

@pnasrat
Copy link

@pnasrat pnasrat commented Dec 16, 2014

OK I'll take a look at doing this but it may not be until next week.

@hustcat
Copy link

@hustcat hustcat commented Dec 30, 2014

+1 When I use gdb to debug docker, and I encountered the same problem.

Linux/CentOS 6.5
golang 1.3
gdb 7.2

@pnasrat
Copy link

@pnasrat pnasrat commented Jan 14, 2015

@zhengzhiren
Copy link

@zhengzhiren zhengzhiren commented Feb 27, 2015

I have the same issue.
CentOS 6.5
gdb 7.9
golang 1.4.2

(gdb) source ~/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "~/go/src/runtime/runtime-gdb.py", line 205, in <module>
gdb.error: No struct type named runtime.rtype.
@cevaris
Copy link

@cevaris cevaris commented Mar 8, 2015

👍

(gdb) source /go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.
(gdb)
@qingfeng-fy
Copy link

@qingfeng-fy qingfeng-fy commented May 21, 2015

you shold modify runtime-gdb.py:
205 _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
206
207
208 def iface_commontype(obj):
209 if is_iface(obj):
210 go_type_ptr = obj['tab']['_type']
211 elif is_eface(obj):
212 go_type_ptr = obj['_type']
213 else:
214 return
215
216 return go_type_ptr.cast(_rctp_type).dereference()

to:
205 #_rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
206
207
208 def iface_commontype(obj):
209 if is_iface(obj):
210 go_type_ptr = obj['tab']['_type']
211 elif is_eface(obj):
212 go_type_ptr = obj['_type']
213 else:
214 return
215
216 # return go_type_ptr.cast(_rctp_type).dereference()
217 return go_type_ptr.cast(gdb.lookup_type("struct runtime.rtype").pointer()).dereference()

@anacrolix
Copy link
Contributor

@anacrolix anacrolix commented May 23, 2015

@qingfeng-fy Thanks for the suggestion, I recommend a diff next time. Unfortunately this only moves the error to later:

(gdb) info goroutine
Python Exception <class 'gdb.error'> There is no member named status.:
Error occurred in Python command: There is no member named status.

(gdb) goroutine 1
Python Exception <class 'ValueError'> need more than 1 value to unpack:
Error occurred in Python command: need more than 1 value to unpack

This makes it difficult to use gdb in addressing #5838

@minux
Copy link
Member

@minux minux commented May 23, 2015

@anacrolix
Copy link
Contributor

@anacrolix anacrolix commented May 24, 2015

I will give it a try, thank you. Have you considered backporting the fix to 1.4.3?

@minux
Copy link
Member

@minux minux commented May 24, 2015

@anacrolix
Copy link
Contributor

@anacrolix anacrolix commented May 24, 2015

It works for me on tip.

@MironWong
Copy link

@MironWong MironWong commented Nov 3, 2015

@anacrolix, i meet the same problem with you. i have run the stringutil.test in my platform and modify the runtime-gdb.py . who can tell me how to solve it?

Linux/CentOS 7.1
golang 1.4.2
gdb GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-64.el7

@davecheney
Copy link
Contributor

@davecheney davecheney commented Nov 3, 2015

@Huangminlong this issue is fixed in Go 1.5 or later. Please open a new issue if you are still experiencing problems after upgrading to Go 1.5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet