From 59ecb24ca29f5e80cf36ec5e216113241cb39480 Mon Sep 17 00:00:00 2001 From: Doug Moore Date: Thu, 27 Apr 2017 17:39:37 -0500 Subject: [PATCH] dwarf:Drop dwarf_create_state_record. In dwarf_make_proc_info, fix a leak in the case that create_state_record fails. --- include/dwarf.h | 3 --- src/dwarf/Gparser.c | 25 +++++++++---------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/include/dwarf.h b/include/dwarf.h index e29b8400..bb99f01e 100644 --- a/include/dwarf.h +++ b/include/dwarf.h @@ -398,7 +398,6 @@ struct dwarf_callback_data #define dwarf_extract_proc_info_from_fde \ UNW_OBJ (dwarf_extract_proc_info_from_fde) #define dwarf_find_save_locs UNW_OBJ (dwarf_find_save_locs) -#define dwarf_create_state_record UNW_OBJ (dwarf_create_state_record) #define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info) #define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer) #define dwarf_step UNW_OBJ (dwarf_step) @@ -441,8 +440,6 @@ extern int dwarf_extract_proc_info_from_fde (unw_addr_space_t as, int is_debug_frame, void *arg); extern int dwarf_find_save_locs (struct dwarf_cursor *c); -extern int dwarf_create_state_record (struct dwarf_cursor *c, - dwarf_state_record_t *sr); extern int dwarf_make_proc_info (struct dwarf_cursor *c); extern int dwarf_read_encoded_pointer (unw_addr_space_t as, unw_accessors_t *a, diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index cc5ed3df..1052863c 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -925,14 +925,6 @@ dwarf_find_save_locs (struct dwarf_cursor *c) return 0; } -/* The proc-info must be valid for IP before this routine can be - called. */ -HIDDEN int -dwarf_create_state_record (struct dwarf_cursor *c, dwarf_state_record_t *sr) -{ - return create_state_record_for (c, sr, c->ip); -} - HIDDEN int dwarf_make_proc_info (struct dwarf_cursor *c) { @@ -940,18 +932,19 @@ dwarf_make_proc_info (struct dwarf_cursor *c) if (c->as->caching_policy == UNW_CACHE_NONE || get_cached_proc_info (c) < 0) #endif + /* Need to check if current frame contains + args_size, and set cursor appropriately. Only + needed for unw_resume */ dwarf_state_record_t sr; int ret; - + /* Lookup it up the slow way... */ - if ((ret = fetch_proc_info (c, c->ip, 0)) < 0) - return ret; - /* Also need to check if current frame contains - args_size, and set cursor appropriatly. Only - needed for unw_resume */ - if ((ret = dwarf_create_state_record (c, &sr)) < 0) - return ret; + ret = fetch_proc_info (c, c->ip, 0); + if (ret >= 0) + ret = create_state_record_for (c, &sr, c->ip); put_unwind_info (c, &c->pi); + if (ret < 0) + return ret; c->args_size = sr.args_size; return 0;