Commit dd93df35 authored by Luuk van Dijk's avatar Luuk van Dijk

runtime: fix gdb support for channels.

R=rsc
CC=golang-dev
https://golang.org/cl/4418043
parent 9c3ecb36
...@@ -1376,20 +1376,18 @@ synthesizemaptypes(DWDie *die) ...@@ -1376,20 +1376,18 @@ synthesizemaptypes(DWDie *die)
static void static void
synthesizechantypes(DWDie *die) synthesizechantypes(DWDie *die)
{ {
DWDie *sudog, *waitq, *link, *hchan, DWDie *sudog, *waitq, *hchan,
*dws, *dww, *dwh, *elemtype; *dws, *dww, *dwh, *elemtype;
DWAttr *a; DWAttr *a;
int elemsize, linksize, sudogsize; int elemsize, sudogsize;
sudog = defgotype(lookup_or_diag("type.runtime.sudog")); sudog = defgotype(lookup_or_diag("type.runtime.sudog"));
waitq = defgotype(lookup_or_diag("type.runtime.waitq")); waitq = defgotype(lookup_or_diag("type.runtime.waitq"));
link = defgotype(lookup_or_diag("type.runtime.link"));
hchan = defgotype(lookup_or_diag("type.runtime.hchan")); hchan = defgotype(lookup_or_diag("type.runtime.hchan"));
if (sudog == nil || waitq == nil || link == nil || hchan == nil) if (sudog == nil || waitq == nil || hchan == nil)
return; return;
sudogsize = getattr(sudog, DW_AT_byte_size)->value; sudogsize = getattr(sudog, DW_AT_byte_size)->value;
linksize = getattr(link, DW_AT_byte_size)->value;
for (; die != nil; die = die->link) { for (; die != nil; die = die->link) {
if (die->abbrev != DW_ABRV_CHANTYPE) if (die->abbrev != DW_ABRV_CHANTYPE)
...@@ -1422,7 +1420,7 @@ synthesizechantypes(DWDie *die) ...@@ -1422,7 +1420,7 @@ synthesizechantypes(DWDie *die)
copychildren(dwh, hchan); copychildren(dwh, hchan);
substitutetype(dwh, "recvq", dww); substitutetype(dwh, "recvq", dww);
substitutetype(dwh, "sendq", dww); substitutetype(dwh, "sendq", dww);
substitutetype(dwh, "free", dws); substitutetype(dwh, "free", defptrto(dws));
newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT,
getattr(hchan, DW_AT_byte_size)->value, NULL); getattr(hchan, DW_AT_byte_size)->value, NULL);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
static int32 debug = 0; static int32 debug = 0;
typedef struct Link Link;
typedef struct WaitQ WaitQ; typedef struct WaitQ WaitQ;
typedef struct SudoG SudoG; typedef struct SudoG SudoG;
typedef struct Select Select; typedef struct Select Select;
...@@ -51,12 +50,6 @@ struct Hchan ...@@ -51,12 +50,6 @@ struct Hchan
// chanbuf(c, i) is pointer to the i'th slot in the buffer. // chanbuf(c, i) is pointer to the i'th slot in the buffer.
#define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i)) #define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
struct Link
{
Link* link; // asynch queue circular linked list
byte elem[8]; // asynch queue data element (+ more)
};
enum enum
{ {
// Scase.kind // Scase.kind
......
...@@ -122,10 +122,13 @@ class ChanTypePrinter: ...@@ -122,10 +122,13 @@ class ChanTypePrinter:
return str(self.val.type) return str(self.val.type)
def children(self): def children(self):
ptr = self.val['recvdataq'] # see chan.c chanbuf()
for idx in range(self.val["qcount"]): et = [x.type for x in self.val['free'].type.target().fields() if x.name == 'elem'][0]
yield ('[%d]' % idx, ptr['elem']) ptr = (self.val.address + 1).cast(et.pointer())
ptr = ptr['link'] for i in range(self.val["qcount"]):
j = (self.val["recvx"] + i) % self.val["dataqsiz"]
yield ('[%d]' % i, (ptr + j).dereference())
# #
# Register all the *Printer classes above. # Register all the *Printer classes above.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment