This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: back into the thread....
- From: Phi Debian <phi dot debian at gmail dot com>
- To: Sterling Augustine <saugustine at google dot com>
- Cc: Mark Manning <mark4th at gmail dot com>, gdb at sourceware dot org
- Date: Wed, 13 Nov 2013 07:48:27 +0100
- Subject: Re: back into the thread....
- Authentication-results: sourceware.org; auth=none
- References: <CAPGNrUX7TA-4eCrrP=sD9G6oNe5Kw=eWPm_jm-D7=9ZTz-v6BA at mail dot gmail dot com> <CAEG7qUx69s2cdp4XY3cGtAakDQAoSrGnbhgvvLxUzZG+rJKC_g at mail dot gmail dot com> <CAEG7qUyR8OZ=XGy0WwK=1UW46afS=e-67Hs=P3XToxKA1Q9+Pw at mail dot gmail dot com>
Hi All,
Off topic about gdb discution
> if (posix_memalign((void **) &dst, 4096*8, EXEC_BYTES) != 0) {
> printf("can't allocate.\n");
> exit (-1);
> }
> if (mprotect(dst, EXEC_BYTES, PROT_READ|PROT_WRITE|PROT_EXEC) != 0) {
> printf("can't mprotect\n");
> exit (-1);
> }
> memcpy(dst, bytes, EXEC_BYTES);
>
> return_val = dst(test_val);
The above code as very little chance to execute on modernn
architecture, at least with architecture with separate icache and
dcache.
The memcpy fill the dcache, the dst() read the icache, since the
caches are not flushed in between, the dst() will execute garbage
(well instruction living there before).
As far as GDB is concerned, it should be able to single step in any
memory area that is declared 'executable'
> Also, the "can not access addres zero" error is totally bogus,
Not if you consider your single step execute garbage instruction.
Cheers,
Phi