< prev index next >

src/hotspot/share/utilities/nativeStackPrinter.cpp

Print this page

28 #include "utilities/globalDefinitions.hpp"
29 #include "utilities/nativeStackPrinter.hpp"
30 #include "utilities/ostream.hpp"
31 
32 bool NativeStackPrinter::print_stack(outputStream* st, char* buf, int buf_size,
33                                      address& lastpc, bool print_source_info,
34                                      int max_frames) {
35   if (os::platform_print_native_stack(st, _context, buf, buf_size, lastpc)) {
36     return true;
37   } else {
38     print_stack_from_frame(st, buf, buf_size, print_source_info, max_frames);
39     return false;
40   }
41 }
42 
43 void NativeStackPrinter::print_stack_from_frame(outputStream* st, frame fr,
44                                                 char* buf, int buf_size,
45                                                 bool print_source_info, int max_frames) {
46   // see if it's a valid frame
47   if (fr.pc()) {
48     st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
49     const int limit = max_frames == -1 ? StackPrintLimit
50                                        : MIN2(max_frames, StackPrintLimit);
51     int count = 0;
52     while (count++ < limit) {
53       fr.print_on_error(st, buf, buf_size);
54       if (fr.pc()) { // print source file and line, if available
55         char filename[128];
56         int line_no;
57         if (count == 1 && _lineno != 0) {
58           // We have source information for the first frame for internal errors,
59           // there is no need to parse it from the symbols.
60           st->print("  (%s:%d)", _filename, _lineno);
61         } else if (print_source_info &&
62                    Decoder::get_source_info(fr.pc(), filename, sizeof(filename), &line_no, count != 1)) {
63           st->print("  (%s:%d)", filename, line_no);
64         }
65       }
66       st->cr();
67       fr = frame::next_frame(fr, _current);
68       if (fr.pc() == nullptr) {

28 #include "utilities/globalDefinitions.hpp"
29 #include "utilities/nativeStackPrinter.hpp"
30 #include "utilities/ostream.hpp"
31 
32 bool NativeStackPrinter::print_stack(outputStream* st, char* buf, int buf_size,
33                                      address& lastpc, bool print_source_info,
34                                      int max_frames) {
35   if (os::platform_print_native_stack(st, _context, buf, buf_size, lastpc)) {
36     return true;
37   } else {
38     print_stack_from_frame(st, buf, buf_size, print_source_info, max_frames);
39     return false;
40   }
41 }
42 
43 void NativeStackPrinter::print_stack_from_frame(outputStream* st, frame fr,
44                                                 char* buf, int buf_size,
45                                                 bool print_source_info, int max_frames) {
46   // see if it's a valid frame
47   if (fr.pc()) {
48     st->print_cr("Native frames: (J=compiled Java code, A=AOT compiled, P=AOT preloaded, j=interpreted, Vv=VM code, C=native code)");
49     const int limit = max_frames == -1 ? StackPrintLimit
50                                        : MIN2(max_frames, StackPrintLimit);
51     int count = 0;
52     while (count++ < limit) {
53       fr.print_on_error(st, buf, buf_size);
54       if (fr.pc()) { // print source file and line, if available
55         char filename[128];
56         int line_no;
57         if (count == 1 && _lineno != 0) {
58           // We have source information for the first frame for internal errors,
59           // there is no need to parse it from the symbols.
60           st->print("  (%s:%d)", _filename, _lineno);
61         } else if (print_source_info &&
62                    Decoder::get_source_info(fr.pc(), filename, sizeof(filename), &line_no, count != 1)) {
63           st->print("  (%s:%d)", filename, line_no);
64         }
65       }
66       st->cr();
67       fr = frame::next_frame(fr, _current);
68       if (fr.pc() == nullptr) {
< prev index next >