public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
* [patch][rfa] Multi core debugging with GDB
@ 2004-03-22 19:37 Dave Brolley
  2004-03-22 19:56 ` Frank Ch. Eigler
  2004-03-22 21:44 ` Dave Brolley
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Brolley @ 2004-03-22 19:37 UTC (permalink / raw)
  To: sid

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

Hi,

Debugging multiple cores with multiple instances of GDB within a 
simulation is currently possible by specifying a separate --gdb option 
after each --board and specifying a different port for each GDB 
instance. The simulation ends (as it does without GDB) when the first 
core exits. However, the other GDB instances all report "Watchdog 
expired.  Target disconnected". This was because of three problems:

1) The "enabled?", "enable-threshold",  "yield-host-time?" and 
"yield-host-time-threshold" of the host scheduler were not being set. 
This caused the host scheduler to yield host time after the first GDB 
stub exited.

2) The other GDB stubs were not properly notifying their GDB clients 
that they were exiting

3) Even after proper notfication and yielding were implemented, the 
packets never reached their GDB clients because their socket components 
were never polled again which was because the host scheduler was never 
advanced again which was because the whole shut down process was 
initiated when the first GDB stub drove main's "stop!" pin. This problem 
is corrected by having the sockets do one final transmit when their 
"fini" pins are driven by shutdown-sequence.

The result is an orderly shutdown of the GDB stubs and their clients.

OK to commit?

Dave

