Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-04-25 22:05:48 -0400
committerEugene Tarassov2012-04-25 22:05:48 -0400
commitf8653bc1f0e99bd75cfe04cbf7dba430b03bcf44 (patch)
tree848079b967e3f8390de487872256d701f66c14de
parent9c150472d2d76cc8a98009e6ca7e004dbea77a8e (diff)
downloadorg.eclipse.tcf.agent-f8653bc1f0e99bd75cfe04cbf7dba430b03bcf44.tar.gz
org.eclipse.tcf.agent-f8653bc1f0e99bd75cfe04cbf7dba430b03bcf44.tar.xz
org.eclipse.tcf.agent-f8653bc1f0e99bd75cfe04cbf7dba430b03bcf44.zip
TCF Agent: better handling of malformed line numbers information
-rw-r--r--agent/tcf/services/dwarfcache.c3
-rw-r--r--agent/tcf/services/dwarfcache.h1
-rw-r--r--agent/tcf/services/linenumbers_elf.c10
-rw-r--r--agent/tcf/services/vm.c3
-rw-r--r--tests/test-dwarf/tcf/backend/backend.c2
5 files changed, 12 insertions, 7 deletions
diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c
index 397456f3..11bbe544 100644
--- a/agent/tcf/services/dwarfcache.c
+++ b/agent/tcf/services/dwarfcache.c
@@ -768,6 +768,8 @@ static int addr_ranges_comparator(const void * x, const void * y) {
UnitAddressRange * ry = (UnitAddressRange *)y;
if (rx->mAddr < ry->mAddr) return -1;
if (rx->mAddr > ry->mAddr) return +1;
+ if (rx->mUnit->mObject->mID < ry->mUnit->mObject->mID) return -1;
+ if (rx->mUnit->mObject->mID > ry->mUnit->mObject->mID) return +1;
return 0;
}
@@ -1603,6 +1605,7 @@ static void compute_reverse_lookup_indices(DWARFCache * Cache, CompUnit * Unit)
Unit->mStatesIndex[i] = s1;
}
qsort(Unit->mStatesIndex, Unit->mStatesCnt, sizeof(LineNumbersState *), state_text_pos_comparator);
+ for (i = 0; i < Unit->mStatesCnt; i++) Unit->mStatesIndex[i]->mStatesIndexPos = i;
if (Cache->mFileInfoHash == NULL) {
Cache->mFileInfoHashSize = 251;
Cache->mFileInfoHash = (FileInfo **)loc_alloc_zero(sizeof(FileInfo *) * Cache->mFileInfoHashSize);
diff --git a/agent/tcf/services/dwarfcache.h b/agent/tcf/services/dwarfcache.h
index 17c0acde..33739015 100644
--- a/agent/tcf/services/dwarfcache.h
+++ b/agent/tcf/services/dwarfcache.h
@@ -164,6 +164,7 @@ struct PropertyValue {
struct LineNumbersState {
ContextAddress mAddress;
char * mFileName;
+ U4_T mStatesIndexPos;
U4_T mFile;
U4_T mLine;
U2_T mColumn;
diff --git a/agent/tcf/services/linenumbers_elf.c b/agent/tcf/services/linenumbers_elf.c
index e69042a8..505436c5 100644
--- a/agent/tcf/services/linenumbers_elf.c
+++ b/agent/tcf/services/linenumbers_elf.c
@@ -98,9 +98,9 @@ static int compare_path(Channel * chnl, Context * ctx, const char * file, const
return 0;
}
-static LineNumbersState * get_next_in_text(CompUnit * unit, unsigned index) {
- LineNumbersState * state = unit->mStatesIndex[index++];
+static LineNumbersState * get_next_in_text(CompUnit * unit, LineNumbersState * state) {
LineNumbersState * next = NULL;
+ U4_T index = state->mStatesIndexPos + 1;
if (index >= unit->mStatesCnt) return NULL;
next = unit->mStatesIndex[index++];
while (next->mLine == state->mLine && next->mColumn == state->mColumn) {
@@ -187,7 +187,7 @@ static void unit_line_to_address(Context * ctx, CompUnit * unit, unsigned file,
h = k;
}
else {
- LineNumbersState * next = get_next_in_text(unit, k);
+ LineNumbersState * next = get_next_in_text(unit, state);
U4_T next_line = next ? next->mLine : state->mLine + 1;
U4_T next_column = next ? next->mColumn : 0;
if (next_line < line || (next_line == line && next_column <= column)) {
@@ -208,7 +208,7 @@ static void unit_line_to_address(Context * ctx, CompUnit * unit, unsigned file,
if (errno == 0) {
LineNumbersState * code_next = get_next_in_code(unit, state);
if (code_next != NULL) {
- LineNumbersState * text_next = get_next_in_text(unit, k);
+ LineNumbersState * text_next = get_next_in_text(unit, state);
U4_T next_line = text_next ? text_next->mLine : state->mLine + 1;
U4_T next_column = text_next ? text_next->mColumn : 0;
if (next_line > line || (next_line == line && next_column > column)) {
@@ -329,7 +329,7 @@ int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1, L
for (;;) {
LineNumbersState * code_next = get_next_in_code(unit, state);
if (code_next != NULL) {
- LineNumbersState * text_next = get_next_in_text(unit, k);
+ LineNumbersState * text_next = get_next_in_text(unit, state);
call_client(unit, state, code_next, text_next, state->mAddress - range->mAddr + range_rt_addr, client, args);
}
if (++k >= unit->mStatesCnt) break;
diff --git a/agent/tcf/services/vm.c b/agent/tcf/services/vm.c
index b7919503..fefabcae 100644
--- a/agent/tcf/services/vm.c
+++ b/agent/tcf/services/vm.c
@@ -182,7 +182,8 @@ static int is_end_of_loc_expr(void) {
return
code_pos >= code_len ||
code[code_pos] == OP_piece ||
- code[code_pos] == OP_bit_piece;
+ code[code_pos] == OP_bit_piece ||
+ code[code_pos] == OP_TCF_offset;
}
static void evaluate_expression(void) {
diff --git a/tests/test-dwarf/tcf/backend/backend.c b/tests/test-dwarf/tcf/backend/backend.c
index 815cab47..1f4e264f 100644
--- a/tests/test-dwarf/tcf/backend/backend.c
+++ b/tests/test-dwarf/tcf/backend/backend.c
@@ -1053,7 +1053,7 @@ static void next_pc(void) {
error("address_to_line");
}
next_pc = area.end_address;
- if (next_pc > 0) next_pc += test_cnt % 6;
+ if (next_pc >= pc) next_pc += test_cnt % 6;
else next_pc = pc + 8;
if (area.start_line > 0) {
char * elf_file_name = tmp_strdup(area.file);

Back to the top