39 // // dump succeeded |
39 // // dump succeeded |
40 // } |
40 // } |
41 // } |
41 // } |
42 // |
42 // |
43 |
43 |
|
44 class outputStream; |
|
45 |
44 class HeapDumper : public StackObj { |
46 class HeapDumper : public StackObj { |
45 private: |
47 private: |
46 char* _error; |
48 char* _error; |
47 bool _print_to_tty; |
|
48 bool _gc_before_heap_dump; |
49 bool _gc_before_heap_dump; |
49 bool _oome; |
50 bool _oome; |
50 elapsedTimer _t; |
51 elapsedTimer _t; |
51 |
52 |
52 HeapDumper(bool gc_before_heap_dump, bool print_to_tty, bool oome) : |
53 HeapDumper(bool gc_before_heap_dump, bool oome) : |
53 _error(NULL), _print_to_tty(print_to_tty), _gc_before_heap_dump(gc_before_heap_dump), _oome(oome) { } |
54 _error(NULL), _gc_before_heap_dump(gc_before_heap_dump), _oome(oome) { } |
54 |
55 |
55 // string representation of error |
56 // string representation of error |
56 char* error() const { return _error; } |
57 char* error() const { return _error; } |
57 void set_error(char* error); |
58 void set_error(char* error); |
58 |
|
59 // indicates if progress messages can be sent to tty |
|
60 bool print_to_tty() const { return _print_to_tty; } |
|
61 |
59 |
62 // internal timer. |
60 // internal timer. |
63 elapsedTimer* timer() { return &_t; } |
61 elapsedTimer* timer() { return &_t; } |
64 |
62 |
65 static void dump_heap(bool oome); |
63 static void dump_heap(bool oome); |
66 |
64 |
67 public: |
65 public: |
68 HeapDumper(bool gc_before_heap_dump) : |
66 HeapDumper(bool gc_before_heap_dump) : |
69 _error(NULL), _print_to_tty(false), _gc_before_heap_dump(gc_before_heap_dump), _oome(false) { } |
67 _error(NULL), _gc_before_heap_dump(gc_before_heap_dump), _oome(false) { } |
70 |
68 |
71 ~HeapDumper(); |
69 ~HeapDumper(); |
72 |
70 |
73 // dumps the heap to the specified file, returns 0 if success. |
71 // dumps the heap to the specified file, returns 0 if success. |
74 int dump(const char* path); |
72 // additional info is written to out if not NULL. |
|
73 int dump(const char* path, outputStream* out = NULL); |
75 |
74 |
76 // returns error message (resource allocated), or NULL if no error |
75 // returns error message (resource allocated), or NULL if no error |
77 char* error_as_C_string() const; |
76 char* error_as_C_string() const; |
78 |
77 |
79 static void dump_heap() NOT_SERVICES_RETURN; |
78 static void dump_heap() NOT_SERVICES_RETURN; |