[-- Attachment #2: sid-gdb.patch.txt --]
[-- Type: text/plain, Size: 6825 bytes --]

Index: sid/component/consoles/socketio.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/consoles/socketio.cxx,v
retrieving revision 1.5
diff -c -p -r1.5 socketio.cxx
*** sid/component/consoles/socketio.cxx	4 Mar 2002 20:38:56 -0000	1.5
--- sid/component/consoles/socketio.cxx	22 Mar 2004 18:48:32 -0000
***************
*** 1,7 ****
  // socketio.cxx - A console that uses a socket to do its I/O.
  // -*- C++ -*-
  
! // Copyright (C) 1999, 2000, 2002 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,7 ----
  // socketio.cxx - A console that uses a socket to do its I/O.
  // -*- C++ -*-
  
! // Copyright (C) 1999-2002, 2004 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** void 
*** 297,302 ****
--- 297,306 ----
  socketio::fini_handler (host_int_4)
  {
    this->poll_control.cancel ();
+ 
+   // Flush out any remaining data
+   if (this->connected_p)
+     this->poll_transmit ();
  
    if (this->connected_p)
      {
Index: sid/component/gdb/gdb.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/gdb/gdb.cxx,v
retrieving revision 1.10
diff -c -p -r1.10 gdb.cxx
*** sid/component/gdb/gdb.cxx	8 May 2002 19:15:30 -0000	1.10
--- sid/component/gdb/gdb.cxx	22 Mar 2004 18:48:32 -0000
***************
*** 1,6 ****
  // gdb.cxx - GDB stub implementation.  -*- C++ -*-
  
! // Copyright (C) 1999-2002 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,6 ----
  // gdb.cxx - GDB stub implementation.  -*- C++ -*-
  
! // Copyright (C) 1999-2002, 2004 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** gdb::deinit_handler (host_int_4) 
*** 1550,1556 ****
  {
    // disconnect if needed
    if (this->connected_p)
!     this->remote_rx_eof_handler ();
  }
  
  
--- 1550,1562 ----
  {
    // disconnect if needed
    if (this->connected_p)
!     {
!       // shut down target
!       target_power (false);
!       // signal gdb
!       gdbserv_fromtarget_exit (gdbserv, 0);
!       this->remote_rx_eof_handler ();
!     }
  }
  
  
Index: sid/main/dynamic/commonCfg.cxx
===================================================================
RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v
retrieving revision 1.6
diff -c -p -r1.6 commonCfg.cxx
*** sid/main/dynamic/commonCfg.cxx	27 Oct 2003 18:55:34 -0000	1.6
--- sid/main/dynamic/commonCfg.cxx	22 Mar 2004 18:48:34 -0000
*************** SessionCfg::SessionCfg (const string nam
*** 530,536 ****
      tcl_bridge (NULL),
      loader (NULL),
      verbose (false),
!     use_stdio (true)
  {
    add_child (host_sched);
    add_child (sim_sched);
--- 530,538 ----
      tcl_bridge (NULL),
      loader (NULL),
      verbose (false),
!     use_stdio (true),
!     board_count (0),
!     gdb_count (0)
  {
    add_child (host_sched);
    add_child (sim_sched);
*************** void SessionCfg::use_tcl_bridge ()
*** 657,662 ****
--- 659,684 ----
    init_seq->add_output (7, tcl_bridge, "!event");
  }
  
+ void SessionCfg::write_config (Writer &w)
+ {
+   AggregateCfg::write_config (w);
+ 
+   // Stop the host scheduler if all of the GDB stubs are stopped
+   if (gdb_count)
+     {
+       assert (host_sched);
+       Setting (host_sched, "yield-host-time-threshold",
+ 	       sidutil::make_attribute (gdb_count)).write_to (w);
+       Setting (host_sched, "yield-host-time?", "0").write_to (w);
+     }
+ 
+   // Stop the sim scheduler if any of the GDB stubs are stopped
+   assert (sim_sched);
+   Setting (sim_sched, "enable-threshold",
+ 	   sidutil::make_attribute (board_count)).write_to (w);
+   Setting (sim_sched, "enabled?",
+ 	   sidutil::make_attribute (board_count)).write_to (w);
+ }
  
  // LoaderCfg 
  LoaderCfg::~LoaderCfg () {}
*************** void BoardCfg::set_gdb (const string por
*** 920,925 ****
--- 942,948 ----
    gdb = new GdbCfg ("gdb", port, cpu, this, sess);
    add_child (gdb);
    sess->use_no_stdio ();
+   sess->add_gdb ();
  }
  
  
Index: sid/main/dynamic/commonCfg.h
===================================================================
RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.h,v
retrieving revision 1.3
diff -c -p -r1.3 commonCfg.h
*** sid/main/dynamic/commonCfg.h	21 Oct 2003 21:39:04 -0000	1.3
--- sid/main/dynamic/commonCfg.h	22 Mar 2004 18:48:34 -0000
*************** struct UlogCfg
*** 182,187 ****
--- 182,188 ----
  
  // you should really only make one of these, with an empty name,
  // unless you want some crazy multi-session support.
+ class BoardCfg;
  class LoaderCfg;
  
  struct SessionCfg :
*************** struct SessionCfg :
*** 214,219 ****
--- 215,226 ----
    bool use_stdio;
    void add_ulog_file (const string filename);
    map<const string, AtomicCfg *> ulog_map;
+   void add_gdb () { ++gdb_count; }
+   void add_board (ComponentCfg *b) { ++board_count; add_child (b); }
+   virtual void write_config (Writer &w);
+ private:
+   sid::host_int_4 board_count;
+   sid::host_int_4 gdb_count;
  };
  
  class CpuCfg :
*************** public:
*** 277,283 ****
    virtual ~GprofCfg ();
  };
  
- class BoardCfg;
  class GdbCfg :
    virtual public AggregateCfg
  {
--- 284,289 ----
Index: sid/main/dynamic/mainDynamic.cxx
===================================================================
RCS file: /cvs/src/src/sid/main/dynamic/mainDynamic.cxx,v
retrieving revision 1.5
diff -c -p -r1.5 mainDynamic.cxx
*** sid/main/dynamic/mainDynamic.cxx	21 Oct 2003 21:39:04 -0000	1.5
--- sid/main/dynamic/mainDynamic.cxx	22 Mar 2004 18:48:34 -0000
*************** main(int argc, char* argv[])
*** 617,623 ****
  	      {
  		need_sess (sess);
  		if (curr_board)
! 		  sess->add_child (curr_board);
  		curr_board = NULL;
  		string new_board_type = optstring();
  		string new_board_name (new_board_type + "-" + 
--- 617,623 ----
  	      {
  		need_sess (sess);
  		if (curr_board)
! 		  sess->add_board (curr_board);
  		curr_board = NULL;
  		string new_board_type = optstring();
  		string new_board_name (new_board_type + "-" + 
*************** main(int argc, char* argv[])
*** 878,884 ****
      }
  
    if (sess && curr_board)
!     sess->add_child (curr_board);
  
    if (persistent_p)
      config_items.push_back (make_pair (false, string("set main persistent? true")));
--- 878,884 ----
      }
  
    if (sess && curr_board)
!     sess->add_board (curr_board);
  
    if (persistent_p)
      config_items.push_back (make_pair (false, string("set main persistent? true")));

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa] Multi core debugging with GDB
  2004-03-22 19:37 [patch][rfa] Multi core debugging with GDB Dave Brolley
@ 2004-03-22 19:56 ` Frank Ch. Eigler
  2004-03-22 21:44 ` Dave Brolley
  1 sibling, 0 replies; 4+ messages in thread
From: Frank Ch. Eigler @ 2004-03-22 19:56 UTC (permalink / raw)
  To: Dave Brolley; +Cc: sid

Hi -

brolley wrote:
> [...]
> 3) Even after proper notfication and yielding were implemented, the 
> packets never reached their GDB clients because their socket components 
> were never polled again [...]

Looks good overall.  For this part (socketio fini), you might consider
having a brief loop to encourage all enqueued data to go out.

- FChE

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa] Multi core debugging with GDB
  2004-03-22 19:37 [patch][rfa] Multi core debugging with GDB Dave Brolley
  2004-03-22 19:56 ` Frank Ch. Eigler
@ 2004-03-22 21:44 ` Dave Brolley
  2004-03-22 21:45   ` Dave Brolley
  1 sibling, 1 reply; 4+ messages in thread
From: Dave Brolley @ 2004-03-22 21:44 UTC (permalink / raw)
  To: Dave Brolley; +Cc: sid

Approved by fche and committed with the attached modification to ensure 
that all data gets flushed.

Dave Brolley wrote:

> Hi,
>
> Debugging multiple cores with multiple instances of GDB within a 
> simulation is currently possible by specifying a separate --gdb option 
> after each --board and specifying a different port for each GDB 
> instance. The simulation ends (as it does without GDB) when the first 
> core exits. However, the other GDB instances all report "Watchdog 
> expired.  Target disconnected". This was because of three problems:
>
> 1) The "enabled?", "enable-threshold",  "yield-host-time?" and 
> "yield-host-time-threshold" of the host scheduler were not being set. 
> This caused the host scheduler to yield host time after the first GDB 
> stub exited.
>
> 2) The other GDB stubs were not properly notifying their GDB clients 
> that they were exiting
>
> 3) Even after proper notfication and yielding were implemented, the 
> packets never reached their GDB clients because their socket 
> components were never polled again which was because the host 
> scheduler was never advanced again which was because the whole shut 
> down process was initiated when the first GDB stub drove main's 
> "stop!" pin. This problem is corrected by having the sockets do one 
> final transmit when their "fini" pins are driven by shutdown-sequence.
>
> The result is an orderly shutdown of the GDB stubs and their clients.
>
> OK to commit?
>
> Dave



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa] Multi core debugging with GDB
  2004-03-22 21:44 ` Dave Brolley
@ 2004-03-22 21:45   ` Dave Brolley
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Brolley @ 2004-03-22 21:45 UTC (permalink / raw)
  To: Dave Brolley; +Cc: sid

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

And here's the modified patch for socketio.cxx

Dave Brolley wrote:

> Approved by fche and committed with the attached modification to 
> ensure that all data gets flushed.
>
> Dave Brolley wrote:
>
>> Hi,
>>
>> Debugging multiple cores with multiple instances of GDB within a 
>> simulation is currently possible by specifying a separate --gdb 
>> option after each --board and specifying a different port for each 
>> GDB instance. The simulation ends (as it does without GDB) when the 
>> first core exits. However, the other GDB instances all report 
>> "Watchdog expired.  Target disconnected". This was because of three 
>> problems:
>>
>> 1) The "enabled?", "enable-threshold",  "yield-host-time?" and 
>> "yield-host-time-threshold" of the host scheduler were not being set. 
>> This caused the host scheduler to yield host time after the first GDB 
>> stub exited.
>>
>> 2) The other GDB stubs were not properly notifying their GDB clients 
>> that they were exiting
>>
>> 3) Even after proper notfication and yielding were implemented, the 
>> packets never reached their GDB clients because their socket 
>> components were never polled again which was because the host 
>> scheduler was never advanced again which was because the whole shut 
>> down process was initiated when the first GDB stub drove main's 
>> "stop!" pin. This problem is corrected by having the sockets do one 
>> final transmit when their "fini" pins are driven by shutdown-sequence.
>>
>> The result is an orderly shutdown of the GDB stubs and their clients.
>>
>> OK to commit?
>>
>> Dave
>
>
>
>


[-- Attachment #2: socket-flush.patch.txt --]
[-- Type: text/plain, Size: 1244 bytes --]

Index: sid/component/consoles/socketio.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/consoles/socketio.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -c -p -r1.5 -r1.6
*** sid/component/consoles/socketio.cxx	4 Mar 2002 20:38:56 -0000	1.5
--- sid/component/consoles/socketio.cxx	22 Mar 2004 21:26:44 -0000	1.6
***************
*** 1,7 ****
  // socketio.cxx - A console that uses a socket to do its I/O.
  // -*- C++ -*-
  
! // Copyright (C) 1999, 2000, 2002 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,7 ----
  // socketio.cxx - A console that uses a socket to do its I/O.
  // -*- C++ -*-
  
! // Copyright (C) 1999-2002, 2004 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** void 
*** 297,302 ****
--- 297,306 ----
  socketio::fini_handler (host_int_4)
  {
    this->poll_control.cancel ();
+ 
+   // Flush out any remaining data
+   while (this->connected_p && this->out_buffer.length() != 0)
+     this->poll_transmit ();
  
    if (this->connected_p)
      {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-22 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-22 19:37 [patch][rfa] Multi core debugging with GDB Dave Brolley
2004-03-22 19:56 ` Frank Ch. Eigler
2004-03-22 21:44 ` Dave Brolley
2004-03-22 21:45   ` Dave Brolley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).