From 5e59e93d049b9c6261c0db456edb7ab323618b6c Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Sun, 25 Mar 2012 18:33:40 -0700 Subject: [PATCH] dwarf: introduce a valid bit for dwarf_reg_state_t Without this, cache_match() returns true when (ip == 0). --- include/dwarf.h | 3 ++- src/dwarf/Gparser.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/dwarf.h b/include/dwarf.h index f2f8bf93..efcf18d5 100644 --- a/include/dwarf.h +++ b/include/dwarf.h @@ -251,7 +251,8 @@ typedef struct dwarf_reg_state unsigned short lru_chain; /* used for least-recently-used chain */ unsigned short coll_chain; /* used for hash collisions */ unsigned short hint; /* hint for next rs to try (or -1) */ - unsigned short signal_frame; /* optional machine-dependent signal info */ + unsigned short valid : 1; /* optional machine-dependent signal info */ + unsigned short signal_frame : 1; /* optional machine-dependent signal info */ } dwarf_reg_state_t; diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index e82df6b3..6793e19a 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -510,6 +510,7 @@ flush_rs_cache (struct dwarf_rs_cache *cache) cache->buckets[i].lru_chain = (i - 1); cache->buckets[i].coll_chain = -1; cache->buckets[i].ip = 0; + cache->buckets[i].valid = 0; } for (i = 0; ihash[i] = -1; @@ -562,7 +563,7 @@ hash (unw_word_t ip) static inline long cache_match (dwarf_reg_state_t *rs, unw_word_t ip) { - if (ip == rs->ip) + if (rs->valid && (ip == rs->ip)) return 1; return 0; } @@ -646,6 +647,7 @@ rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c) rs->hint = 0; rs->ip = c->ip; + rs->valid = 1; rs->ret_addr_column = c->ret_addr_column; rs->signal_frame = 0; tdep_cache_frame (c, rs);