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]

notice_new_inferior stops thread although leave_running is set


Hi

I have questions related to notice_new_inferior (gdb-7.2). The function comment states that: "...If LEAVE_RUNNING, then leave the threads of this inferior running, except those we've explicitly seen reported as stopped.". In the case I'm describing here, "LEAVE_RUNNING" is set to '1'.

It seems that I discover a situation for which the above comment is not true (or otherwise my understanding is wrong): I connect to a remote target, which was already attached to the inferior. Debugging is done with the following options:

    set target-async 1
    set pagination off
    set non-stop on
    set debug remote 1

The inferior is currently running about 19 threads. Check the mail bottom for the GDB stdout. According to that output, GDB sends a 'vCont;t;...' packet before it checks the threads states. All that GDB knows at that time is the amount of threads, their Pid.Tid along with some kind of thread description. It does not know about their states, does it?
According to the function comment, I would have expected that:
- Either the function checks the thread state explicitly and then stop all "stopped" threads
- Or the function does *not* stop any thread (as it is not aware of any stopped thread)
What's wrong here? My understanding? The function comment? The implementation? ...


Why do I care about all this? My problem is that I'm debugging a real-time embedded OS. Attaching the debugger to the system should not cause any change unless the user actively asks to modify a task state. To temporarily solve this issue, I'm using the following patch (which seems to work find for me):

*** /tmp/gdb-7.2/gdb/infcmd.c    2010-07-01 17:36:15.000000000 +0200
--- gdb-7.2/gdb/infcmd.c    2010-12-17 16:26:54.440016740 +0100
*************** notice_new_inferior (ptid_t ptid, int le
*** 2501,2507 ****
    /* When we "notice" a new inferior we need to do all the things we
       would normally do if we had just attached to it.  */

!   if (is_executing (inferior_ptid))
      {
        struct inferior *inferior = current_inferior ();

--- 2501,2507 ----
    /* When we "notice" a new inferior we need to do all the things we
       would normally do if we had just attached to it.  */

!   if (!leave_running && is_executing (inferior_ptid))
      {
        struct inferior *inferior = current_inferior ();


Any advice would be very welcome! Raphael




The GDB output:


GNU gdb (GDB) 7.2
...
This GDB was configured as "--host=i686-pc-linux-gnu --target=powerpc-indel-eabi".
...
Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
Packet received: multiprocess+;QStartNoAckMode+;QNonStop+;qXfer:threads:read+;PacketSize=1EE
Packet qSupported (supported-packets) is supported
Sending packet: $QStartNoAckMode#b0...Ack
Packet received: OK
Sending packet: $!#21...Packet received: OK
Sending packet: $Hgp0.0#ad...Packet received: OK
Sending packet: $QNonStop:1#8d...Packet received: OK
Sending packet: $qXfer:threads:read::0,1e9#a0...Packet received: m<?xml version="1.0"?>\n<threads><thread id="p1.398038" core="0">Startup</thread>\n<thread id="p1.39b000" core="0">INCO Dispatcher</thread>\n<thread id="p1.39dc58" core="0">INCO DispatcherEmg</thread>\n<thread id="p1.3a08f8" core="0">Idle</thread>\n<thread id="p1.3a4210" core="0">ETH0Icmp</thread>\n<thread id="p1.3a67b8" core="0">ETH0Arp</thread>\n<thread id="p1.3a8d78" core="0">INCOCOM0Snd</thread>\n<thread id="p1.3ab1a0" core="0">INCOCOM0Rec</thread>\n<thread id="p1.3ad760" core="0">INCOCOM1
Sending packet: $qXfer:threads:read::1e8,1e9#3e...Packet received: mSnd</thread>\n<thread id="p1.3afb88" core="0">INCOCOM1Rec</thread>\n<thread id="p1.3b2148" core="0">INCOETHSnd</thread>\n<thread id="p1.3b6058" core="0">INCOETHRec</thread>\n<thread id="p1.412a58" core="0">ServiceUdpETH0</thread>\n<thread id="p1.415898" core="0">INOS_1MS</thread>\n<thread id="p1.418428" core="0">InfoLink</thread>\n<thread id="p1.41a5b8" core="0">PostInfoLink</thread>\n<thread id="p1.539350" core="0">ShapeCalc</thread>\n<thread id="p1.53c0a8" core="0">ShapeRun</thread>\n<thread
Sending packet: $qXfer:threads:read::3d0,1e9#37...Packet received: l id="p1.53ee00" core="0">StreamRun</thread>\n<thread id="p1.5646f8" core="0">RunUnitTest</thread>\n</threads>\n
Sending packet: $qAttached:1#fa...Packet received: 1
Packet qAttached (query-attached) is supported
[New Thread 1.3768376]
remote_stop called
Sending packet: $vCont?#49...Packet received: vCont;c;C;s;S;t
Packet vCont (verbose-resume) is supported
Sending packet: $vCont;t:p1.398038#01...Packet received: OK



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