Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] Introduce gdb::function_view & fix completion bug
@ 2017-02-22 14:50 Pedro Alves
  2017-02-22 14:50 ` [PATCH 2/3] Use gdb::function_view in iterate_over_symtabs & co Pedro Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Pedro Alves @ 2017-02-22 14:50 UTC (permalink / raw)
  To: gdb-patches

I noticed that gdb.base/completion.exp fails when run with
--target_board=dwarf4-gdb-index.  In order to fix it, I wanted to use
a lambda with iterate_over_symtabs.  However, the C-style "function
pointer" + "data pointer" callback style we are still using doesn't
play well with lambdas with captures.

C++11 gave us std::function as type-erased wrapper around arbitrary
callables, however, as I explained at [1] in detail (with references),
std::function is not an ideal fit for transient callbacks.  A better
type for that is a non-owning version of std::function.  Using modern
C++17 terminology, the natural name for such an object is a "view",
thus "function_view".  There are several examples of such a thing in
the interwebs.  This series adds such a type to GDB.

This version is more complete than any other I've seen.  It supports
function pointers efficiently without hitting undefined behavior, it
supports comparison with NULL like std::function, and it supports
referencing callables that return non-void when the function_view is
expecting void, just like std::function too.  (Speaking of which, I've
looked at libstdc++'s std::function to compare APIs, and stolen a few
traits bits from there while at it).  Unit tests to cover the whole
API are included too.

[1] - https://sourceware.org/ml/gdb-patches/2017-02/msg00535.html

Regtested on x86_64 Fedora 23, and build tested with GCC 4.8.5 too.

Also pushed to the users/palves/function-view branch on sourceware.org.

Pedro Alves (3):
  Introduce gdb::function_view
  Use gdb::function_view in iterate_over_symtabs & co
  Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index

 gdb/Makefile.in                         |  24 ++-
 gdb/ada-lang.c                          | 107 ++++-------
 gdb/common/function-view.h              | 320 +++++++++++++++++++++++++++++++
 gdb/compile/compile-c-support.c         |  16 +-
 gdb/dwarf2read.c                        |  51 +++--
 gdb/language.h                          |  19 +-
 gdb/linespec.c                          | 315 ++++++++++++++----------------
 gdb/macrocmd.c                          |  31 ++-
 gdb/macrotab.c                          |  17 +-
 gdb/macrotab.h                          |  39 ++--
 gdb/psymtab.c                           |  79 ++++----
 gdb/symfile-debug.c                     |  42 ++--
 gdb/symfile.c                           |  13 +-
 gdb/symfile.h                           |  64 +++----
 gdb/symmisc.c                           |  47 ++---
 gdb/symtab.c                            | 329 ++++++++++----------------------
 gdb/symtab.h                            |  33 ++--
 gdb/unittests/function-view-selftests.c | 183 ++++++++++++++++++
 18 files changed, 1002 insertions(+), 727 deletions(-)
 create mode 100644 gdb/common/function-view.h
 create mode 100644 gdb/unittests/function-view-selftests.c

-- 
2.5.5


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

end of thread, other threads:[~2017-02-24 17:45 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 14:50 [PATCH 0/3] Introduce gdb::function_view & fix completion bug Pedro Alves
2017-02-22 14:50 ` [PATCH 2/3] Use gdb::function_view in iterate_over_symtabs & co Pedro Alves
2017-02-22 22:40   ` Yao Qi
2017-02-22 14:50 ` [PATCH 3/3] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-23 16:02   ` Yao Qi
2017-02-23 17:12     ` Pedro Alves
2017-02-23 17:24     ` [PATCH v2 0/2] " Pedro Alves
2017-02-23 17:24       ` [PATCH v2 1/2] symtab.c: Small refactor Pedro Alves
2017-02-23 21:45         ` Yao Qi
2017-02-24 17:45           ` Pedro Alves
2017-02-23 17:24       ` [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-24 15:34         ` Yao Qi
2017-02-24 17:15           ` Pedro Alves
2017-02-22 14:50 ` [PATCH 1/3] Introduce gdb::function_view Pedro Alves
2017-02-22 15:15   ` Simon Marchi
2017-02-22 17:40     ` Pedro Alves
2017-02-22 17:49       ` [PATCH v1.1 " Pedro Alves
2017-02-22 22:12         ` Yao Qi
2017-02-23 14:49           ` Pedro Alves
2017-02-23 15:11             ` Yao Qi
2017-02-23 15:20               ` Pedro Alves
2017-02-23 15:34                 ` Yao Qi
2017-02-22 22:23         ` Yao Qi
2017-02-23 14:50           ` [PATCH v1.2 " Pedro Alves
2017-02-23 14:58             ` Yao Qi
2017-02-23 14:59               ` Pedro Alves
2017-02-22 18:02       ` [PATCH " Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox