aboutsummaryrefslogtreecommitdiff
path: root/gdb/objc-lang.c
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2023-05-02 20:23:32 +0200
committerMark Wielaard <mark@klomp.org>2023-05-03 16:58:35 +0200
commit9b0ccb1ebaef7474d4f7242f778531ef042a55fc (patch)
tree4dd6c055de7493aea71715adb96e2003b2977dec /gdb/objc-lang.c
parent7e1b5887642d6c7c341c2db09ae912041d670a79 (diff)
downloadfsf-binutils-gdb-9b0ccb1ebaef7474d4f7242f778531ef042a55fc.zip
fsf-binutils-gdb-9b0ccb1ebaef7474d4f7242f778531ef042a55fc.tar.gz
fsf-binutils-gdb-9b0ccb1ebaef7474d4f7242f778531ef042a55fc.tar.bz2
Pass const frame_info_ptr reference for skip_[language_]trampoline
g++ 13.1.1 produces a -Werror=dangling-pointer= In file included from ../../binutils-gdb/gdb/frame.h:75, from ../../binutils-gdb/gdb/symtab.h:40, from ../../binutils-gdb/gdb/language.c:33: In member function ‘void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’, inlined from ‘void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’ at gdbsupport/intrusive_list.h:332:24, inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at gdb/frame.h:241:26, inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at gdb/language.c:530:49: gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=] 415 | m_back = &elem; | ~~~~~~~^~~~~~~ gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’: gdb/language.c:530:49: note: ‘<anonymous>’ declared here 530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here 359 | static intrusive_list<frame_info_ptr> frame_list; | ^~~~~~~~~~ Each new frame_info_ptr is being pushed on a static frame list and g++ cannot see why that is safe in case the frame_info_ptr is created and destroyed immediately when passed as value. It isn't clear why only in this one place g++ sees the issue (probably because it can inline enough code in this specific case). Since passing the frame_info_ptr as const reference is cheaper, use that as workaround for this warning. PR build/30413 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413 Tested-by: Kevin Buettner <kevinb@redhat.com> Reviewed-by: Kevin Buettner <kevinb@redhat.com> Reviewed-by: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/objc-lang.c')
-rw-r--r--gdb/objc-lang.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index ccbe7c1..6af25d9 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -282,7 +282,7 @@ public:
/* See language.h. */
- CORE_ADDR skip_trampoline (frame_info_ptr frame,
+ CORE_ADDR skip_trampoline (const frame_info_ptr &frame,
CORE_ADDR stop_pc) const override
{
struct gdbarch *gdbarch = get_frame_arch (frame);