Make stacktrace parsing work when line number info is not available.

Reviewed By: sblackshear

Differential Revision: D3715702

fbshipit-source-id: cb52f9a
master
Lázaro Clapp Jiménez Labora 9 years ago committed by Facebook Github Bot 2
parent e81e43456b
commit 616e8fddd4

@ -60,10 +60,16 @@ let parse_stack_frame frame_str =
if string_equal file_and_line "Native Method" then if string_equal file_and_line "Native Method" then
make_frame class_str method_str "Native Method" (-1) make_frame class_str method_str "Native Method" (-1)
else begin else begin
(* separate the filename and line number *) (* Separate the filename and line number.
ignore(Str.string_match file_and_line_regexp file_and_line 0); note that a few methods might not have line number information,
let file_str = Str.matched_group 1 file_and_line in for those, file_and_line includes only the filename. *)
let line_num = int_of_string (Str.matched_group 2 file_and_line) in let is_file_line = Str.string_match file_and_line_regexp file_and_line 0 in
let file_str = if is_file_line
then Str.matched_group 1 file_and_line
else file_and_line in
let line_num = if is_file_line
then int_of_string (Str.matched_group 2 file_and_line)
else -1 in
make_frame class_str method_str file_str line_num make_frame class_str method_str file_str line_num
end end

@ -69,5 +69,23 @@ let tests =
assert_equal trace expected in assert_equal trace expected in
"multi_frame_trace_test">::multi_frame_trace_test_ in "multi_frame_trace_test">::multi_frame_trace_test_ in
let missing_line_info_test =
let missing_line_info_test_s =
"Exception in thread \"main\" java.lang.NullPointerException\n" ^
"\tat endtoend.java.checkers.crashcontext.MinimalCrashTest.main" ^
"(MinimalCrashTest.java)" in
let trace = Stacktrace.of_string missing_line_info_test_s in
let expected = Stacktrace.make
"java.lang.NullPointerException"
[Stacktrace.make_frame
"endtoend.java.checkers.crashcontext.MinimalCrashTest"
"main"
"MinimalCrashTest.java"
(-1)] in
let missing_line_info_test_ _ =
assert_equal trace expected in
"missing_line_info_test">::missing_line_info_test_ in
"all_tests_suite">:::[empty_string_test; empty_trace_test; "all_tests_suite">:::[empty_string_test; empty_trace_test;
one_frame_trace_test; multi_frame_trace_test] one_frame_trace_test; multi_frame_trace_test;
missing_line_info_test]

Loading…
Cancel
Save