This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true


> 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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]