1 #include <jvmti.h>
2 #include <stdio.h>
3 
4 #include <string>
5 
6 #include "globals.h"
7 #include "profiler.h"
8 
9 #ifndef DISPLAY_H
10 #define DISPLAY_H
11 
12 // Some platforms have a ::string class that is different from ::std::string
13 // (although the interface is the same, of course).  On other platforms,
14 // ::string is the same as ::std::string.
15 #ifndef HAS_GLOBAL_STRING
16 using std::string;
17 #endif
18 
19 class StackTracesPrinter {
20  public:
StackTracesPrinter(FILE * file,jvmtiEnv * jvmti)21   StackTracesPrinter(FILE *file, jvmtiEnv *jvmti)
22       : file_(file), jvmti_(jvmti) {}
23 
24   void PrintStackTraces(TraceData *traces, int length);
25 
26   void PrintLeafHistogram(TraceData *traces, int length);
27 
28  private:
29   FILE *file_;
30 
31   jvmtiEnv *jvmti_;
32 
33   bool PrintStackFrame(JVMPI_CallFrame *frame);
34 
35   void PrintStackTrace(TraceData *trace);
36 
37   bool GetStackFrameElements(JVMPI_CallFrame *frame, string *method_name,
38                              string *class_name, string *file_name,
39                              int *line_number);
40 
41   jint GetLineNumber(jmethodID method, jlocation location);
42 
43   DISALLOW_COPY_AND_ASSIGN(StackTracesPrinter);
44 };
45 
46 #endif  // DISPLAY_H
47