* [PATCH 0/7] [gdb/build] Fix -std=c++20 issues
@ 2023-08-15 18:13 Tom de Vries
2023-08-15 18:13 ` [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion Tom de Vries
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
I tried building gdb using -std=c++20, an ran into a few issues.
This series contains fixes for most of them.
I ran into a problem in a libguile header file, I've worked around that by
disabling guile support. I'll file a PR about this.
The final patch, "[gdb/build, c++20] Handle deprecated
std::allocator::construct", exposes two problems where a gdb::byte_vector is
returned and consequently copied.
I have fix for one of those, patch "[gdb/build] Return reference in
target_read_auxv".
But the other one, in remote_target::thread_info_to_thread_handle remains
unfixed:
...
gdb::byte_vector
remote_target::thread_info_to_thread_handle (struct thread_info *tp)
{
remote_thread_info *priv = get_remote_thread_info (tp);
return priv->thread_handle;
}
...
I wrote a patch for this, which allowed me to finish the build with
-std=c++20, but it causes a regression in gdb.python/py-thrhandle.exp, so it's
not included in this series.
Tested on x86_64-linux, with:
- gcc 7.5.0 -std=c++11, and
- gcc 12.3.0 -std=c++17.
Build on x86_64-linux, with:
- gcc 12.3.0 -std=c++20, which runs into the single error mentioned above.
Tom de Vries (7):
[gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion
[gdb/build, c++20] Stop using deprecated is_pod
[gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type
[gdb/build, c++20] Fix deprecated implicit capture of this
[gdb/build, c++20] Fix invalid conversion in test_symbols
[gdb/build] Return reference in target_read_auxv
[gdb/build, c++20] Handle deprecated std::allocator::construct
gdb/ada-lang.c | 2 +-
gdb/arm-fbsd-tdep.c | 2 +-
gdb/auxv.c | 6 +++---
gdb/auxv.h | 2 +-
gdb/dwarf2/read.c | 2 +-
gdb/ravenscar-thread.c | 2 +-
gdb/remote.c | 14 +++++++++-----
gdb/rs6000-tdep.c | 3 ++-
gdb/ui-out.h | 2 +-
gdb/unittests/ptid-selftests.c | 4 +++-
gdbsupport/common-exceptions.h | 4 +++-
gdbsupport/default-init-alloc.h | 13 ++++++++++++-
gdbsupport/poison.h | 2 +-
13 files changed, 39 insertions(+), 19 deletions(-)
base-commit: 2a3f442df9e9a71f9e3c4c5999a2c53bf93e488d
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-15 18:13 ` [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod Tom de Vries
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with clang 15 and -std=c++20, I run into:
...
gdbsupport/common-exceptions.h:203:32: error: arithmetic between different \
enumeration types ('const enum return_reason' and 'const enum errors') is \
deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
size_t result = exc.reason + exc.error;
~~~~~~~~~~ ^ ~~~~~~~~~
...
Fix this by using to_underlying.
Likewise in a few other places.
Tested on x86_64-linux.
---
gdb/remote.c | 12 ++++++++----
gdb/rs6000-tdep.c | 3 ++-
gdbsupport/common-exceptions.h | 4 +++-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 6fefabac0ce..e01da795ec8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -10850,7 +10850,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
char *p;
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
- if (m_features.packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
+ if (m_features.packet_support ((to_underlying (PACKET_Z0)
+ + to_underlying (packet))) == PACKET_DISABLE)
return 1;
/* Make sure the remote is pointing at the right process, if
@@ -10867,7 +10868,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
putpkt (rs->buf);
getpkt (&rs->buf, 0);
- switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet))
+ switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
+ + to_underlying (packet))))
{
case PACKET_ERROR:
return -1;
@@ -10898,7 +10900,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
char *p;
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
- if (m_features.packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
+ if (m_features.packet_support ((to_underlying (PACKET_Z0)
+ + to_underlying (packet))) == PACKET_DISABLE)
return -1;
/* Make sure the remote is pointing at the right process, if
@@ -10914,7 +10917,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
putpkt (rs->buf);
getpkt (&rs->buf, 0);
- switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet))
+ switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
+ + to_underlying (packet))))
{
case PACKET_ERROR:
case PACKET_UNKNOWN:
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index ff83743da36..71390513ad2 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2495,7 +2495,8 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno)
/* Hide the upper halves of the cvs0~cvs31 registers. */
if (PPC_CVSR0_UPPER_REGNUM <= regno
- && regno < PPC_CVSR0_UPPER_REGNUM + ppc_num_gprs)
+ && regno < (to_underlying (PPC_CVSR0_UPPER_REGNUM)
+ + to_underlying (ppc_num_gprs)))
return "";
/* Check if the SPE pseudo registers are available. */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index f9b59ece736..e4750211448 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -26,6 +26,8 @@
#include <string>
#include <functional>
+#include "gdbsupport/underlying.h"
+
/* Reasons for calling throw_exceptions(). NOTE: all reason values
must be different from zero. enum value 0 is reserved for internal
use as the return value from an initial setjmp(). */
@@ -200,7 +202,7 @@ struct hash<gdb_exception>
{
size_t operator() (const gdb_exception &exc) const
{
- size_t result = exc.reason + exc.error;
+ size_t result = to_underlying (exc.reason) + to_underlying (exc.error);
if (exc.message != nullptr)
result += std::hash<std::string> {} (*exc.message);
return result;
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
2023-08-15 18:13 ` [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-15 18:13 ` [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type Tom de Vries
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with clang 15 and -std=c++20, I run into:
...
gdbsupport/poison.h:52:11: error: 'is_pod<timeval>' is deprecated: use \
is_standard_layout && is_trivial instead [-Werror,-Wdeprecated-declarations]
std::is_pod<T>>
^
...
Fix this by following the suggestion.
Likewise in gdb/unittests/ptid-selftests.c.
Tested on x86_64-linux.
---
gdb/unittests/ptid-selftests.c | 4 +++-
gdbsupport/poison.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/unittests/ptid-selftests.c b/gdb/unittests/ptid-selftests.c
index 5af73b0da53..2713b619741 100644
--- a/gdb/unittests/ptid-selftests.c
+++ b/gdb/unittests/ptid-selftests.c
@@ -29,7 +29,9 @@ namespace ptid {
This is a requirement for as long as we have ptids embedded in
structures allocated with malloc. */
-static_assert (std::is_pod<ptid_t>::value, "ptid_t is POD");
+static_assert (gdb::And<std::is_standard_layout<ptid_t>,
+ std::is_trivial<ptid_t>>::value,
+ "ptid_t is POD");
/* We want to avoid implicit conversion from int to ptid_t. */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 956c3d856d8..63fccb30cb9 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -49,7 +49,7 @@ be a compile-time error. */
template<typename T>
struct IsMemsettable
: gdb::Or<std::is_void<T>,
- std::is_pod<T>>
+ gdb::And<std::is_standard_layout<T>, std::is_trivial<T>>>
{};
template <typename T,
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
2023-08-15 18:13 ` [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion Tom de Vries
2023-08-15 18:13 ` [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-15 18:13 ` [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this Tom de Vries
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with -std=c++20, I run into:
...
include/ansidecl.h:342:9: error: expected unqualified-id before ‘const’
342 | TYPE (const TYPE&) = delete; \
| ^~~~~
gdb/ui-out.h:412:3: note: in expansion of macro ‘DISABLE_COPY_AND_ASSIGN’
412 | DISABLE_COPY_AND_ASSIGN (ui_out_emit_type<Type>);
| ^~~~~~~~~~~~~~~~~~~~~~~
...
Fix this by using "DISABLE_COPY_AND_ASSIGN (ui_out_emit_type)".
Tested on x86_64-linux.
---
gdb/ui-out.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index ba5b1de68ab..07567a1df35 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -409,7 +409,7 @@ class ui_out_emit_type
m_uiout->end (Type);
}
- DISABLE_COPY_AND_ASSIGN (ui_out_emit_type<Type>);
+ DISABLE_COPY_AND_ASSIGN (ui_out_emit_type);
private:
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
` (2 preceding siblings ...)
2023-08-15 18:13 ` [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-15 18:13 ` [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols Tom de Vries
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with -std=c++20 I run into:
...
gdb/ada-lang.c:10713:16: error: implicit capture of ‘this’ via ‘[=]’ is \
deprecated in C++20 [-Werror=deprecated]
10713 | auto do_op = [=] (LONGEST x, LONGEST y)
| ^
gdb/ada-lang.c:10713:16: note: add explicit ‘this’ or ‘*this’ capture
...
Fix this by using "[this]".
Likewise in two more spots.
Tested on x86_64-linux.
---
gdb/ada-lang.c | 2 +-
gdb/ravenscar-thread.c | 2 +-
gdb/remote.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1261ee8fa05..018adfcfb70 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10710,7 +10710,7 @@ ada_binop_addsub_operation::evaluate (struct type *expect_type,
value *arg1 = std::get<1> (m_storage)->evaluate_with_coercion (exp, noside);
value *arg2 = std::get<2> (m_storage)->evaluate_with_coercion (exp, noside);
- auto do_op = [=] (LONGEST x, LONGEST y)
+ auto do_op = [this] (LONGEST x, LONGEST y)
{
if (std::get<0> (m_storage) == BINOP_ADD)
return x + y;
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 52016133889..68d336bee99 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -473,7 +473,7 @@ ravenscar_thread_target::update_thread_list ()
(m_base_ptid) and the running thread, that may not have been included
to system.tasking.debug's list yet. */
- iterate_over_live_ada_tasks ([=] (struct ada_task_info *task)
+ iterate_over_live_ada_tasks ([this] (struct ada_task_info *task)
{
this->add_thread (task);
});
diff --git a/gdb/remote.c b/gdb/remote.c
index e01da795ec8..7abe08439b5 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11609,7 +11609,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
int found;
ULONGEST found_addr;
- auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result, size_t len)
+ auto read_memory = [this] (CORE_ADDR addr, gdb_byte *result, size_t len)
{
return (target_read (this, TARGET_OBJECT_MEMORY, NULL, result, addr, len)
== len);
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
` (3 preceding siblings ...)
2023-08-15 18:13 ` [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-15 18:13 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom de Vries
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with -std=c++20, I run into:
...
gdb/dwarf2/read.c:2709:3: error: invalid conversion from ‘const char8_t*’ to \
‘const char*’ [-fpermissive]
2709 | u8"u8função",
| ^~~~~~~~~~~~
| |
| const char8_t*
...
Fix this by making the conversion explicit.
Tested on x86_64-linux.
---
gdb/dwarf2/read.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a64f82bd24a..5b13bbda31d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2706,7 +2706,7 @@ static const char *test_symbols[] = {
/* A UTF-8 name with multi-byte sequences to make sure that
cp-name-parser understands this as a single identifier ("função"
is "function" in PT). */
- u8"u8função",
+ (const char *)u8"u8função",
/* Test a symbol name that ends with a 0xff character, which is a
valid character in non-UTF-8 source character sets (e.g. Latin1
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/7] [gdb/build] Return reference in target_read_auxv
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
` (4 preceding siblings ...)
2023-08-15 18:13 ` [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-16 18:23 ` Tom Tromey
2023-08-15 18:13 ` [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct Tom de Vries
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
7 siblings, 1 reply; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
In target_read_auxv we return a copy of an object:
...
gdb::optional<gdb::byte_vector>
target_read_auxv ()
{
...
return info->data;
}
...
Return a reference instead, saving a copy.
This is exposed by using std::pmr::polymorphic_allocator instead of
std::allocator in default_init_allocator.
Tested on x86_64-linux.
---
gdb/arm-fbsd-tdep.c | 2 +-
gdb/auxv.c | 6 +++---
gdb/auxv.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index acafc4a8bcd..fe1c7f453c9 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
const struct target_desc *
arm_fbsd_read_description_auxv (bool tls)
{
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
return arm_fbsd_read_description_auxv (auxv,
current_inferior ()->top_target (),
current_inferior ()->gdbarch,
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 812b2807554..02b4ab4cdd0 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -354,7 +354,7 @@ invalidate_auxv_cache (void)
/* See auxv.h. */
-gdb::optional<gdb::byte_vector>
+gdb::optional<gdb::byte_vector> &
target_read_auxv ()
{
inferior *inf = current_inferior ();
@@ -410,7 +410,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops,
int
target_auxv_search (CORE_ADDR match, CORE_ADDR *valp)
{
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
if (!auxv.has_value ())
return -1;
@@ -564,7 +564,7 @@ fprint_target_auxv (struct ui_file *file)
struct gdbarch *gdbarch = target_gdbarch ();
CORE_ADDR type, val;
int ents = 0;
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
if (!auxv.has_value ())
return -1;
diff --git a/gdb/auxv.h b/gdb/auxv.h
index 2441b6c02ab..f42efa4fa7b 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -48,7 +48,7 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
/* Read auxv data from the current inferior's target stack. */
-extern gdb::optional<gdb::byte_vector> target_read_auxv ();
+extern gdb::optional<gdb::byte_vector> &target_read_auxv ();
/* Read auxv data from OPS. */
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
` (5 preceding siblings ...)
2023-08-15 18:13 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom de Vries
@ 2023-08-15 18:13 ` Tom de Vries
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
7 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-15 18:13 UTC (permalink / raw)
To: gdb-patches
When building gdb with -std=c++20, I run into:
...
gdbsupport/default-init-alloc.h:52:12: error: ‘construct’ has not been \
declared in ‘class std::allocator<unsigned char>’
52 | using A::construct;
| ^~~~~~~~~
...
Indeed, std::allocator::construct has been deprecated in c++17 and removed in
c++20.
Fix this by using instead std::pmr::polymorphic_allocator for c++20.
Tested on x86_64-linux.
---
gdbsupport/default-init-alloc.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 9c8b5a2c689..e2d3bd24516 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -18,6 +18,10 @@
#ifndef COMMON_DEFAULT_INIT_ALLOC_H
#define COMMON_DEFAULT_INIT_ALLOC_H
+#if __cplusplus >= 202002L
+#include <memory_resource>
+#endif
+
namespace gdb {
/* An allocator that default constructs using default-initialization
@@ -29,7 +33,14 @@ namespace gdb {
adapter that given an allocator A, overrides 'A::construct()'. 'A'
defaults to std::allocator<T>. */
-template<typename T, typename A = std::allocator<T>>
+template<typename T,
+ typename A
+#if __cplusplus >= 202002L
+ = std::pmr::polymorphic_allocator<T>
+#else
+ = std::allocator<T>
+#endif
+ >
class default_init_allocator : public A
{
public:
--
2.35.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] [gdb/build] Return reference in target_read_auxv
2023-08-15 18:13 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom de Vries
@ 2023-08-16 18:23 ` Tom Tromey
0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2023-08-16 18:23 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> In target_read_auxv we return a copy of an object:
Tom> ...
Tom> gdb::optional<gdb::byte_vector>
Tom> target_read_auxv ()
Tom> {
Tom> ...
Tom> return info->data;
Tom> }
Tom> ...
Tom> Return a reference instead, saving a copy.
I suspect it ought to return a const reference instead.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/7] [gdb/build] Fix -std=c++20 issues
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
` (6 preceding siblings ...)
2023-08-15 18:13 ` [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct Tom de Vries
@ 2023-08-16 18:27 ` Tom Tromey
2023-08-21 11:04 ` Tom de Vries
7 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2023-08-16 18:27 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> I tried building gdb using -std=c++20, an ran into a few issues.
Tom> This series contains fixes for most of them.
Thanks for doing this. I read these & sent one comment.
The rest look ok to me.
Tom> But the other one, in remote_target::thread_info_to_thread_handle remains
Tom> unfixed:
Tom> ...
Tom> gdb::byte_vector
Tom> remote_target::thread_info_to_thread_handle (struct thread_info *tp)
Tom> {
Tom> remote_thread_info *priv = get_remote_thread_info (tp);
Tom> return priv->thread_handle;
First, I wonder if we even care about this copying.
But if we do, it could return a const reference and linux-thread-db
could be modified to cache the byte_vector in thread_db_thread_info.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/7] [gdb/build] Fix -std=c++20 issues
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
@ 2023-08-21 11:04 ` Tom de Vries
0 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-08-21 11:04 UTC (permalink / raw)
To: Tom Tromey, Tom de Vries via Gdb-patches
On 8/16/23 20:27, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> I tried building gdb using -std=c++20, an ran into a few issues.
> Tom> This series contains fixes for most of them.
>
> Thanks for doing this. I read these & sent one comment.
> The rest look ok to me.
>
> Tom> But the other one, in remote_target::thread_info_to_thread_handle remains
> Tom> unfixed:
> Tom> ...
> Tom> gdb::byte_vector
> Tom> remote_target::thread_info_to_thread_handle (struct thread_info *tp)
> Tom> {
> Tom> remote_thread_info *priv = get_remote_thread_info (tp);
> Tom> return priv->thread_handle;
>
> First, I wonder if we even care about this copying.
>
Well, I care because I run into a build error:
...
In file included from /usr/include/c++/12/ext/alloc_traits.h:34,
from /usr/include/c++/12/unordered_map:41,
from /usr/include/c++/12/functional:61,
from /data/vries/gdb/src/gdb/../gdbsupport/ptid.h:35,
from
/data/vries/gdb/src/gdb/../gdbsupport/common-defs.h:206,
from /data/vries/gdb/src/gdb/defs.h:26,
from /data/vries/gdb/src/gdb/remote.c:22:
/usr/include/c++/12/bits/alloc_traits.h: In instantiation of ‘static
constexpr _Alloc std::allocator_traits< <template-parameter-1-1>
>::select_on_container_copy_construction(const _Alloc&) [with _Alloc =
gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> >]’:
/usr/include/c++/12/ext/alloc_traits.h:98:63: required from ‘static
constexpr _Alloc __gnu_cxx::__alloc_traits<_Alloc,
<template-parameter-1-2> >::_S_select_on_copy(const _Alloc&) [with
_Alloc = gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> >;
<template-parameter-1-2> = unsigned char]’
/usr/include/c++/12/bits/stl_vector.h:598:34: required from ‘constexpr
std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with
_Tp = unsigned char; _Alloc = gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> >]’
/data/vries/gdb/src/gdb/remote.c:14557:16: required from here
/usr/include/c++/12/bits/alloc_traits.h:402:25: error: could not convert
‘std::allocator_traits<gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> > >::_S_select<const
gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> > >((* & __rhs), 0)’ from
‘std::pmr::polymorphic_allocator<unsigned char>’ to
‘gdb::default_init_allocator<unsigned char,
std::pmr::polymorphic_allocator<unsigned char> >’
402 | { return _S_select(__rhs, 0); }
| ~~~~~~~~~^~~~~~~~~~
| |
|
std::pmr::polymorphic_allocator<unsigned char>
...
> But if we do, it could return a const reference and linux-thread-db
> could be modified to cache the byte_vector in thread_db_thread_info.
I've managed to get that working, submitted here (
https://sourceware.org/pipermail/gdb-patches/2023-August/201727.html ).
Thanks,
- Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-08-21 11:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
2023-08-15 18:13 ` [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion Tom de Vries
2023-08-15 18:13 ` [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod Tom de Vries
2023-08-15 18:13 ` [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type Tom de Vries
2023-08-15 18:13 ` [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this Tom de Vries
2023-08-15 18:13 ` [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols Tom de Vries
2023-08-15 18:13 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom de Vries
2023-08-16 18:23 ` Tom Tromey
2023-08-15 18:13 ` [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct Tom de Vries
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
2023-08-21 11:04 ` Tom de Vries
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).