Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 0/3] Introduce gdb::function_view & fix completion bug
Date: Wed, 22 Feb 2017 14:50:00 -0000	[thread overview]
Message-ID: <1487775033-32699-1-git-send-email-palves@redhat.com> (raw)

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


             reply	other threads:[~2017-02-22 14:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 14:50 Pedro Alves [this message]
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
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

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=1487775033-32699-1-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@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