PTL - PDB (PTL Internal Debugger)
Note: All information in this page is out-of-date. Modern operating systems have multi-threading function so PTL is no longer useful.
PTL - Portable Thread Library
Top Page
Original APIs
Supported APIs
Debugger ->

   PDB (PTL Internal Debugger)

PTL has a builtin debugger PDB. You can connect to PDB with telnet command and examine thread related objects such as threads, mutexes, condition variables, etc.

  How to invoke PDB

To invoke PDB, you have to set environment variable PTL_DEBUG_PORT to a TCP port number before executing your program.

% env PTL_DEBUG_PORT=9999 ./philosopher

Then, you can connect to PDB with telnet command.Probably you want to do this in another window.

% telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
PTL Debugger (thread 8, file descriptor 3)
Copyright (C) 1995-1999 Kota ABE
pdb>

If you add :wait to $PTL_DEBUG_PORT (i.e. PTL_DEBUG_PORT=9999:wait),the program does not start until the connection is established.

  PDB commands

help

displays the help message.



ps [-stack|-signal|-sched] [thread-id...]

displays thread information.

If no option is given, display basic information.
pdb> ps
 TID Name             Arg(hex) State     Detail
   4 [I/O]                   0 sigwait    (io_dispatch_thread(), io.c, line 650)
   6 [IDLE]                  0 run       
   8 [PDB]                   0 run       
   9 noname(0x1c30)       e380 cond      CV 0xd400 (take_forks(), philosopher.c, line 104)
  10 noname(0x1c30)       e390 sleep     8.000 sec (eat(), philosopher.c, line 94)
  11 noname(0x1c30)       e3a0 cond      CV 0xd400 (take_forks(), philosopher.c, line 104)
  12 noname(0x1c30)       e3b0 sleep     1.000 sec (think(), philosopher.c, line 86)
  13 noname(0x1c30)       e3c0 sleep     8.000 sec (eat(), philosopher.c, line 94)

Note that the threads whose name is surrounded by [] are PTL internal threads.

-stack option displays thread's stack information.

pdb> ps -stack
 TID STK   STKSZ    BASE       NAME
   4 heap   4000     f320      [I/O]
   6 heap   4000    21320      [IDLE]
   8 heap   4000    26320      [PDB]
   9 heap   4000    2b320      noname(0x1c30)
  10 heap   4000    30320      noname(0x1c30)
  11 heap   4000    35320      noname(0x1c30)
  12 heap   4000    3a320      noname(0x1c30)
  13 heap   4000    3f320      noname(0x1c30)
    

-signal displays signal mask information.

pdb> ps -signal
     H I Q I T I E F K B S S P A T U S T C C T T I X X V P W I U U P 
     U N U L R O M P I U E Y I L E R T S O H T T O C F T R I N S S W 
     P T I L A T T E L S G S P R R G O T N L I O   P S A O N F R R R 
         T   P       L   V   E M M   P P T D N U   U Z L F C O 1 2   
                                                       R   H         
 TID                                                   M              NAME
   4 x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x [I/O]
   6 x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x [IDLE]
   8 x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x [PDB]
   9                                                                 noname(0x1c30)
  10                                                                 noname(0x1c30)
  11                                                                 noname(0x1c30)
  12                                                                 noname(0x1c30)
  13                                                                 noname(0x1c30)

ProcLevel                                                                  

Note: x means the signal is masked. ! means the signal is suspended.

-sched option displays scheduling information.

pdb> ps -sched
 TID Policy Pri Detach   CancelStat CancelType   CancelReq NAME
   4 FIFO    32 JOINABLE ENABLE     DEFERRED               [I/O]
   6 IDLE     0 JOINABLE ENABLE     DEFERRED               [IDLE]
   8 FIFO    32 JOINABLE ENABLE     DEFERRED               [PDB]
   9 OTHER    8 JOINABLE ENABLE     DEFERRED               noname(0x1c30)
  10 OTHER    8 JOINABLE ENABLE     DEFERRED               noname(0x1c30)
  11 OTHER    8 JOINABLE ENABLE     DEFERRED               noname(0x1c30)
  12 OTHER    8 JOINABLE ENABLE     DEFERRED               noname(0x1c30)
  13 OTHER    8 JOINABLE ENABLE     DEFERRED               noname(0x1c30)


thread
same as ps command.


cond

displays condition variables.

pdb> cond
   ID    NAME             #WAITER  WAITING THREADS ID
    d480 noname                0   
    d400 noname                1    11
    d340 [BG TTY]              0   


mutex

displays mutexes.

pdb> mutex
   ID    PROTO   CEIL BOOST NAME             OWNER #WAITER WAITING THREADS ID
   14460 NO        32     0 noname               0       0
   14420 NO        32     0 noname               0       0
   143e0 NO        32     0 [stdio_global]       0       0
   143a0 NO        32     0 [pthread_first]      0       0
   14360 NO        32     0 [IO]                 0       0


signal

displays signal status.

pdb> signal
SIG NAME   HANDLER
  1 HUP    SIG_DFL
  2 INT    SIG_DFL
  3 QUIT   SIG_DFL
  4 ILL    SIG_DFL
  5 TRAP   SIG_DFL
  6 IOT    SIG_DFL
  7 EMT    SIG_DFL
  8 FPE    SIG_DFL
  9 KILL   SIG_DFL
 10 BUS    SIG_DFL
 11 SEGV   SIG_DFL
 12 SYS    SIG_DFL
 13 PIPE   SIG_DFL
 14 ALRM   SIG_DFL
 15 TERM   SIG_DFL
 16 URG    SIG_DFL
 17 STOP   SIG_DFL
 18 TSTP   SIG_SIGWAIT_NP
 19 CONT   SIG_SIGWAIT_NP
 20 CHLD   SIG_DFL
 21 TTIN   SIG_DFL
 22 TTOU   SIG_DFL
 23 IO     SIG_DFL
 24 XCPU   SIG_DFL
 25 XFSZ   SIG_DFL
 26 VTALRM SIG_DFL
 27 PROF   SIG_DFL
 28 WINCH  SIG_DFL
 29 INFO   SIG_DFL
 30 USR1   SIG_DFL
 31 USR2   SIG_DFL
 32 PWR    SIG_DFL


suspend thread-id...

suspend all

suspend the specified (or all) threads. Note that thread suspension from PDB is distinct from that by pthread_suspend_np().



resume thread-id...

resume all

resume the specified (or all) threads.



cancel thread-id...

perform pthread_cancel() to the specified threads.



broadcast cond-id...

perform pthread_cond_broadcast() to the specified condition variables.



dmesg

displays PTL's internal ring queue message buffer contents. You can use pthread_debug_pdb_np() to put messages to the buffer.



timeq

displays PTL internal timeout queue.



iostat (since PTL-2.1)

displays file descriptor status.



timer

not implemented.



quit

quit PDB. Program execution continues.