summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Moore <dougm@rice.edu>2017-05-08 21:27:03 -0500
committerDoug Moore <dougm@rice.edu>2017-05-12 22:23:59 -0500
commit1602987b5f1044146bb5768ba81146cc7d7f04e9 (patch)
tree4d7c1a135926de73c4e74f59f9c8f4d052ef6df3
parent04db2b7ceabe425fa35100ca171ce41345768b62 (diff)
downloadlibunwind-1602987b5f1044146bb5768ba81146cc7d7f04e9.tar.gz
Extract 'find_reg_state' from dwarf_find_save_locs.
-rw-r--r--src/dwarf/Gparser.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
index 6a5eeb2c..fc294bb9 100644
--- a/src/dwarf/Gparser.c
+++ b/src/dwarf/Gparser.c
@@ -874,12 +874,10 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
return 0;
}
-/* The function finds the saved locations and applies the register
- state as well. */
-HIDDEN int
-dwarf_find_save_locs (struct dwarf_cursor *c)
+/* Find the saved locations. */
+static int
+find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr)
{
- dwarf_state_record_t sr;
dwarf_reg_state_t *rs;
struct dwarf_rs_cache *cache;
int ret = 0;
@@ -891,20 +889,20 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
/* update hint; no locking needed: single-word writes are atomic */
c->ret_addr_column = rs->ret_addr_column;
c->use_prev_instr = ! rs->signal_frame;
- memcpy (&sr.rs_current, rs, sizeof (*rs));
+ memcpy (&sr->rs_current, rs, sizeof (*rs));
}
else
{
ret = fetch_proc_info (c, c->ip, 1);
if (ret >= 0)
- ret = create_state_record_for (c, &sr, c->ip);
+ ret = create_state_record_for (c, sr, c->ip);
put_unwind_info (c, &c->pi);
if (cache && ret >= 0)
{
rs = rs_new (cache, c);
cache->links[rs - cache->buckets].hint = 0;
- memcpy(rs, &sr.rs_current, offsetof(struct dwarf_reg_state, ret_addr_column));
+ memcpy(rs, &sr->rs_current, offsetof(struct dwarf_reg_state, ret_addr_column));
}
}
@@ -923,6 +921,18 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
return ret;
if (cache)
tdep_reuse_frame (c, rs);
+ return 0;
+}
+
+/* The function finds the saved locations and applies the register
+ state as well. */
+HIDDEN int
+dwarf_find_save_locs (struct dwarf_cursor *c)
+{
+ int ret;
+ dwarf_state_record_t sr;
+ if ((ret = find_reg_state (c, &sr)) < 0)
+ return ret;
if ((ret = apply_reg_state (c, &sr.rs_current)) < 0)
return ret;