[PATCH] Linux: Access memory even if threads are running

Pedro Alves pedro@palves.net
Fri Jul 2 09:05:54 GMT 2021


On 2021-07-01 8:14 p.m., Luis Machado wrote:
> On 7/1/21 3:34 PM, Pedro Alves wrote:
>> On 2021-07-01 7:03 p.m., Luis Machado wrote:
>>> On 7/1/21 2:30 PM, Pedro Alves wrote:
>>
>>>> I don't know how memory tags work, I have not followed that thread.
>>>>
>>>
>>> Whenever you attempt to print a tagged pointer, GDB will try to fetch the memory tags (via ptrace). In this particular case, it will fail to fetch the tags, even if the architecture supports it.
>>
>> Even if the pointer variable is e.g., a history variable (which could be for an unrelated inferior,
>> or for a past instance of the inferior, etc.) ?
> 
> Yes. Any TYPE_CODE_PTR that is tagged will have its logical tag validated against the allocation tag in memory.
> 
>>
>>>
>>> I guess since this is mostly non-stop, which is used less often than all-stop, this won't matter much.
>>
>> That's a bit dismissive.  :-)  Some users and some IDEs rely on non-stop mode all the time.  But yeah,
>> not great, but not different from what you had before my patch.  The user just needs to
>> pause some thread.  But I'd suggest trying it out and seeing how bad is the breakage.  AFAICS,
>> print_command_1 does the validation before printing the variable.  It might be useful to catch
>> errors and say something along the lines of "cannot validate tags, thread is running" and then
>> still print the value.
>>
> 
> Sorry if it came out that way. My point is not to dismiss non-stop, but most of the cases I'm handling are all-stop-target-stopped scenarios. I'm trying to assess what is the impact of this new use case for memory tagging. If most of our users are using all-stop, then this change won't matter much. That's the context of my point above.

No worries.  Note this isn't a new use case.  With gdbserver, it has been possible to set breakpoints
and access memory while threads are running for years.  Only native debugging did not.

> 
> I have a patch on the list to catch validation errors and fallback to regular printing of variables. In that case, users will just not see the tags being validated, which is not ideal, but acceptable.

I've found it, and replied on that thread.

Cheers,
Pedro Alves


More information about the Gdb-patches mailing list