gdb, btrace: fix assert with gcc-15

Message ID 20251217101632.2591325-1-markus.t.metzger@intel.com
State New
Headers
Series gdb, btrace: fix assert with gcc-15 |

Commit Message

Metzger, Markus T Dec. 17, 2025, 10:16 a.m. UTC
  This fixes

/usr/include/c++/15/optional:1186: constexpr _Tp& std::optional<_Tp>::operator*() & [with _Tp = std::__cxx11::basic_string<char>]: Assertion 'this->_M_is_engaged()' failed.

encountered in gdb.btrace/ptwrite.exp.
---
 gdb/btrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Simon Marchi Dec. 17, 2025, 3:20 p.m. UTC | #1
On 12/17/25 5:16 AM, Markus Metzger wrote:
> This fixes
> 
> /usr/include/c++/15/optional:1186: constexpr _Tp& std::optional<_Tp>::operator*() & [with _Tp = std::__cxx11::basic_string<char>]: Assertion 'this->_M_is_engaged()' failed.

Just wondering, is this with -D_GLIBCXX_DEBUG or without?  Are there
some assertions enabled by default?

> 
> encountered in gdb.btrace/ptwrite.exp.
> ---
>  gdb/btrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/btrace.c b/gdb/btrace.c
> index b5516a1499c..b7c26573404 100644
> --- a/gdb/btrace.c
> +++ b/gdb/btrace.c
> @@ -1393,7 +1393,7 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
>  	      continue;
>  
>  	    if (!ptw_string.has_value ())
> -	      *ptw_string = hex_string (event.variant.ptwrite.payload);
> +	      ptw_string = hex_string (event.variant.ptwrite.payload);

LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  
Sam James Dec. 17, 2025, 3:49 p.m. UTC | #2
Simon Marchi <simark@simark.ca> writes:

> On 12/17/25 5:16 AM, Markus Metzger wrote:
>> This fixes
>> 
>> /usr/include/c++/15/optional:1186: constexpr _Tp& std::optional<_Tp>::operator*() & [with _Tp = std::__cxx11::basic_string<char>]: Assertion 'this->_M_is_engaged()' failed.
>
> Just wondering, is this with -D_GLIBCXX_DEBUG or without?  Are there
> some assertions enabled by default?

At -O0, -D_GLIBCXX_ASSERTIONS is the default with GCC >= 15.

>
>> 
>> encountered in gdb.btrace/ptwrite.exp.
>> ---
>>  gdb/btrace.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/gdb/btrace.c b/gdb/btrace.c
>> index b5516a1499c..b7c26573404 100644
>> --- a/gdb/btrace.c
>> +++ b/gdb/btrace.c
>> @@ -1393,7 +1393,7 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
>>  	      continue;
>>  
>>  	    if (!ptw_string.has_value ())
>> -	      *ptw_string = hex_string (event.variant.ptwrite.payload);
>> +	      ptw_string = hex_string (event.variant.ptwrite.payload);
>
> LGTM.
>
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>
> Simon
  

Patch

diff --git a/gdb/btrace.c b/gdb/btrace.c
index b5516a1499c..b7c26573404 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1393,7 +1393,7 @@  handle_pt_insn_events (struct btrace_thread_info *btinfo,
 	      continue;
 
 	    if (!ptw_string.has_value ())
-	      *ptw_string = hex_string (event.variant.ptwrite.payload);
+	      ptw_string = hex_string (event.variant.ptwrite.payload);
 
 	    handle_pt_aux_insn (btinfo, *ptw_string, pc);