heap_dump 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -583,6 +583,8 @@ typedef struct rb_context_struct {
583
583
  size_t machine_stack_size;
584
584
  } rb_context_t;
585
585
 
586
+
587
+
586
588
  enum fiber_status {
587
589
  CREATED,
588
590
  RUNNING,
@@ -605,11 +607,111 @@ typedef struct rb_fiber_struct {
605
607
 
606
608
 
607
609
 
610
+ static void yg_fiber_status(enum fiber_status status, walk_ctx_t* ctx){
611
+ switch(status){
612
+ case CREATED: yg_cstring("CREATED"); break;
613
+ case RUNNING: yg_cstring("RUNNING"); break;
614
+ case TERMINATED: yg_cstring("TERMINATED"); break;
615
+ }
616
+ }
608
617
 
609
618
 
610
619
 
620
+ static void dump_thread(rb_thread_t* th, walk_ctx_t *ctx){
621
+ if(th->stack){
622
+ VALUE *p = th->stack;
623
+ VALUE *sp = th->cfp->sp;
624
+ rb_control_frame_t *cfp = th->cfp;
625
+ rb_control_frame_t *limit_cfp = (void *)(th->stack + th->stack_size);
611
626
 
627
+ yg_cstring("stack");
628
+ yajl_gen_array_open(ctx->yajl);
629
+ while (p < sp) yg_id(*p++);
630
+ yajl_gen_array_close(ctx->yajl);
612
631
 
632
+ yg_cstring("cfp");
633
+ yajl_gen_array_open(ctx->yajl);
634
+ while (cfp != limit_cfp) {
635
+ yajl_gen_map_open(ctx->yajl);
636
+ rb_iseq_t *iseq = cfp->iseq;
637
+ ygh_id("proc", cfp->proc);
638
+ ygh_id("self", cfp->self);
639
+ if (iseq) {
640
+ ygh_id("iseq", RUBY_VM_NORMAL_ISEQ_P(iseq) ? iseq->self : (VALUE)iseq);
641
+ int line_no = rb_vm_get_sourceline(cfp);
642
+ ygh_rstring("file", iseq->filename);
643
+ ygh_int("line_no",line_no);
644
+ }
645
+ if (cfp->me){
646
+ const rb_method_entry_t *me = cfp->me;
647
+ //((rb_method_entry_t *)cfp->me)->mark = 1;
648
+ yg_cstring("me");
649
+ yajl_gen_map_open(ctx->yajl);
650
+ //
651
+ //rb_method_flag_t flag;
652
+ // char mark;
653
+ //rb_method_definition_t *def;
654
+ ygh_id("klass", me->klass);
655
+ ID id = me->called_id;
656
+
657
+ if(me->def){
658
+ id = me->def->original_id;
659
+ yg_cstring("def");
660
+ dump_method_definition_as_value(me->def, ctx);
661
+ }
662
+ if(id != ID_ALLOCATOR)
663
+ ygh_rstring("meth_id", rb_id2str(id));
664
+ yajl_gen_map_close(ctx->yajl);
665
+ }
666
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
667
+ yajl_gen_map_close(ctx->yajl);
668
+ }
669
+ yajl_gen_array_close(ctx->yajl);
670
+ }
671
+
672
+ //TODO: mark other...
673
+ ygh_id("first_proc", th->first_proc);
674
+ if (th->first_proc) ygh_id("first_proc", th->first_args);
675
+
676
+ ygh_id("thgroup", th->thgroup);
677
+ ygh_id("value", th->value);
678
+ ygh_id("errinfo", th->errinfo);
679
+ ygh_id("thrown_errinfo", th->thrown_errinfo);
680
+ ygh_id("local_svar", th->local_svar);
681
+ ygh_id("top_self", th->top_self);
682
+ ygh_id("top_wrapper", th->top_wrapper);
683
+ ygh_id("fiber", th->fiber);
684
+ ygh_id("root_fiber", th->root_fiber);
685
+ ygh_id("stat_insn_usage", th->stat_insn_usage);
686
+ ygh_id("last_status", th->last_status);
687
+ ygh_id("locking_mutex", th->locking_mutex);
688
+
689
+ // rb_mark_tbl(th->local_storage);
690
+
691
+ // if (GET_THREAD() != th && th->machine_stack_start && th->machine_stack_end) {
692
+ // rb_gc_mark_machine_stack(th);
693
+ // rb_gc_mark_locations((VALUE *)&th->machine_regs,
694
+ // (VALUE *)(&th->machine_regs) +
695
+ // sizeof(th->machine_regs) / sizeof(VALUE));
696
+ // }
697
+
698
+ yg_cstring("local_storage");
699
+ yajl_gen_array_open(ctx->yajl);
700
+ if(th->local_storage){
701
+ st_foreach(th->local_storage, dump_iv_entry, ctx); //?
702
+ }
703
+ yajl_gen_array_close(ctx->yajl);
704
+
705
+ // mark_event_hooks(th->event_hooks);
706
+ rb_event_hook_t *hook = th->event_hooks;
707
+ yg_cstring("event_hooks");
708
+ yajl_gen_array_open(ctx->yajl);
709
+ while(hook){
710
+ yg_id(hook->data);
711
+ hook = hook->next;
712
+ }
713
+ yajl_gen_array_close(ctx->yajl);
714
+ }
613
715
 
614
716
 
615
717
 
@@ -751,9 +853,20 @@ static void dump_data_if_known(VALUE obj, walk_ctx_t *ctx){
751
853
  //ygh_int("cont", fib->cont);
752
854
  yg_cstring("cont");
753
855
  yg_map();
754
- ygh_int("type", fib->cont.type);
856
+ //ygh_int("type", fib->cont.type);
857
+ yg_cstring("type");
858
+ yg_fiber_status(fib->cont.type, ctx);
859
+
755
860
  ygh_id("self", fib->cont.self);
756
861
  ygh_id("value", fib->cont.value);
862
+
863
+ yg_cstring("saved_thread");
864
+ yg_map();
865
+ //rb_thread_mark(&fib->cont.saved_thread);
866
+ dump_thread(&fib->cont.saved_thread, ctx);
867
+ yg_map_end();
868
+
869
+ //stacks:
757
870
  VALUE *vm_stack = fib->cont.vm_stack;
758
871
  int i = 0;
759
872
  for(; vm_stack && i < fib->cont.vm_stack_slen + fib->cont.vm_stack_clen; i++){
@@ -773,99 +886,7 @@ static void dump_data_if_known(VALUE obj, walk_ctx_t *ctx){
773
886
 
774
887
  if(!strcmp("VM/thread", typename)){
775
888
  const rb_thread_t *th = RTYPEDDATA_DATA(obj);
776
- if(th->stack){
777
- VALUE *p = th->stack;
778
- VALUE *sp = th->cfp->sp;
779
- rb_control_frame_t *cfp = th->cfp;
780
- rb_control_frame_t *limit_cfp = (void *)(th->stack + th->stack_size);
781
-
782
- yg_cstring("stack");
783
- yajl_gen_array_open(ctx->yajl);
784
- while (p < sp) yg_id(*p++);
785
- yajl_gen_array_close(ctx->yajl);
786
-
787
- yg_cstring("cfp");
788
- yajl_gen_array_open(ctx->yajl);
789
- while (cfp != limit_cfp) {
790
- yajl_gen_map_open(ctx->yajl);
791
- rb_iseq_t *iseq = cfp->iseq;
792
- ygh_id("proc", cfp->proc);
793
- ygh_id("self", cfp->self);
794
- if (iseq) {
795
- ygh_id("iseq", RUBY_VM_NORMAL_ISEQ_P(iseq) ? iseq->self : (VALUE)iseq);
796
- int line_no = rb_vm_get_sourceline(cfp);
797
- ygh_rstring("file", iseq->filename);
798
- ygh_int("line_no",line_no);
799
- }
800
- if (cfp->me){
801
- const rb_method_entry_t *me = cfp->me;
802
- //((rb_method_entry_t *)cfp->me)->mark = 1;
803
- yg_cstring("me");
804
- yajl_gen_map_open(ctx->yajl);
805
- //
806
- //rb_method_flag_t flag;
807
- // char mark;
808
- //rb_method_definition_t *def;
809
- ygh_id("klass", me->klass);
810
- ID id = me->called_id;
811
-
812
- if(me->def){
813
- id = me->def->original_id;
814
- yg_cstring("def");
815
- dump_method_definition_as_value(me->def, ctx);
816
- }
817
- if(id != ID_ALLOCATOR)
818
- ygh_rstring("meth_id", rb_id2str(id));
819
- yajl_gen_map_close(ctx->yajl);
820
- }
821
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
822
- yajl_gen_map_close(ctx->yajl);
823
- }
824
- yajl_gen_array_close(ctx->yajl);
825
- }
826
-
827
- //TODO: mark other...
828
- ygh_id("first_proc", th->first_proc);
829
- if (th->first_proc) ygh_id("first_proc", th->first_args);
830
-
831
- ygh_id("thgroup", th->thgroup);
832
- ygh_id("value", th->value);
833
- ygh_id("errinfo", th->errinfo);
834
- ygh_id("thrown_errinfo", th->thrown_errinfo);
835
- ygh_id("local_svar", th->local_svar);
836
- ygh_id("top_self", th->top_self);
837
- ygh_id("top_wrapper", th->top_wrapper);
838
- ygh_id("fiber", th->fiber);
839
- ygh_id("root_fiber", th->root_fiber);
840
- ygh_id("stat_insn_usage", th->stat_insn_usage);
841
- ygh_id("last_status", th->last_status);
842
- ygh_id("locking_mutex", th->locking_mutex);
843
-
844
- // rb_mark_tbl(th->local_storage);
845
-
846
- // if (GET_THREAD() != th && th->machine_stack_start && th->machine_stack_end) {
847
- // rb_gc_mark_machine_stack(th);
848
- // rb_gc_mark_locations((VALUE *)&th->machine_regs,
849
- // (VALUE *)(&th->machine_regs) +
850
- // sizeof(th->machine_regs) / sizeof(VALUE));
851
- // }
852
-
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);
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);
889
+ dump_thread(th, ctx);
869
890
  return;
870
891
  }
871
892
 
@@ -1,3 +1,3 @@
1
1
  module HeapDump
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
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.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-internal
16
- requirement: &70344745593220 !ruby/object:Gem::Requirement
16
+ requirement: &70141674362520 !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: *70344745593220
24
+ version_requirements: *70141674362520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: yajl-ruby
27
- requirement: &70344745592500 !ruby/object:Gem::Requirement
27
+ requirement: &70141674359400 !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: *70344745592500
35
+ version_requirements: *70141674359400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake-compiler
38
- requirement: &70344745591760 !ruby/object:Gem::Requirement
38
+ requirement: &70141674358340 !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: *70344745591760
46
+ version_requirements: *70141674358340
47
47
  description: dump ruby 1.9 heap contents
48
48
  email:
49
49
  - vasilyfedoseyev@gmail.com