heap_dump 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/heap_dump/heap_dump.c +111 -3
- data/lib/heap_dump/version.rb +1 -1
- metadata +8 -8
data/ext/heap_dump/heap_dump.c
CHANGED
@@ -52,6 +52,12 @@ static ID classid;
|
|
52
52
|
#define ygh_cstring(key,str) {yg_cstring(key); yg_cstring(str);}
|
53
53
|
#define ygh_rstring(key,str) {yg_cstring(key); yg_rstring(str);}
|
54
54
|
|
55
|
+
#define yg_map() yajl_gen_map_open(ctx->yajl);
|
56
|
+
#define yg_map_end() yajl_gen_map_close(ctx->yajl);
|
57
|
+
#define yg_array() yajl_gen_array_open(ctx->yajl);
|
58
|
+
#define yg_array_end() yajl_gen_array_close(ctx->yajl);
|
59
|
+
|
60
|
+
|
55
61
|
// context for objectspace_walker callback
|
56
62
|
typedef struct walk_ctx {
|
57
63
|
int walker_called;
|
@@ -547,6 +553,66 @@ static void dump_block(const rb_block_t* block, walk_ctx_t *ctx){
|
|
547
553
|
}
|
548
554
|
|
549
555
|
|
556
|
+
#define CAPTURE_JUST_VALID_VM_STACK 1
|
557
|
+
|
558
|
+
enum context_type {
|
559
|
+
CONTINUATION_CONTEXT = 0,
|
560
|
+
FIBER_CONTEXT = 1,
|
561
|
+
ROOT_FIBER_CONTEXT = 2
|
562
|
+
};
|
563
|
+
|
564
|
+
typedef struct rb_context_struct {
|
565
|
+
enum context_type type;
|
566
|
+
VALUE self;
|
567
|
+
int argc;
|
568
|
+
VALUE value;
|
569
|
+
VALUE *vm_stack;
|
570
|
+
#ifdef CAPTURE_JUST_VALID_VM_STACK
|
571
|
+
size_t vm_stack_slen; /* length of stack (head of th->stack) */
|
572
|
+
size_t vm_stack_clen; /* length of control frames (tail of th->stack) */
|
573
|
+
#endif
|
574
|
+
VALUE *machine_stack;
|
575
|
+
VALUE *machine_stack_src;
|
576
|
+
#ifdef __ia64
|
577
|
+
VALUE *machine_register_stack;
|
578
|
+
VALUE *machine_register_stack_src;
|
579
|
+
int machine_register_stack_size;
|
580
|
+
#endif
|
581
|
+
rb_thread_t saved_thread;
|
582
|
+
rb_jmpbuf_t jmpbuf;
|
583
|
+
size_t machine_stack_size;
|
584
|
+
} rb_context_t;
|
585
|
+
|
586
|
+
enum fiber_status {
|
587
|
+
CREATED,
|
588
|
+
RUNNING,
|
589
|
+
TERMINATED
|
590
|
+
};
|
591
|
+
|
592
|
+
///TODO: move this out
|
593
|
+
typedef struct rb_fiber_struct {
|
594
|
+
rb_context_t cont;
|
595
|
+
VALUE prev;
|
596
|
+
enum fiber_status status;
|
597
|
+
struct rb_fiber_struct *prev_fiber;
|
598
|
+
struct rb_fiber_struct *next_fiber;
|
599
|
+
} rb_fiber_t;
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
550
616
|
static void dump_data_if_known(VALUE obj, walk_ctx_t *ctx){
|
551
617
|
|
552
618
|
// VM
|
@@ -679,6 +745,32 @@ static void dump_data_if_known(VALUE obj, walk_ctx_t *ctx){
|
|
679
745
|
return;
|
680
746
|
}
|
681
747
|
|
748
|
+
if(!strcmp("fiber", typename)){
|
749
|
+
rb_fiber_t *fib = RTYPEDDATA_DATA(obj);
|
750
|
+
ygh_id("prev", fib->prev);
|
751
|
+
//ygh_int("cont", fib->cont);
|
752
|
+
yg_cstring("cont");
|
753
|
+
yg_map();
|
754
|
+
ygh_int("type", fib->cont.type);
|
755
|
+
ygh_id("self", fib->cont.self);
|
756
|
+
ygh_id("value", fib->cont.value);
|
757
|
+
VALUE *vm_stack = fib->cont.vm_stack;
|
758
|
+
int i = 0;
|
759
|
+
for(; vm_stack && i < fib->cont.vm_stack_slen + fib->cont.vm_stack_clen; i++){
|
760
|
+
yg_id(*(vm_stack++));
|
761
|
+
}
|
762
|
+
vm_stack = fib->cont.vm_stack;
|
763
|
+
for(i = 0;vm_stack && i<fib->cont.machine_stack_size; i++){
|
764
|
+
yg_id(*(vm_stack++));
|
765
|
+
}
|
766
|
+
yg_cstring("stack");
|
767
|
+
yg_array();
|
768
|
+
|
769
|
+
yg_array_end();
|
770
|
+
yg_map_end();
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
|
682
774
|
if(!strcmp("VM/thread", typename)){
|
683
775
|
const rb_thread_t *th = RTYPEDDATA_DATA(obj);
|
684
776
|
if(th->stack){
|
@@ -758,8 +850,22 @@ static void dump_data_if_known(VALUE obj, walk_ctx_t *ctx){
|
|
758
850
|
// sizeof(th->machine_regs) / sizeof(VALUE));
|
759
851
|
// }
|
760
852
|
|
761
|
-
|
853
|
+
yg_cstring("local_storage");
|
854
|
+
yajl_gen_array_open(ctx->yajl);
|
855
|
+
if(th->local_storage){
|
856
|
+
st_foreach(th->local_storage, dump_iv_entry, ctx); //?
|
857
|
+
}
|
858
|
+
yajl_gen_array_close(ctx->yajl);
|
762
859
|
|
860
|
+
// mark_event_hooks(th->event_hooks);
|
861
|
+
rb_event_hook_t *hook = th->event_hooks;
|
862
|
+
yg_cstring("event_hooks");
|
863
|
+
yajl_gen_array_open(ctx->yajl);
|
864
|
+
while(hook){
|
865
|
+
yg_id(hook->data);
|
866
|
+
hook = hook->next;
|
867
|
+
}
|
868
|
+
yajl_gen_array_close(ctx->yajl);
|
763
869
|
return;
|
764
870
|
}
|
765
871
|
|
@@ -1350,7 +1456,7 @@ static void dump_machine_context(walk_ctx_t *ctx){
|
|
1350
1456
|
VALUE *stack_start, *stack_end;
|
1351
1457
|
|
1352
1458
|
|
1353
|
-
yg_cstring("
|
1459
|
+
yg_cstring("registers");
|
1354
1460
|
yajl_gen_array_open(ctx->yajl);
|
1355
1461
|
|
1356
1462
|
FLUSH_REGISTER_WINDOWS;
|
@@ -1369,9 +1475,11 @@ static void dump_machine_context(walk_ctx_t *ctx){
|
|
1369
1475
|
if(is_pointer_to_heap((void*)v, NULL))
|
1370
1476
|
yg_id(v);
|
1371
1477
|
}
|
1478
|
+
yajl_gen_array_close(ctx->yajl);
|
1372
1479
|
|
1373
1480
|
//printf("stack: %p %p\n", stack_start, stack_end);
|
1374
|
-
|
1481
|
+
yg_cstring("stack");
|
1482
|
+
yajl_gen_array_open(ctx->yajl);
|
1375
1483
|
//rb_gc_mark_locations(stack_start, stack_end);
|
1376
1484
|
if(stack_start < stack_end){
|
1377
1485
|
n = stack_end - stack_start;
|
data/lib/heap_dump/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heap_dump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-internal
|
16
|
-
requirement: &
|
16
|
+
requirement: &70344745593220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70344745593220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yajl-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &70344745592500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.1'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70344745592500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake-compiler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70344745591760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70344745591760
|
47
47
|
description: dump ruby 1.9 heap contents
|
48
48
|
email:
|
49
49
|
- vasilyfedoseyev@gmail.com
|