corefiles/2265: writable registers in core files

zigmar@gmail.com zigmar@gmail.com
Mon May 28 10:18:00 GMT 2007


>Number:         2265
>Category:       corefiles
>Synopsis:       writable registers in core files
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          patch
>Submitter-Id:   net
>Arrival-Date:   Mon May 28 10:18:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     zigmar@gmail.com
>Release:        6.6
>Organization:
>Environment:

>Description:
Sometimes, there is a need sometimes to modify registers when debugging the core file. There could be several reasons for this. One of them (my case) is the application uses user-level non-preemptive threading, and examining different threads (i.e. backtracing) requires modification of some registers (notably stack pointers). Other uses might include debugging core of the process where some registers got garbled due to corruption and need manual fix. There is no actual reason why GDB wont let to modify the registers when debugging the core file.

The patch is fairly simple: it only allows to changes registers by installing dummy to_prepare_to_store & to_store_registers, without any additional side effects.

The patch is based on the old discussion between Jon Ringle <jon dot ringle at comdial dot com> and Daniel Jacobowitz <drow at false dot org>: 
http://www.cygwin.com/ml/gdb/2005-04/msg00187.html
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gdb6.6_corelow.c_registers.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gdb6.6_corelow.c_registers.patch"

LS0tIGdkYi02LjYtb3JpZy9nZGIvY29yZWxvdy5jICAyMDA2LTA0LTE4IDIyOjIwOjA2LjAwMDAw
MDAwMCArMDMwMAorKysgZ2RiLTYuNi9nZGIvY29yZWxvdy5jICAgICAgIDIwMDctMDUtMjggMTI6
NTY6MTMuMDAwMDAwMDAwICswMzAwCkBAIC00ODcsMTkgKzQ4NywyMSBAQAogewogICBpbnQgc3Rh
dHVzOwoKLSAgaWYgKCEoY29yZV9nZGJhcmNoICYmIGdkYmFyY2hfcmVnc2V0X2Zyb21fY29yZV9z
ZWN0aW9uX3AgKGNvcmVfZ2RiYXJjaCkpCi0gICAgICAmJiA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