From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25EA2385841B; Fri, 12 Nov 2021 21:06:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25EA2385841B From: "msebor at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/28589] New: cannot call a variadic C++ function Date: Fri, 12 Nov 2021 21:06:08 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor 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: Fri, 12 Nov 2021 21:06:09 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28589 Bug ID: 28589 Summary: cannot call a variadic C++ function Product: gdb Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ Assignee: unassigned at sourceware dot org Reporter: msebor at gmail dot com Target Milestone: --- I'm sure this must be a known bug, but it makes debugging GCC (and presumab= ly other C++ code that uses its own printf-style message formatting) hard. I'= ve found no way to call from within GDB a printf-like function defined in a C++ program except with no variable arguments. Below is a simple test case. It works fine in C but not in C++. GCC is a C++ code base that defines variad= ic functions to print messages. It's often convenient to display this or that piece of internal data the way it would be presented to the user when forma= tted by one of these functions. But in GDB 11.1 it still doesn't appear to be possible. $ gcc -g -xc++ z.C && gdb -batch --silent -ex "break main" -ex "run" -ex st= ep -ex 'p print("x =3D %i\n", x)' a.out #include #include void printv (const char *f, va_list va) { int x =3D va_arg (va, int); printf (f, x); } void print (const char *f, ...) { va_list va; va_start (va, f); printv (f, va); va_end (va); } int main () { int x =3D 123; print ("x =3D %i\n", x); } gdb: warning: Couldn't determine a path for the index cache directory. warning: File "/ssd/build/tmp/.gdbinit" auto-loading has been declined by y= our `auto-load safe-path' set to "$debugdir:$datadir/auto-load". To enable execution of this file add add-auto-load-safe-path /ssd/build/tmp/.gdbinit line to your configuration file "$HOME/.gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "$HOME/.gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the she= ll: info "(gdb)Auto-loading safe path" Breakpoint 1 at 0x401241: file z.C, line 21. Breakpoint 1, main () at z.C:21 21 int x =3D 123; 22 print ("x =3D %i\n", x); Cannot resolve function print to any overloaded instance --=20 You are receiving this mail because: You are on the CC list for the bug.=