diff --git a/FindMissingLineNo.py b/FindMissingLineNo.py new file mode 100755 index 000000000..c92b5ed41 --- /dev/null +++ b/FindMissingLineNo.py @@ -0,0 +1,74 @@ +#!/usr/bin/python + +import os +import sys + +DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".dbg.ml" +OPT_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".dbg.opt.ml" +NATIVE_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".native.dbg.ml" +NATIVE_OPT_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".native.dbg.opt.ml" +XFAIL_FILE=sys.argv[2] + "/lineinfo.xfail" + +REPORT_FILE="Output/" + sys.argv[1] + ".dbg.missing_lines.report.txt" + +def read_inputfile(filename, dict): + f = open(filename, "r") + lines = f.readlines() + for l in range(len(lines)): + columns = lines[l].split() + s = dict.get(columns[0]) + if s is None: + s = set() + s.add(columns[1]) + dict[columns[0]] = s + f.close() + return + +dbg_lines = {} +read_inputfile(DBG_OUTPUT_FILE, dbg_lines) + +dbg_opt_lines = {} +read_inputfile(OPT_DBG_OUTPUT_FILE, dbg_opt_lines) + +native_dbg_lines = {} +read_inputfile(NATIVE_DBG_OUTPUT_FILE, native_dbg_lines) + +native_dbg_opt_lines = {} +read_inputfile(NATIVE_OPT_DBG_OUTPUT_FILE, native_dbg_opt_lines) + +xfailed_lines = {} +read_inputfile(XFAIL_FILE, xfailed_lines) + +dbg_line_items = dbg_lines.items() +for f in range(len(dbg_line_items)): + fname = dbg_line_items[f][0] + fset = dbg_line_items[f][1] + optset = dbg_opt_lines.get(fname) + nativeoptset = native_dbg_opt_lines.get(fname) + xfailedset = xfailed_lines.get(os.path.basename(fname)) + if optset is not None: + src = open(fname, "r") + srclines = src.readlines() + src_output = open("Output/" + sys.argv[1] + ".lineinfo", "w") + for l in range(len(srclines)): + l1 = l + 1 + l1s = str(l1) + if l1s in fset: + if l1s in optset: + if nativeoptset is not None and l1s in nativeoptset: + src_output.write(".|") + else: + src_output.write("+|") + else: + if nativeoptset is not None and l1s in nativeoptset: + if xfailedset is not None and l1s in xfailedset: + src_output.write(" |") + else: + src_output.write("x|") + else: + src_output.write("-|") + else: + src_output.write(" |") + src_output.write(srclines[l]) + src.close() + src_output.close() diff --git a/PrintLineNo.sh b/PrintLineNo.sh new file mode 100755 index 000000000..c7ba2ce57 --- /dev/null +++ b/PrintLineNo.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +dwarfdump Output/$1.dbg.dSYM/ -e --debug-line | grep "^0x" | awk '{if ($3) prev=$3; print basename prev," ",$2}' |sort |uniq > Output/$1.dbg.ml; +dwarfdump Output/$1.dbg.opt.dSYM/ -e --debug-line | grep "^0x" | awk '{if ($3) prev=$3; print basename prev," ",$2}' |sort |uniq > Output/$1.dbg.opt.ml; +dwarfdump Output/$1.native.dbg.dSYM/ -e --debug-line | grep "^0x" | awk '{if ($3) prev=$3; print basename prev," ",$2}' |sort |uniq > Output/$1.native.dbg.ml; +dwarfdump Output/$1.native.dbg.opt.dSYM/ -e --debug-line | grep "^0x" | awk '{if ($3) prev=$3; print basename prev," ",$2}' |sort |uniq > Output/$1.native.dbg.opt.ml; diff --git a/TEST.lineinfo.Makefile b/TEST.lineinfo.Makefile new file mode 100644 index 000000000..6138ec83e --- /dev/null +++ b/TEST.lineinfo.Makefile @@ -0,0 +1,65 @@ +##===- TEST.lineinfo.Makefile -----------------------------*- Makefile -*--===## +# +# This test is used to measure quality of debugging information. +# +##===----------------------------------------------------------------------===## + +CURDIR := $(shell cd .; pwd) +PROGDIR := $(PROJ_SRC_ROOT) +RELDIR := $(subst $(PROGDIR),,$(CURDIR)) +COLLECTOR := $(PROJ_SRC_ROOT)/CollectDebugInfoUsingLLDB.py + +REPORTS_TO_GEN := dbg +REPORTS_SUFFIX := $(addsuffix .report.txt, $(REPORTS_TO_GEN)) + +Output/%.bp: %.c Output/.dir + $(LCC) $(CPPFLAGS) $(CFLAGS) -g -c -emit-llvm $< -o $@.bc + $(LOPT) -print-breakpoints-for-testing $@.bc -o $@ + +Output/%.bp: %.cpp Output/.dir + $(LCXX) $(CPPFLAGS) $(CFLAGS) -g -c -emit-llvm $< -o $@.bc + $(LOPT) -print-breakpoints-for-testing $@.bc -o $@ + +Output/%.bp: %.m Output/.dir + $(LCC) $(CPPFLAGS) $(CFLAGS) -g -c -emit-llvm $< -o $@.bc + $(LOPT) -print-breakpoints-for-testing $@.bc -o $@ + +Output/%.bp: %.mm Output/.dir + $(LCXX) $(CPPFLAGS) $(CFLAGS) -g -c -emit-llvm $< -o $@.bc + $(LOPT) -print-breakpoints-for-testing $@.bc -o $@ + +$(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ +test.$(TEST).%: Output/%.bp Output/%.dbg Output/%.dbg.opt Output/%.native.dbg Output/%.native.dbg.opt + @-is_skip=0; \ + if test "$*" == "reversefile"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "spellcheck"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "sumcol"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "wc"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "wordfreq"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "exptree"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "ray"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "oscar"; then \ + is_skip=1; \ + fi; \ + if test "$*" == "spirit"; then \ + is_skip=1; \ + fi; \ + if test $$is_skip == 0; then \ + $(PROJ_SRC_ROOT)/PrintLineNo.sh $*; \ + $(PROJ_SRC_ROOT)/FindMissingLineNo.py $* $(PROJ_SRC_ROOT);\ + fi + diff --git a/lineinfo.xfail b/lineinfo.xfail new file mode 100644 index 000000000..79e27caba --- /dev/null +++ b/lineinfo.xfail @@ -0,0 +1 @@ +sse.shift.c 9 \ No newline at end of file