public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/13] No-debug-info debugging improvements
@ 2017-07-13 15:32 Pedro Alves
  2017-07-13 15:32 ` [PATCH v2 11/13] Handle "p 'S::method()::static_var'" (quoted) in symbol lookup Pedro Alves
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Pedro Alves @ 2017-07-13 15:32 UTC (permalink / raw)
  To: gdb-patches

New in v2:
  - The new simpler cast-return-type syntax now assumes the called
    function is prototyped instead of unprototyped:
     https://sourceware.org/ml/gdb-patches/2017-07/msg00128.html
  - Documentation patch adjusted accordingly.
  - The fix for calling prototyped functions via function pointers is
    now patch #1, because the v2 of patch #2 includes new tests that
    depend on the fix.


This series stops GDB from assuming that no-debug-info functions
return int, and that no-debug-info variables have type int.

E.g. instead of this, if you have no debug info for glibc:

  (gdb) p getenv("PATH")
  $1 = -6185

You'll get:

  (gdb) p getenv ("PATH")
  'getenv' has unknown return type; cast the call to its declared return type
  (gdb) p (char *) getenv ("PATH")                      # now Just Works
  $1 = 0x7fffffffe7d7 "/usr/local/bin:/"...
  (gdb) p ((char *(*) (const char *)) getenv) ("PATH")  # continues working
  $1 = 0x7fffffffe7d7 "/usr/local/bin:/"...

And similarly for variables.

While implementing and writing tests for the above, I ran into a few
other problems (as usual...), and fixed them too.  Most of the
problems were related to printing static local variables, with the
documented "p klass::method()::static_var" syntax.

One other problem I ran into today while writing the documentation
patch...  I wanted to document when to call a no-debug-info function
by casting it to the right function pointer type, and calling that
pointer, and noticed that that doesn't actually work correctly...  GDB
always leaves the target function type of the function pointer type as
an unprototyped function, meaning that it applies argument coercion
incorrectly.  W00t!

See many more details and rationale on the description of each patch.
Documentation is in the last patch.

Tested on x86-64 GNU/Linux, native and gdbserver, both with and
without glibc debug info.  Adds over 3700 new passes:

  -# of expected passes           39661
  +# of expected passes           43405

I see this series as follow up to the recent "whatis" fixes for Zack's
errno pretty printer:

  https://sourceware.org/ml/gdb-patches/2017-06/msg00827.html
  https://sourceware.org/ml/gdb-patches/2017-07/msg00018.html

so I put this series on top of those patches in the same branch:

  users/palves/whatis

Pedro Alves (13):
  Fix calling prototyped functions via function pointers
  Stop assuming no-debug-info functions return int
  Introduce OP_VAR_MSYM_VALUE
  Make ptype/whatis print function name of functions with no debug info
    too
  evaluate_subexp_standard: Eliminate one goto
  evaluate_subexp_standard: Remove useless assignments
  evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.
  Stop assuming no-debug-info variables have type int
  Eliminate UNOP_MEMVAL_TLS
  Handle "p S::method()::static_var" in the C++ parser
  Handle "p 'S::method()::static_var'" (quoted) in symbol lookup
  Make "p S::method() const::static_var" work too
  Document "no debug info debugging" improvements

 gdb/doc/gdb.texinfo                                | 114 +++++-
 gdb/NEWS                                           |  26 ++
 gdb/ada-lang.c                                     |  11 +-
 gdb/ada-typeprint.c                                |   7 +-
 gdb/ax-gdb.c                                       |  72 +++-
 gdb/c-exp.y                                        |  51 ++-
 gdb/c-typeprint.c                                  |  10 +-
 gdb/compile/compile-c-symbols.c                    |   4 +-
 gdb/compile/compile-c-types.c                      |  35 +-
 gdb/compile/compile-object-run.c                   |   3 +-
 gdb/cp-namespace.c                                 |  50 +--
 gdb/dwarf2read.c                                   |  46 ++-
 gdb/elfread.c                                      |   2 +-
 gdb/eval.c                                         | 439 ++++++++++++++-------
 gdb/expprint.c                                     |  92 +++--
 gdb/expression.h                                   |   1 +
 gdb/f-typeprint.c                                  |   7 +-
 gdb/gcore.c                                        |   2 +-
 gdb/gdbtypes.c                                     |  27 +-
 gdb/gdbtypes.h                                     |  15 +-
 gdb/guile/scm-value.c                              |   2 +-
 gdb/infcall.c                                      |  49 ++-
 gdb/infcall.h                                      |  19 +-
 gdb/linux-fork.c                                   |   6 +-
 gdb/linux-tdep.c                                   |   4 +-
 gdb/m2-typeprint.c                                 |  11 +-
 gdb/minsyms.h                                      |   9 +
 gdb/objc-lang.c                                    |  14 +-
 gdb/p-typeprint.c                                  |  57 +--
 gdb/parse.c                                        | 130 +++---
 gdb/parser-defs.h                                  |   2 +
 gdb/python/py-value.c                              |   3 +-
 gdb/rust-lang.c                                    |   2 +-
 gdb/std-operator.def                               |  43 +-
 gdb/testsuite/gdb.asm/asm-source.exp               |   8 +-
 .../gdb.base/break-main-file-remove-fail.exp       |   2 +-
 gdb/testsuite/gdb.base/break-probes.exp            |   2 +-
 gdb/testsuite/gdb.base/callfuncs.exp               |  26 +-
 gdb/testsuite/gdb.base/checkpoint.exp              |  44 +--
 gdb/testsuite/gdb.base/dprintf-detach.exp          |   2 +-
 gdb/testsuite/gdb.base/infcall-exec.exp            |   2 +-
 gdb/testsuite/gdb.base/info-os.exp                 |   8 +-
 gdb/testsuite/gdb.base/nodebug.c                   |  48 +++
 gdb/testsuite/gdb.base/nodebug.exp                 | 194 +++++++--
 gdb/testsuite/gdb.base/solib-display.exp           |  16 +-
 gdb/testsuite/gdb.compile/compile-ifunc.exp        |   5 +-
 gdb/testsuite/gdb.compile/compile.exp              |  10 +-
 gdb/testsuite/gdb.cp/local-static.c                | 170 ++++++++
 gdb/testsuite/gdb.cp/local-static.cc               |   1 +
 gdb/testsuite/gdb.cp/local-static.exp              | 241 +++++++++++
 gdb/testsuite/gdb.cp/m-static.exp                  |   5 -
 gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp     |   2 +-
 gdb/testsuite/gdb.threads/siginfo-threads.exp      |   7 +-
 gdb/testsuite/gdb.threads/tls-nodebug.exp          |   5 +-
 gdb/testsuite/gdb.trace/entry-values.exp           |   6 +-
 gdb/typeprint.c                                    |  18 +-
 gdb/typeprint.h                                    |   9 +
 gdb/valarith.c                                     |   4 +-
 gdb/valops.c                                       |   7 +-
 59 files changed, 1753 insertions(+), 454 deletions(-)
 create mode 100644 gdb/testsuite/gdb.cp/local-static.c
 create mode 100644 gdb/testsuite/gdb.cp/local-static.cc
 create mode 100644 gdb/testsuite/gdb.cp/local-static.exp

-- 
2.5.5

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-12-08 16:28 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 15:32 [PATCH v2 00/13] No-debug-info debugging improvements Pedro Alves
2017-07-13 15:32 ` [PATCH v2 11/13] Handle "p 'S::method()::static_var'" (quoted) in symbol lookup Pedro Alves
2017-07-13 15:32 ` [PATCH v2 10/13] Handle "p S::method()::static_var" in the C++ parser Pedro Alves
2017-07-13 15:32 ` [PATCH v2 09/13] Eliminate UNOP_MEMVAL_TLS Pedro Alves
2017-07-13 15:32 ` [PATCH v2 03/13] Introduce OP_VAR_MSYM_VALUE Pedro Alves
2017-07-13 15:32 ` [PATCH v2 06/13] evaluate_subexp_standard: Remove useless assignments Pedro Alves
2017-07-13 15:32 ` [PATCH v2 02/13] Stop assuming no-debug-info functions return int Pedro Alves
2017-07-13 15:32 ` [PATCH v2 05/13] evaluate_subexp_standard: Eliminate one goto Pedro Alves
2017-07-13 15:32 ` [PATCH v2 01/13] Fix calling prototyped functions via function pointers Pedro Alves
2017-07-13 15:37 ` [PATCH v2 12/13] Make "p S::method() const::static_var" work too Pedro Alves
2017-07-13 15:38 ` [PATCH v2 13/13] Document "no debug info debugging" improvements Pedro Alves
2017-07-13 16:11   ` Eli Zaretskii
2017-07-13 16:31     ` Pedro Alves
2017-07-13 17:54       ` Eli Zaretskii
2017-07-13 15:38 ` [PATCH v2 07/13] evaluate_subexp_standard: Factor out OP_VAR_VALUE handling Pedro Alves
2017-07-13 15:38 ` [PATCH v2 08/13] Stop assuming no-debug-info variables have type int Pedro Alves
2017-12-07 23:30   ` [RFA] Adjust gdb.arch/i386-sse-stack-align.exp print statement Sergio Durigan Junior
2017-12-08 10:47     ` Pedro Alves
2017-12-08 16:28       ` Sergio Durigan Junior
2017-07-13 15:39 ` [PATCH v2 04/13] Make ptype/whatis print function name of functions with no debug info too Pedro Alves
2017-09-04 19:21 ` [PATCH v2 00/13] No-debug-info debugging improvements Pedro Alves

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).