public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug c++/28935] New: GDB very slow stepping through LLVM compiled by Clang Date: Wed, 02 Mar 2022 18:25:20 +0000 [thread overview] Message-ID: <bug-28935-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=28935 Bug ID: 28935 Summary: GDB very slow stepping through LLVM compiled by Clang Product: gdb Version: 11.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ Assignee: unassigned at sourceware dot org Reporter: msebor at gmail dot com Target Milestone: --- Stepping through C++ code compiled by Clang takes much longer than when the code is compiled by GCC. For example, when debugging LLVM, each step takes a second or more. This is with the stock GDB (11.1-5.fc35) on x86_64 running Fedora 35. That makes using GDB for interactive work impractical. Using GCC instead of Clang to compile LLVM is a viable workaround but it's not without issues of its own. LLDB doesn't have the same problem as GDB but because it's not fully compatible with GDB it's not a great solution for those of us used to GDB. I'd like to try to help isolate and fix this problem. Below is a test case independent of LLVM that shows a small but measurable difference between these two scenarios. The output is the number of microseconds it takes the three 'next' GDB commands to step over the three C++ statements in A::f(), averaged over 100 runs. In GCC-compiled code the average is 5.2 microseconds, in Clang-compiled code it's 5.5 microseconds. If the difference grows with code size and/or complexity it could explain the much bigger 1 second delay in LLVM. If this test case isn't representative of the problem can you suggest what might be? $ (cat t.C && g++ -ggdb -o a.gcc.out t.C && (n=0; while [ $n -lt 100 ]; do gdb -batch -nx -ex "break A::f" -ex run -ex next -ex next -ex next -ex continue ./a.gcc.out >/dev/null; n=$((n+1)); done) 2>&1 | awk 'BEGIN { t = 0.0 } { t += $1 } END { print t / 100 }' ) #include <iostream> #include <string> #include <time.h> struct A { void f () const { std::string s = "Hello, "; s += "World!"; std::cout << s << std::endl; } }; A a; int main () { struct timespec t0, t1; clock_gettime (CLOCK_MONOTONIC, &t0); a.f (); clock_gettime (CLOCK_MONOTONIC, &t1); double t = (t1.tv_sec - t0.tv_sec) * 1e3 + (t1.tv_nsec - t0.tv_nsec) / 1e3; fprintf (stderr, "%f ms\n", t / 1e3); } 5.19838 $ (clang++ -ggdb -o a.clang.out t.C && (n=0; while [ $n -lt 100 ]; do gdb -batch -nx -ex "break A::f" -ex run -ex next -ex next -ex next -ex continue ./a.clang.out >/dev/null; n=$((n+1)); done) 2>&1 | awk 'BEGIN { n = 0.0 } { n += $1 } END { print n / 100 }' ) 5.52529 -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2022-03-02 18:25 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-02 18:25 msebor at gmail dot com [this message] 2022-03-02 20:54 ` [Bug c++/28935] " simark at simark dot ca 2022-03-02 22:41 ` msebor at gmail dot com 2022-03-03 2:28 ` simark at simark dot ca 2022-03-03 18:37 ` ssbssa at sourceware dot org 2022-05-16 13:33 ` tromey at sourceware dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-28935-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).