public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "aditya24.garg at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31048] New: GDB commands very slow due to too many lseek calls
Date: Thu, 09 Nov 2023 12:47:07 +0000	[thread overview]
Message-ID: <bug-31048-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31048

            Bug ID: 31048
           Summary: GDB commands very slow due to too many lseek calls
           Product: gdb
           Version: 9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: aditya24.garg at gmail dot com
                CC: aditya24.garg at gmail dot com
  Target Milestone: ---

OS: Linux (Ubuntu 20.04.5)

Overview: I have a project consisting of multiple .so files. I have refactored
one of the .so files to a templatized version, therefore now i have quite a few
template classes and functions. Now on using GDB for debugging, commands like
print/ptype are running extremely slow in certain frames. Its taking over a
minute to just execute ptype <namespace::variable-name>

Actual Results: For local args and variables, GDB print/ptype works pretty fast
but with one of the static singleton variables, GDB print/ptype is taking 1
minute to execute. I tried using strace on gdb PID and saw that over 5000 LSEEK
calls for the same offset were being made repeatedly.

From comment on another old ticket
(https://sourceware.org/bugzilla/show_bug.cgi?id=17764#c5), I tried setting
demangle-style to none after which this problem disappeared. Everything became
superfast.

But debugging with mangled names is very inconvenient so i am exploring
solutions to fix this slowness while still using demangler.

Expected Results: Expectation was that GDB will return response within a few
seconds, instead its taking around a minute.

GDB Version: GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2

Environment: 
OS: Linux 5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64
x86_64 x86_64 GNU/Linux

GCC: Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

GDB: This GDB was configured as "x86_64-linux-gnu"


Strace Logs:
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
lseek(158, 4980736, SEEK_SET)           = 4980736
ptrace(PTRACE_PEEKTEXT, 865894, 0x7fffe0ccb260, [0x7fffe3a0c920]) = 0
rt_sigaction(SIGINT, {sa_handler=0x556e929a32e0, sa_mask=[INT],
sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fb93304d090},
{sa_handler=0x556e929a32e0, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, s>
brk(0x556ec2ea5000)                     = 0x556ec2ea5000
brk(0x556ec2ec6000)                     = 0x556ec2ec6000
brk(0x556ec2ee7000)                     = 0x556ec2ee7000
brk(0x556ec2f08000)                     = 0x556ec2f08000
brk(0x556ec2f29000)                     = 0x556ec2f29000
brk(0x556ec2f4a000)                     = 0x556ec2f4a000



Interesting fact: When i execute ptype <variable>. It takes 1 minute to run
when current frame selected (lets say frame 5) is from file1.so. And if i go to
frame 10 which belongs to file2.so, then same ptype command executes in 5
seconds. All the changes i have made are for file2.so and no change has been
made to file1.so implementation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-11-09 12:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09 12:47 aditya24.garg at gmail dot com [this message]
2023-11-09 13:19 ` [Bug gdb/31048] " aditya24.garg at gmail dot com
2023-11-10 15:09 ` aditya24.garg at gmail dot com
2023-11-10 18:29 ` simon.marchi at polymtl dot ca
2023-11-10 22:00 ` tromey at sourceware dot org
2023-11-10 23:05 ` sam at gentoo dot org
2023-11-12 14:25 ` ssbssa at sourceware dot org
2023-11-12 14:46 ` aditya24.garg at gmail dot com
2024-02-16  4:51 ` 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-31048-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: link
Be 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).