849 char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64);
850
851 // Print stack trace line in buffer
852 sprintf(buf, "\tat %s.%s", klass_name, method_name);
853 if (method->is_native()) {
854 strcat(buf, "(Native Method)");
855 } else {
856 int line_number = method->line_number_from_bci(bci);
857 if (source_file_name != NULL && (line_number != -1)) {
858 // Sourcename and linenumber
859 sprintf(buf + (int)strlen(buf), "(%s:%d)", source_file_name, line_number);
860 } else if (source_file_name != NULL) {
861 // Just sourcename
862 sprintf(buf + (int)strlen(buf), "(%s)", source_file_name);
863 } else {
864 // Neither soucename and linenumber
865 sprintf(buf + (int)strlen(buf), "(Unknown Source)");
866 }
867 nmethod* nm = method->code();
868 if (WizardMode && nm != NULL) {
869 sprintf(buf + (int)strlen(buf), "(nmethod %#x)", nm);
870 }
871 }
872
873 return buf;
874 }
875
876
877 void java_lang_Throwable::print_stack_element(Handle stream, methodOop method, int bci) {
878 ResourceMark rm;
879 char* buf = print_stack_element_to_buffer(method, bci);
880 print_to_stream(stream, buf);
881 }
882
883 void java_lang_Throwable::print_stack_element(outputStream *st, methodOop method, int bci) {
884 ResourceMark rm;
885 char* buf = print_stack_element_to_buffer(method, bci);
886 st->print_cr("%s", buf);
887 }
888
889 void java_lang_Throwable::print_to_stream(Handle stream, const char* str) {
|
849 char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64);
850
851 // Print stack trace line in buffer
852 sprintf(buf, "\tat %s.%s", klass_name, method_name);
853 if (method->is_native()) {
854 strcat(buf, "(Native Method)");
855 } else {
856 int line_number = method->line_number_from_bci(bci);
857 if (source_file_name != NULL && (line_number != -1)) {
858 // Sourcename and linenumber
859 sprintf(buf + (int)strlen(buf), "(%s:%d)", source_file_name, line_number);
860 } else if (source_file_name != NULL) {
861 // Just sourcename
862 sprintf(buf + (int)strlen(buf), "(%s)", source_file_name);
863 } else {
864 // Neither soucename and linenumber
865 sprintf(buf + (int)strlen(buf), "(Unknown Source)");
866 }
867 nmethod* nm = method->code();
868 if (WizardMode && nm != NULL) {
869 sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm);
870 }
871 }
872
873 return buf;
874 }
875
876
877 void java_lang_Throwable::print_stack_element(Handle stream, methodOop method, int bci) {
878 ResourceMark rm;
879 char* buf = print_stack_element_to_buffer(method, bci);
880 print_to_stream(stream, buf);
881 }
882
883 void java_lang_Throwable::print_stack_element(outputStream *st, methodOop method, int bci) {
884 ResourceMark rm;
885 char* buf = print_stack_element_to_buffer(method, bci);
886 st->print_cr("%s", buf);
887 }
888
889 void java_lang_Throwable::print_to_stream(Handle stream, const char* str) {
|