This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/1] [RFC] gdb: corelow: make possible to modify (set) registers for a corefile
- From: Roman Penyaev <roman dot penyaev at profitbricks dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: Pedro Alves <palves at redhat dot com>, Daniel Jacobowitz <dan at codesourcery dot com>, Jan Kratochvil <jan dot kratochvil at redhat dot com>, gdb-patches at sourceware dot org, Stefan Hajnoczi <stefanha at redhat dot com>
- Date: Wed, 15 Mar 2017 10:02:11 +0100
- Subject: Re: [PATCH 1/1] [RFC] gdb: corelow: make possible to modify (set) registers for a corefile
- Authentication-results: sourceware.org; auth=none
- References: <20170314100838.12647-1-roman.penyaev@profitbricks.com> <20170314131454.533FAD830FF@oc3748833570.ibm.com>
On Tue, Mar 14, 2017 at 2:14 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> Roman Pen wrote:
>
>> Despite the fact that this is a hairy hack this change eases debugging
>> of a jmp_buf (setjmp()) and user contexts (makecontext()), which are
>> highly used in QEMU project as a part of coroutines.
>>
>> This change allows setting registers for a corefile, thus QEMU gdb
>> script (qemu/scripts/qemugdb/coroutine.py) is allowed to investigate
>> backtrace of a preempted coroutine context. Previously only debugging
>> of a live process was allowed.
>>
>> This patch caches all register on a first attempt to modify register
>> '(gdb) set $REG = ADDR' and then cached copy is always returned from
>> get_core_registers().
>>
>> This change should not break previous behaviour if nobody sets any
>> register, i.e. on each get_core_registers() call registers from a
>> corefile will be reread.
>
> I'm wondering why you need that extra copy of the registers;
> there already should be a regcache that would be able to hold
> any modified values.
>
> It is not currently possible to actually change those values
> in the regcache because there is no to_store_registers routine.
> But simply adding such a routine that does nothing (just like
> to_prepare_to_store in your patch) should hopefully be enough ...
Unfortunately it is not. 'regcache' argument, which is passed to
get_core_registers(), has all registers set to zero, i.e. registers
are not preserved between 'to_fetch_registers' and 'to_store_registers'
calls. Thus on each get_core_registers() call we have to fill in
'regcache'. By default registers are always fetched from a corefile,
which prevents modifying them, that's why I need some extra registers
array.
>
> In any case, it would be good to add or extend a test case to
> verify that this feature is working as intended.
Good point, I will take a look.
Thanks.
--
Roman