Browse Source

dtrace: fix style in ustack helper

v0.11.0-release
Fedor Indutny 12 years ago
committed by Ben Noordhuis
parent
commit
3cb5bf1c0d
  1. 296
      src/v8ustack.d

296
src/v8ustack.d

@ -20,7 +20,7 @@
#define IS_SMI(value) \
((value & V8_SmiTagMask) == V8_SmiTag)
#define SMI_VALUE(value) \
((uint32_t) ((value) >> V8_SmiValueShift))
((uint32_t)(value) >> V8_SmiValueShift)
/*
* Heap objects usually start off with a Map pointer, itself another heap
@ -34,8 +34,7 @@
/*
* Determine the encoding and representation of a V8 string.
*/
#define V8_TYPE_STRING(type) \
(((type) & V8_IsNotStringMask) == V8_StringTag)
#define V8_TYPE_STRING(type) (((type) & V8_IsNotStringMask) == V8_StringTag)
#define V8_STRENC_ASCII(type) \
(((type) & V8_StringEncodingMask) == V8_AsciiStringTag)
@ -64,56 +63,19 @@
*/
#define COPYIN_UINT8(addr) (*(uint8_t*) copyin((addr), sizeof(uint8_t)))
#define COPYIN_UINT32(addr) (*(uint32_t*) copyin((addr), sizeof(uint32_t)))
#define COPYIN_UINT64(addr) (*(uint64_t*) copyin((addr), sizeof(uint64_t)))
#if defined(__i386)
# define COPYIN_PTR(addr) COPYIN_UINT32(addr)
# define off_t uint32_t
# define APPEND_PTR(p) APPEND_PTR_32(p)
#else
# define COPYIN_PTR(addr) COPYIN_UINT64(addr)
# define off_t uint64_t
# define APPEND_PTR(p) APPEND_PTR_64(p)
#endif
#define APPEND_CHR(c) (this->buf[this->off++] = (c))
#define APPEND_CHR4(s0, s1, s2, s3) \
APPEND_CHR(s0); \
APPEND_CHR(s1); \
APPEND_CHR(s2); \
APPEND_CHR(s3);
#define APPEND_CHR8(s0, s1, s2, s3, s4, s5, s6, s7) \
APPEND_CHR4(s0, s1, s2, s3) \
APPEND_CHR4(s4, s5, s6, s7)
#define APPEND_DGT(i, d) \
(((i) / (d)) ? APPEND_CHR('0' + ((i)/(d) % 10)) : 0)
#define APPEND_NUM(i) \
APPEND_DGT((i), 100000); \
APPEND_DGT((i), 10000); \
APPEND_DGT((i), 1000); \
APPEND_DGT((i), 100); \
APPEND_DGT((i), 10); \
APPEND_DGT((i), 1);
#define APPEND_HEX(d) \
APPEND_CHR((d) < 10 ? '0' + (d) : 'a' - 10 + (d))
#define APPEND_PTR_32(p) \
APPEND_HEX((p >> 28) & 0xf); \
APPEND_HEX((p >> 24) & 0xf); \
APPEND_HEX((p >> 20) & 0xf); \
APPEND_HEX((p >> 16) & 0xf); \
APPEND_HEX((p >> 12) & 0xf); \
APPEND_HEX((p >> 8) & 0xf); \
APPEND_HEX((p >> 4) & 0xf); \
APPEND_HEX((p) & 0xf);
#define APPEND_PTR_64(p) \
APPEND_PTR_32(p >> 32) \
APPEND_PTR_32(p)
/*
* The following macros are used to output ASCII SeqStrings, ConsStrings, and
* Node.js ExternalStrings. To represent each string, we use three fields:
@ -137,8 +99,8 @@
* Load "len" and "attrs" for the given "str".
*/
#define LOAD_STRFIELDS(str, len, attrs) \
len = SMI_VALUE(COPYIN_PTR(str + V8_OFF_STR_LENGTH)); \
this->map = V8_MAP_PTR(COPYIN_PTR(str + V8_OFF_HEAPOBJ_MAP)); \
len = SMI_VALUE(COPYIN_UINT32(str + V8_OFF_STR_LENGTH)); \
this->map = V8_MAP_PTR(COPYIN_UINT32(str + V8_OFF_HEAPOBJ_MAP)); \
attrs = COPYIN_UINT8(this->map + V8_OFF_MAP_ATTRS);
/*
@ -161,8 +123,8 @@
dtrace:helper:ustack: \
/!this->done && len > 0 && ASCII_EXTSTR(attrs)/ \
{ \
this->resource = COPYIN_PTR(str + V8_OFF_EXTSTR_RSRC); \
this->dataptr = COPYIN_PTR(this->resource + NODE_OFF_EXTSTR_DATA); \
this->resource = COPYIN_UINT32(str + V8_OFF_EXTSTR_RSRC); \
this->dataptr = COPYIN_UINT32(this->resource + NODE_OFF_EXTSTR_DATA); \
copyinto(this->dataptr, len, this->buf + this->off); \
this->off += len; \
}
@ -200,17 +162,17 @@
dtrace:helper:ustack: \
/!this->done/ \
{ \
this->s0str = this->s1str = this->s2str = (off_t) 0; \
this->s3str = this->s4str = this->s5str = (off_t) 0; \
this->s6str = this->s7str = this->s8str = (off_t) 0; \
this->s9str = this->s10str = this->s11str = (off_t) 0; \
this->s12str = this->s13str = (off_t) 0; \
this->s0str = this->s1str = this->s2str = 0; \
this->s3str = this->s4str = this->s5str = 0; \
this->s6str = this->s7str = this->s8str = 0; \
this->s9str = this->s10str = this->s11str = 0; \
this->s12str = this->s13str = 0; \
\
this->s0len = this->s1len = this->s2len = (off_t) 0; \
this->s3len = this->s4len = this->s5len = (off_t) 0; \
this->s6len = this->s7len = this->s8len = (off_t) 0; \
this->s9len = this->s10len = this->s11len = (off_t) 0; \
this->s12len = this->s13len = (off_t) 0; \
this->s0len = this->s1len = this->s2len = 0; \
this->s3len = this->s4len = this->s5len = 0; \
this->s6len = this->s7len = this->s8len = 0; \
this->s9len = this->s10len = this->s11len = 0; \
this->s12len = this->s13len = 0; \
\
this->s0attrs = this->s1attrs = this->s2attrs = 0; \
this->s3attrs = this->s4attrs = this->s5attrs = 0; \
@ -230,10 +192,10 @@
{ \
len = 0; \
\
s1s = COPYIN_PTR(str + V8_OFF_CONSSTR_CAR); \
s1s = COPYIN_UINT32(str + V8_OFF_CONSSTR_CAR); \
LOAD_STRFIELDS(s1s, s1l, s1a) \
\
s2s = COPYIN_PTR(str + V8_OFF_CONSSTR_CDR); \
s2s = COPYIN_UINT32(str + V8_OFF_CONSSTR_CDR); \
LOAD_STRFIELDS(s2s, s2l, s2a) \
}
@ -306,21 +268,21 @@ dtrace:helper:ustack:
this->done = 0;
/* program state */
this->ctx = (off_t) 0;
this->marker = (off_t) 0;
this->func = (off_t) 0;
this->shared = (off_t) 0;
this->map = (off_t) 0;
this->ctx = 0;
this->marker = 0;
this->func = 0;
this->shared = 0;
this->map = 0;
this->attrs = 0;
this->funcnamestr = (off_t) 0;
this->funcnamestr = 0;
this->funcnamelen = 0;
this->funcnameattrs = 0;
this->script = (off_t) 0;
this->scriptnamestr = (off_t) 0;
this->script = 0;
this->scriptnamestr = 0;
this->scriptnamelen = 0;
this->scriptnameattrs = 0;
this->position = 0;
this->line_ends = (off_t) 0;
this->line_ends = 0;
this->le_attrs = 0;
/* binary search fields */
@ -335,15 +297,27 @@ dtrace:helper:ustack:
*/
dtrace:helper:ustack:
{
this->ctx = COPYIN_PTR(this->fp + V8_OFF_FP_CONTEXT);
this->ctx = COPYIN_UINT32(this->fp + V8_OFF_FP_CONTEXT);
}
dtrace:helper:ustack:
/IS_SMI(this->ctx) && SMI_VALUE(this->ctx) == V8_FT_ADAPTOR/
{
this->done = 1;
APPEND_CHR8('<','<',' ','a','d','a','p','t');
APPEND_CHR8('o','r',' ','>','>','\0','\0','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('a');
APPEND_CHR('d');
APPEND_CHR('a');
APPEND_CHR('p');
APPEND_CHR('t');
APPEND_CHR('o');
APPEND_CHR('r');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -353,7 +327,7 @@ dtrace:helper:ustack:
dtrace:helper:ustack:
/!this->done/
{
this->marker = COPYIN_PTR(this->fp + V8_OFF_FP_MARKER);
this->marker = COPYIN_UINT32(this->fp + V8_OFF_FP_MARKER);
}
dtrace:helper:ustack:
@ -361,8 +335,18 @@ dtrace:helper:ustack:
SMI_VALUE(this->marker) == V8_FT_ENTRY/
{
this->done = 1;
APPEND_CHR8('<','<',' ','e','n','t','r','y');
APPEND_CHR4(' ','>','>','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('e');
APPEND_CHR('n');
APPEND_CHR('t');
APPEND_CHR('r');
APPEND_CHR('y');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -371,9 +355,27 @@ dtrace:helper:ustack:
SMI_VALUE(this->marker) == V8_FT_ENTRYCONSTRUCT/
{
this->done = 1;
APPEND_CHR8('<','<',' ','e','n','t','r','y');
APPEND_CHR8('_','c','o','n','s','t','r','u');
APPEND_CHR4('t',' ','>','>');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('e');
APPEND_CHR('n');
APPEND_CHR('t');
APPEND_CHR('r');
APPEND_CHR('y');
APPEND_CHR('_');
APPEND_CHR('c');
APPEND_CHR('o');
APPEND_CHR('n');
APPEND_CHR('s');
APPEND_CHR('t');
APPEND_CHR('r');
APPEND_CHR('u');
APPEND_CHR('c');
APPEND_CHR('t');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -383,8 +385,17 @@ dtrace:helper:ustack:
SMI_VALUE(this->marker) == V8_FT_EXIT/
{
this->done = 1;
APPEND_CHR8('<','<',' ','e','x','i','t',' ');
APPEND_CHR4('>','>','\0','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('e');
APPEND_CHR('x');
APPEND_CHR('i');
APPEND_CHR('t');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -393,8 +404,21 @@ dtrace:helper:ustack:
SMI_VALUE(this->marker) == V8_FT_INTERNAL/
{
this->done = 1;
APPEND_CHR8('<','<',' ','i','n','t','e','r');
APPEND_CHR8('n','a','l',' ','>','>','\0','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('i');
APPEND_CHR('n');
APPEND_CHR('t');
APPEND_CHR('e');
APPEND_CHR('r');
APPEND_CHR('n');
APPEND_CHR('a');
APPEND_CHR('l');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -403,9 +427,24 @@ dtrace:helper:ustack:
SMI_VALUE(this->marker) == V8_FT_CONSTRUCT/
{
this->done = 1;
APPEND_CHR8('<','<',' ','c','o','n','s','t');
APPEND_CHR8('r','u','c','t','o','r',' ','>');
APPEND_CHR4('>','\0','\0','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('c');
APPEND_CHR('o');
APPEND_CHR('n');
APPEND_CHR('s');
APPEND_CHR('t');
APPEND_CHR('r');
APPEND_CHR('u');
APPEND_CHR('c');
APPEND_CHR('t');
APPEND_CHR('o');
APPEND_CHR('r');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -417,8 +456,8 @@ dtrace:helper:ustack:
dtrace:helper:ustack:
/!this->done/
{
this->func = COPYIN_PTR(this->fp + V8_OFF_FP_FUNC);
this->map = V8_MAP_PTR(COPYIN_PTR(this->func + V8_OFF_HEAPOBJ_MAP));
this->func = COPYIN_UINT32(this->fp + V8_OFF_FP_FUNC);
this->map = V8_MAP_PTR(COPYIN_UINT32(this->func + V8_OFF_HEAPOBJ_MAP));
this->attrs = COPYIN_UINT8(this->map + V8_OFF_MAP_ATTRS);
}
@ -426,9 +465,26 @@ dtrace:helper:ustack:
/!this->done && this->attrs == V8_IT_CODE/
{
this->done = 1;
APPEND_CHR8('<','<',' ','i','n','t','e','r');
APPEND_CHR8('n','a','l',' ','c','o','d','e');
APPEND_CHR4(' ','>','>','\0');
APPEND_CHR('<');
APPEND_CHR('<');
APPEND_CHR(' ');
APPEND_CHR('i');
APPEND_CHR('n');
APPEND_CHR('t');
APPEND_CHR('e');
APPEND_CHR('r');
APPEND_CHR('n');
APPEND_CHR('a');
APPEND_CHR('l');
APPEND_CHR(' ');
APPEND_CHR('c');
APPEND_CHR('o');
APPEND_CHR('d');
APPEND_CHR('e');
APPEND_CHR(' ');
APPEND_CHR('>');
APPEND_CHR('>');
APPEND_CHR('\0');
stringof(this->buf);
}
@ -443,8 +499,8 @@ dtrace:helper:ustack:
this->map = 0;
this->attrs = 0;
this->shared = COPYIN_PTR(this->func + V8_OFF_FUNC_SHARED);
this->funcnamestr = COPYIN_PTR(this->shared + V8_OFF_SHARED_NAME);
this->shared = COPYIN_UINT32(this->func + V8_OFF_FUNC_SHARED);
this->funcnamestr = COPYIN_UINT32(this->shared + V8_OFF_SHARED_NAME);
LOAD_STRFIELDS(this->funcnamestr, this->funcnamelen,
this->funcnameattrs);
}
@ -457,11 +513,18 @@ dtrace:helper:ustack:
* some object then V8 will have computed an inferred name that we can
* include in the stack trace.
*/
APPEND_CHR8('(','a','n','o','n',')',' ','a');
APPEND_CHR('(');
APPEND_CHR('a');
APPEND_CHR('n');
APPEND_CHR('o');
APPEND_CHR('n');
APPEND_CHR(')');
APPEND_CHR(' ');
APPEND_CHR('a');
APPEND_CHR('s');
APPEND_CHR(' ');
this->funcnamestr = COPYIN_PTR(this->shared + V8_OFF_SHARED_INFERRED);
this->funcnamestr = COPYIN_UINT32(this->shared + V8_OFF_SHARED_INFERRED);
LOAD_STRFIELDS(this->funcnamestr, this->funcnamelen,
this->funcnameattrs);
}
@ -470,7 +533,10 @@ dtrace:helper:ustack:
/!this->done && this->funcnamelen == 0/
{
APPEND_CHR('(');
APPEND_CHR4('a','n','o','n');
APPEND_CHR('a');
APPEND_CHR('n');
APPEND_CHR('o');
APPEND_CHR('n');
APPEND_CHR(')');
}
@ -482,19 +548,15 @@ APPEND_V8STR(this->funcnamestr, this->funcnamelen, this->funcnameattrs)
dtrace:helper:ustack:
/!this->done/
{
this->script = COPYIN_PTR(this->shared + V8_OFF_SHARED_SCRIPT);
this->scriptnamestr = COPYIN_PTR(this->script + V8_OFF_SCRIPT_NAME);
this->script = COPYIN_UINT32(this->shared + V8_OFF_SHARED_SCRIPT);
this->scriptnamestr = COPYIN_UINT32(this->script + V8_OFF_SCRIPT_NAME);
LOAD_STRFIELDS(this->scriptnamestr, this->scriptnamelen,
this->scriptnameattrs);
APPEND_CHR4(' ','a','t',' ');
}
dtrace:helper:ustack:
/!this->done && this->scriptnamelen == 0/
{
APPEND_CHR8('<','u','n','k','n','o','w','n');
APPEND_CHR('>');
APPEND_CHR(' ');
APPEND_CHR('a');
APPEND_CHR('t');
APPEND_CHR(' ');
}
APPEND_V8STR(this->scriptnamestr, this->scriptnamelen, this->scriptnameattrs)
@ -506,8 +568,8 @@ dtrace:helper:ustack:
/!this->done/
{
this->position = COPYIN_UINT32(this->shared + V8_OFF_SHARED_FUNTOK);
this->line_ends = COPYIN_PTR(this->script + V8_OFF_SCRIPT_LENDS);
this->map = V8_MAP_PTR(COPYIN_PTR(this->line_ends + V8_OFF_HEAPOBJ_MAP));
this->line_ends = COPYIN_UINT32(this->script + V8_OFF_SCRIPT_LENDS);
this->map = V8_MAP_PTR(COPYIN_UINT32(this->line_ends + V8_OFF_HEAPOBJ_MAP));
this->le_attrs = COPYIN_UINT8(this->map + V8_OFF_MAP_ATTRS);
}
@ -519,7 +581,14 @@ dtrace:helper:ustack:
* undefined because V8 has not had to compute it yet. In this case we
* just show the raw position and call it a day.
*/
APPEND_CHR8(' ','p','o','s','i','t','i','o');
APPEND_CHR(' ');
APPEND_CHR('p');
APPEND_CHR('o');
APPEND_CHR('s');
APPEND_CHR('i');
APPEND_CHR('t');
APPEND_CHR('i');
APPEND_CHR('o');
APPEND_CHR('n');
APPEND_CHR(' ');
APPEND_NUM(this->position);
@ -539,10 +608,10 @@ dtrace:helper:ustack:
{
/* initialize binary search */
this->bsearch_line = this->position <
SMI_VALUE(COPYIN_PTR(this->line_ends + V8_OFF_FA_DATA)) ? 1 : 0;
COPYIN_UINT32(this->line_ends + V8_OFF_FA_DATA) ? 1 : 0;
this->bsearch_min = 0;
this->bsearch_max = this->bsearch_line != 0 ? 0 :
SMI_VALUE(COPYIN_PTR(this->line_ends + V8_OFF_FA_SIZE)) - 1;
SMI_VALUE(COPYIN_UINT32(this->line_ends + V8_OFF_FA_SIZE)) - 1;
}
/*
@ -559,18 +628,16 @@ dtrace:helper:ustack:
\
dtrace:helper:ustack: \
/!this->done && this->bsearch_max >= 1 && \
this->position > SMI_VALUE( \
COPYIN_PTR(this->line_ends + V8_OFF_FA_DATA + \
this->ii * sizeof (uint32_t)))/ \
this->position > COPYIN_UINT32(this->line_ends + V8_OFF_FA_DATA + \
this->ii * sizeof (uint32_t))/ \
{ \
this->bsearch_min = this->ii + 1; \
} \
\
dtrace:helper:ustack: \
/!this->done && this->bsearch_max >= 1 && \
this->position <= SMI_VALUE( \
COPYIN_PTR(this->line_ends + V8_OFF_FA_DATA + \
(this->ii - 1) * sizeof (uint32_t)))/ \
this->position <= COPYIN_UINT32(this->line_ends + V8_OFF_FA_DATA + \
(this->ii - 1) * sizeof (uint32_t))/ \
{ \
this->bsearch_max = this->ii - 1; \
}
@ -601,7 +668,10 @@ dtrace:helper:ustack:
/!this->done/
{
APPEND_CHR(' ');
APPEND_CHR4('l','i','n','e');
APPEND_CHR('l');
APPEND_CHR('i');
APPEND_CHR('n');
APPEND_CHR('e');
APPEND_CHR(' ');
APPEND_NUM(this->bsearch_line);
APPEND_CHR('\0');

Loading…
Cancel
Save