This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sun, 08 Sep 2013 18:10:19 +0300
- Subject: Re: [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true
- Authentication-results: sourceware.org; auth=none
- References: <1378432920-7731-1-git-send-email-yao at codesourcery dot com> <1378641807-24256-1-git-send-email-yao at codesourcery dot com> <1378641807-24256-2-git-send-email-yao at codesourcery dot com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: Yao Qi <yao@codesourcery.com>
> Date: Sun, 8 Sep 2013 20:03:21 +0800
>
> If users write a readonly section, such as .text, the contents of the inferior
> and of the executable become out of sync. It is better to emit a warning
> to ask users to "set trust-readonly-sections off".
>
> (gdb) set trust-readonly-sections on
> (gdb) p /x* (char *) 0x080484c1 = 0xcc
> warning: Writing to a readonly section so that the contents in the
> inferior and in the executable are out of sync. Please 'set
> trust-readonly-sections off'.
> $1 = 0xcc
This warning got me puzzled: did GDB write to the address or did it
not? If it did, why do we need the warning? If it did not, the
warning does not say that clearly enough.
How about the following instead:
(gdb) set trust-readonly-sections on
(gdb) p /x* (char *) 0x080484c1 = 0xcc
Address is read-only and trust-readonly-sections is set to "on";
set it to "off" and write to a read-only section? (y or n)
And then if the user answers "yes", set trust-readonly-sections to off
automatically. Isn't this a better UI?