From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 82B1C3851C19; Wed, 13 May 2020 14:16:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82B1C3851C19 From: "brenorg at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/25987] New: Wrong line for code containing inlined functions Date: Wed, 13 May 2020 14:16:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: c++ X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: brenorg at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 14:16:46 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25987 Bug ID: 25987 Summary: Wrong line for code containing inlined functions Product: gdb Version: HEAD Status: UNCONFIRMED Severity: critical Priority: P2 Component: c++ Assignee: unassigned at sourceware dot org Reporter: brenorg at gmail dot com Target Milestone: --- TLDR: GDB is showing the wrong line information for a function call in a line with inlined functions. Like this: ``` some_unique_ptr->fn(); ``` In the backtrace, GDB shows "unique_ptr::operator->" as line information for the call to "fn". The long version:=20 For the following code: ``` struct MyClass; struct ptr { MyClass* get() { return t; } MyClass* t; }; struct MyClass { void call(); }; void MyClass::call() { *(char*)(nullptr) =3D 1; } static void intermediate(ptr p) { p.get()->call(); } int main() { intermediate(ptr{new MyClass}); } ``` Compiled with GCC 8 or above with these flags: ``` g++ -Og -g -o main main.cpp ``` The function "call" will crash and the backtrace using GDB HEAD looks like this: ``` #0 MyClass::call (this=3D0x416c20) at main.cpp:8 #1 0x0000000000401140 in intermediate (p=3D...) at main.cpp:3 #2 0x0000000000401157 in main () at main.cpp:14 ``` Notice that the "intermediate" frame is pointing to main.cpp:3 which is the call to "get". I would expect it to show main.cpp:11 I tested GDB 8 and it shows the correct information but that seems by chanc= e. If I move the "ptr" definition to a header, then it also fails with GDB 8 (= but works with GDB head). Looking at the decoded line information, it seems that there is no way for = GDB to tell which is the correct call: ``` $ objdump -D main | grep callq.*intermediate 401152: e8 e4 ff ff ff callq 40113b <_ZL12intermediate3ptr $ objdump --dwarf=3Ddecodedline main | grep 40113b main.cpp 10 0x40113b x main.cpp 11 0x40113b 1 x main.cpp 3 0x40113b 2 x main.cpp 3 0x40113b 3 x main.cpp 3 0x40113b 4 main.cpp 11 0x40113b 5 ``` There seems to be multiple line information for the same "callq" instructio= n. So I'm not sure how GDB would tell the difference. Maybe from the dwarf information it should be able to figure out which of those lines refer to inlined functions ? --=20 You are receiving this mail because: You are on the CC list for the bug.=