diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2024-04-29 12:02:25 -0700 |
---|---|---|
committer | Indu Bhagat <indu.bhagat@oracle.com> | 2024-04-30 15:09:37 -0700 |
commit | 2d466a50ef1280a3949151a229257e89c10fa9dc (patch) | |
tree | 2fdb480ac0eba5ca5afab0fc49468e80c2e340be | |
parent | dc5f8e1ba264da98f13c881db564da205fcde6f5 (diff) | |
download | gdb-2d466a50ef1280a3949151a229257e89c10fa9dc.zip gdb-2d466a50ef1280a3949151a229257e89c10fa9dc.tar.gz gdb-2d466a50ef1280a3949151a229257e89c10fa9dc.tar.bz2 |
testsuite: libsframest: define a new function sframest_sfinfo_addr_range_p
Use this function consistently and remove unnecessary API
sframest_update_sfinfo.
ChangeLog:
* sframe-stacktrace.c
* sframe-state.c
* sframe-state.h
3 files changed, 23 insertions, 38 deletions
diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c index 52ceb86..2893e17 100644 --- a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c @@ -166,9 +166,12 @@ sframe_unwind (struct sframest_ctx *sf, void **ra_lst, int *ra_size) /* Check if need to update the SFrame stack trace info for the return addr. */ - sfinfo = sframest_update_sfinfo (sf, sfinfo, return_addr); - if (!sfinfo || !sfinfo->dctx) - return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE); + if (!sframest_sfinfo_addr_range_p (sfinfo, return_addr)) + { + sfinfo = sframest_get_sfinfo (sf, pc); + if (!sfinfo || !sfinfo->dctx) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE); + } } else { diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c index 37ade6a..cabecc6 100644 --- a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c @@ -80,6 +80,19 @@ sframe_bt_set_errno (int *errp, int error) #endif +/* Return whether the given SFrame stack trace info object SFINFO has (stack + trace) information corresponding to addr. */ + +bool sframest_sfinfo_addr_range_p (struct sframest_info *sfinfo, + uint64_t addr) +{ + if (!sfinfo || !addr) + return false; + + return (sfinfo->text_vma <= addr + && sfinfo->text_vma + sfinfo->text_size > addr); +} + /* Add .sframe info in D_DATA, which is associated with a dynamic shared object, to D_LIST. */ @@ -159,16 +172,14 @@ sframe_find_context (struct sframest_ctx *sf, uint64_t addr) if (!sf) return NULL; - if (sf->prog_sfinfo.text_vma < addr - && sf->prog_sfinfo.text_vma + sf->prog_sfinfo.text_size > addr) + if (sframest_sfinfo_addr_range_p (&sf->prog_sfinfo, addr)) return &sf->prog_sfinfo; d_list = &sf->dsos_sfinfo; for (i = 0; i < sf->dsos_sfinfo.used; ++i) { sfinfo = d_list->entry[i]; - if ((sfinfo.text_vma <= addr) - && (sfinfo.text_vma + sfinfo.text_size >= addr)) + if (sframest_sfinfo_addr_range_p (&sfinfo, addr)) return &d_list->entry[i]; } @@ -199,34 +210,6 @@ sframest_get_sfinfo (struct sframest_ctx *sf, uint64_t raddr) return sfinfo; } -struct sframest_info * -sframest_update_sfinfo (struct sframest_ctx *sf, - struct sframest_info *cur_sfinfo, - uint64_t raddr) -{ - struct sframest_info *sfinfo = NULL; - int err = 0; - - if (!sf || !cur_sfinfo) - return NULL; - - /* Detect if current SFrame stack trace info object serves for raddr. */ - if (cur_sfinfo->text_vma < raddr - && cur_sfinfo->text_vma + cur_sfinfo->text_size > raddr) - return cur_sfinfo; - - sfinfo = sframe_find_context (sf, raddr); - if (!sfinfo) - return NULL; - - /* Decode the SFrame section the first time. */ - if (!sfinfo->dctx) - sfinfo->dctx = sframe_decode (sfinfo->buf, sfinfo->buflen, &err); - - return sfinfo; -} - - /* Open /proc image associated with the process id and return the file descriptor. */ diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h index 8bc4a86..e5c8dde 100644 --- a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h @@ -93,9 +93,8 @@ int sframe_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, void *data); -struct sframest_info *sframest_update_sfinfo (struct sframest_ctx *sf, - struct sframest_info *cur_sfinfo, - uint64_t raddr); +bool sframest_sfinfo_addr_range_p (struct sframest_info *sfinfo, + uint64_t addr); struct sframest_info *sframest_get_sfinfo (struct sframest_ctx *sf, uint64_t raddr); |