* [rfc] Do not read from the executable if ptrace fails
@ 2007-06-25 3:09 Daniel Jacobowitz
2007-06-26 0:53 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-06-25 3:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Alex
The old memory read methods used to have a target_has_all_memory
check. It was broken at some point, probably around the introduction
of target_xfer_partial, and when I redid all the memory interfaces
last year I didn't try to fix it. But there's a bug report about
this, which I've been meaning to come back to.
The attached fixes it. If we try to read from a ptrace target, and
it fails, we do not continue down the target stack. This won't affect
core debugging.
Any comments, or shall I apply this?
--
Daniel Jacobowitz
CodeSourcery
2007-06-24 Daniel Jacobowitz <dan@codesourcery.com>
PR symtab/2161
* target.c (memory_xfer_partial): Do not continue past targets with
all memory.
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.143
diff -u -p -r1.143 target.c
--- target.c 9 Jun 2007 13:42:16 -0000 1.143
+++ target.c 25 Jun 2007 00:29:17 -0000
@@ -1084,6 +1084,11 @@ memory_xfer_partial (struct target_ops *
if (res > 0)
return res;
+ /* We want to continue past core files to executables, but not
+ past a running target's memory. */
+ if (ops->to_has_all_memory)
+ return res;
+
ops = ops->beneath;
}
while (ops != NULL);
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [rfc] Do not read from the executable if ptrace fails
2007-06-25 3:09 [rfc] Do not read from the executable if ptrace fails Daniel Jacobowitz
@ 2007-06-26 0:53 ` Joel Brobecker
2007-07-01 22:36 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2007-06-26 0:53 UTC (permalink / raw)
To: gdb-patches, Alex
> Any comments, or shall I apply this?
>
> --
> Daniel Jacobowitz
> CodeSourcery
>
> 2007-06-24 Daniel Jacobowitz <dan@codesourcery.com>
>
> PR symtab/2161
> * target.c (memory_xfer_partial): Do not continue past targets with
> all memory.
FWIW, it looks pretty good to me, and I think it should be part of 6.7
too.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Do not read from the executable if ptrace fails
2007-06-26 0:53 ` Joel Brobecker
@ 2007-07-01 22:36 ` Daniel Jacobowitz
2007-07-23 19:15 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-07-01 22:36 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Alex
On Mon, Jun 25, 2007 at 07:54:03PM -0400, Joel Brobecker wrote:
> > Any comments, or shall I apply this?
> >
> > --
> > Daniel Jacobowitz
> > CodeSourcery
> >
> > 2007-06-24 Daniel Jacobowitz <dan@codesourcery.com>
> >
> > PR symtab/2161
> > * target.c (memory_xfer_partial): Do not continue past targets with
> > all memory.
>
> FWIW, it looks pretty good to me, and I think it should be part of 6.7
> too.
OK, I checked it in.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Do not read from the executable if ptrace fails
2007-07-01 22:36 ` Daniel Jacobowitz
@ 2007-07-23 19:15 ` Ulrich Weigand
2007-07-23 21:25 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2007-07-23 19:15 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches, Alex
Dan Jacobowitz wrote:
> On Mon, Jun 25, 2007 at 07:54:03PM -0400, Joel Brobecker wrote:
> > > Any comments, or shall I apply this?
> > >
> > > --
> > > Daniel Jacobowitz
> > > CodeSourcery
> > >
> > > 2007-06-24 Daniel Jacobowitz <dan@codesourcery.com>
> > >
> > > PR symtab/2161
> > > * target.c (memory_xfer_partial): Do not continue past targets with
> > > all memory.
> >
> > FWIW, it looks pretty good to me, and I think it should be part of 6.7
> > too.
>
> OK, I checked it in.
I only noticed now, but this breaks SPU overlay support.
Overlay support uses "LMA" addresses to refer to overlay sections
not currently loaded, and performs xfer_partial requests to read
from those (e.g. when invoking skip_prologue on a function not
currently present).
This works only if accesses to those LMA addresses go through to
the xfer_memory routine in exec.c, which implements the required
logic to retrieve those section contents from the executable file.
This used to work (probably accidentally?), but is broken by
this patch. Any suggestions how to fix it? Should the overlay
logic from xfer_memory be moved to memory_xfer_partial, maybe?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Do not read from the executable if ptrace fails
2007-07-23 19:15 ` Ulrich Weigand
@ 2007-07-23 21:25 ` Daniel Jacobowitz
2007-07-23 22:05 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-07-23 21:25 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches, Alex
On Mon, Jul 23, 2007 at 09:02:33PM +0200, Ulrich Weigand wrote:
> I only noticed now, but this breaks SPU overlay support.
:-(
> Overlay support uses "LMA" addresses to refer to overlay sections
> not currently loaded, and performs xfer_partial requests to read
> from those (e.g. when invoking skip_prologue on a function not
> currently present).
>
> This works only if accesses to those LMA addresses go through to
> the xfer_memory routine in exec.c, which implements the required
> logic to retrieve those section contents from the executable file.
>
> This used to work (probably accidentally?), but is broken by
> this patch. Any suggestions how to fix it? Should the overlay
> logic from xfer_memory be moved to memory_xfer_partial, maybe?
That sounds reasonable. What about if we check for an unmapped
overlay address at the same point we handle trust_readonly?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Do not read from the executable if ptrace fails
2007-07-23 21:25 ` Daniel Jacobowitz
@ 2007-07-23 22:05 ` Ulrich Weigand
2007-07-23 22:54 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2007-07-23 22:05 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches, Alex
Daniel Jacobowitz wrote:
> > This used to work (probably accidentally?), but is broken by
> > this patch. Any suggestions how to fix it? Should the overlay
> > logic from xfer_memory be moved to memory_xfer_partial, maybe?
>
> That sounds reasonable. What about if we check for an unmapped
> overlay address at the same point we handle trust_readonly?
Like so? Tested on spu-elf, fixes the overlay test case.
Bye,
Ulrich
ChangeLog:
* target.c (memory_xfer_partial): Accesses to unmapped overlay
sections should always go to the executable file.
Index: gdb/target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.144
diff -c -p -r1.144 target.c
*** gdb/target.c 1 Jul 2007 22:35:55 -0000 1.144
--- gdb/target.c 23 Jul 2007 20:39:33 -0000
*************** memory_xfer_partial (struct target_ops *
*** 1017,1022 ****
--- 1017,1030 ----
return xfer_memory (memaddr, readbuf, len, 0, NULL, ops);
}
+ /* Likewise for accesses to unmapped overlay sections. */
+ if (readbuf != NULL && overlay_debugging)
+ {
+ asection *section = find_pc_overlay (memaddr);
+ if (pc_in_unmapped_range (memaddr, section))
+ return xfer_memory (memaddr, readbuf, len, 0, NULL, ops);
+ }
+
/* Try GDB's internal data cache. */
region = lookup_mem_region (memaddr);
/* region->hi == 0 means there's no upper bound. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [rfc] Do not read from the executable if ptrace fails
2007-07-23 22:05 ` Ulrich Weigand
@ 2007-07-23 22:54 ` Daniel Jacobowitz
2007-07-24 13:03 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-07-23 22:54 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches, Alex
On Mon, Jul 23, 2007 at 11:24:56PM +0200, Ulrich Weigand wrote:
> * target.c (memory_xfer_partial): Accesses to unmapped overlay
> sections should always go to the executable file.
Looks fine to me. I can't see any cases where this would be wrong.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Do not read from the executable if ptrace fails
2007-07-23 22:54 ` Daniel Jacobowitz
@ 2007-07-24 13:03 ` Ulrich Weigand
0 siblings, 0 replies; 8+ messages in thread
From: Ulrich Weigand @ 2007-07-24 13:03 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches, Alex
Daniel Jacobowitz wrote:
> On Mon, Jul 23, 2007 at 11:24:56PM +0200, Ulrich Weigand wrote:
> > * target.c (memory_xfer_partial): Accesses to unmapped overlay
> > sections should always go to the executable file.
>
> Looks fine to me. I can't see any cases where this would be wrong.
I've checked this in now, thanks.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-07-24 13:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-25 3:09 [rfc] Do not read from the executable if ptrace fails Daniel Jacobowitz
2007-06-26 0:53 ` Joel Brobecker
2007-07-01 22:36 ` Daniel Jacobowitz
2007-07-23 19:15 ` Ulrich Weigand
2007-07-23 21:25 ` Daniel Jacobowitz
2007-07-23 22:05 ` Ulrich Weigand
2007-07-23 22:54 ` Daniel Jacobowitz
2007-07-24 13:03 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox