This is the mail archive of the gdb@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: PR13901


On 04/02/2012 12:57 PM, Tristan Gingold wrote:

> On Apr 2, 2012, at 12:44 PM, Tristan Gingold wrote:
>> > On Mar 30, 2012, at 3:42 PM, Jack Howarth wrote:

>>> >> (gdb) break main

>>> >> Breakpoint 1 at 0xd80: file himenoBMTxpa.c, line 71.
>>> >> (gdb) r
>>> >> Starting program: /Users/howarth/a.out 
>>> >> darwin_set_sstep: unknown flavour: 4
>>> >> Error calling thread_get_state for GP registers for thread 0x8451lxwarning:
>>> >> Mach error at "i386-darwin-nat.c:118" in function
>>> >> "i386_darwin_fetch_inferior_registers": (os/kern) invalid argument (0x4)


>> > I now understand the issue:
>> > 
>> > gdb spawns bash to run the program, but the bash spawned is 64 bits, which is not understood by gdb...
> Fixed by this patch (committed on trunk):


<disclaimer>I don't know much about darwin/osx</disclaimer>

This assumes there's even a 32-bit version of the user's whatever $SHELL.
Not sure we can claim that's always true?  It also doesn't feel right
to force a different $SHELL version/build of the shell that runs if GDB
is not involved.  Very unlikely to cause problems, but still...

Why does GDB need to touch the shell's registers at all in the first place?

If we can't skip darwin_set_sstep for all continues that are not single-steps,
we could at least skip those while starting up (when continuing the shell
until we see enough execs).  That'd suggest a new flag like
darwin-nat.h:struct private_inferior->starting_up, set and cleared in
darwin_create_inferior, and then making darwin_resume_thread do:

-     /* Set single step.  */
-     inferior_debug (4, _("darwin_set_sstep (thread=%x, enable=%d)\n"),
-                     thread->gdb_port, step);
-     darwin_set_sstep (thread->gdb_port, step);
+     /* Avoid touching the $SHELL process, and go straight to resuming it.  */
+     gdb_assert (!inf->private->starting_up || !step);
+     if (!inf->private->starting_up)
+        {
+         /* Set single step.  */
+         inferior_debug (4, _("darwin_set_sstep (thread=%x, enable=%d)\n"),
+                         thread->gdb_port, step);
+         darwin_set_sstep (thread->gdb_port, step);

WDYT?

-- 
Pedro Alves


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