User Level DB: a Debugging API for User- Level Thread Libraries - - PowerPoint PPT Presentation

user level db a debugging api for user level thread
SMART_READER_LITE
LIVE PREVIEW

User Level DB: a Debugging API for User- Level Thread Libraries - - PowerPoint PPT Presentation

User Level DB: a Debugging API for User- Level Thread Libraries Kevin Pouget, Marc Prache, Patrick Carribault, and Herv Jourdren kevin.pouget@gmail.com, {marc.perache,patrick.carribault,herve.jourdren}@cea.fr CEA, DAM, DIF, F-91297 Arpajon,


slide-1
SLIDE 1

1 MTAAP 2010 CEA,DAM,DIF

User Level DB: a Debugging API for User- Level Thread Libraries

Kevin Pouget, Marc Pérache, Patrick Carribault, and Hervé Jourdren

kevin.pouget@gmail.com, {marc.perache,patrick.carribault,herve.jourdren}@cea.fr CEA, DAM, DIF, F-91297 Arpajon, France

slide-2
SLIDE 2

2 MTAAP 2010 CEA,DAM,DIF

Outline

  • Context
  • User-Level Thread Libraries
  • User-Level Thread Libraries and Debugging
  • User Level DB
  • Conclusion and Future Work
slide-3
SLIDE 3

3 MTAAP 2010 CEA,DAM,DIF

Introduction

  • Context

High Performance Computing Supercomputer architecture

  • Cluster

Cluster

  • Non

Non-

  • Uniform Memory Access

Uniform Memory Access (NUMA) hardware

  • Multicore

Multicore User-Level Thread Libraries MPC (MultiProcessor Communications): APIs: MPI 1.3, OpenMP 2.5, PThread

  • How to debug threads in this context?
slide-4
SLIDE 4

4 MTAAP 2010 CEA,DAM,DIF

Thread Libraries

slide-5
SLIDE 5

5 MTAAP 2010 CEA,DAM,DIF

Thread Libraries

slide-6
SLIDE 6

6 MTAAP 2010 CEA,DAM,DIF

Thread Libraries

  • Why using user-level thread libraries?

Thread scheduler in user-space: Can be specialized. Low-cost context switching. Portable.

  • MPC framework:

Thread-based MPI: each MPI task is converted a thread. POSIX Thread API and OpenMP API: efficient mix of threads and MPI Everything is a thread. Optimized scheduler: Integrated polling method. Collective communications.

slide-7
SLIDE 7

7 MTAAP 2010 CEA,DAM,DIF

User-Level Thread Libraries and Debugging

slide-8
SLIDE 8

8 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
slide-9
SLIDE 9

9 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
  • Request to the Thread_DB

library thanks to Thread_DB API

slide-10
SLIDE 10

10 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
  • Request to the Thread_DB

library thanks to Thread_DB API

  • Use the thread-library specific

implementation of Thread_DB

slide-11
SLIDE 11

11 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
  • Request to the Thread_DB

library thanks to Thread_DB API

  • Use the thread library specific

implementation of Thread_DB

  • Use the Proc_service API to

read into the process to debug

slide-12
SLIDE 12

12 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
  • Request to the Thread_DB

library thanks to Thread_DB API

  • Use the thread library specific

implementation of Thread_DB

  • Use the Proc_service API to

read into the process to debug

  • Return command results to the

debugger

slide-13
SLIDE 13

13 MTAAP 2010 CEA,DAM,DIF

Debugging Threads

  • User command
  • Request to the Thread_DB

library thanks to Thread_DB API

  • Use the thread library specific

implementation of Thread_DB

  • Use the Proc_service API to

read into the process to debug

  • Return command results to the

debugger Have to be implemented for each thread library

slide-14
SLIDE 14

14 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB

  • Example:

6 user threads 2 kernel threads

  • With GDB
  • Expected:

(gdb) info threads Thread 2 (LWP 2) in bar () Thread 1 (LWP 1) in foo () (gdb) info threads Thread 5 (LWP 2) in mpc_setjmp () Thread 4 (LWP 2) in bar () Thread 3 (LWP 1) in foo () Thread 2 (LWP 1) in mpc_setjmp () Thread 1 (LWP 1) in mpc_setjmp ()

slide-15
SLIDE 15

15 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB

  • Example:

6 user threads 2 kernel threads

  • With GDB
  • Expected:

(gdb) info threads Thread 2 (LWP 2) in bar () Thread 1 (LWP 1) in foo () (gdb) info threads Thread 5 (LWP 2) in mpc_setjmp () Thread 4 (LWP 2) in bar () Thread 3 (LWP 1) in foo () Thread 2 (LWP 1) in mpc_setjmp () Thread 1 (LWP 1) in mpc_setjmp ()

Blocked in the user scheduler Running thread

slide-16
SLIDE 16

16 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB

  • General case:

The user-level thread library uses the underlying POSIX Thread library. Debuggers use the libthread_db associated to the underlying POSIX Thread library. Debuggers ignore sleeping user thread. Debuggers only see running threads. => Need a specialized libthread_db for each user-level thread library and force the debugger to use it.

slide-17
SLIDE 17

17 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB on Linux

  • User command
slide-18
SLIDE 18

18 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB on Linux

  • User command
  • Use registers of the kernel

threads

slide-19
SLIDE 19

19 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB on Linux

  • User command
  • Use registers of the kernel

threads

  • Return command results to the

debugger

slide-20
SLIDE 20

20 MTAAP 2010 CEA,DAM,DIF

Debugging User-Level Threads with GDB on Linux

  • GDB on Linux do not use libthread_db correctly:

Skip the libthread_db library. Due to bugs in libthread_db implementation. Assume 1x1 threading model (true for Linux). => Need to patch GDB in order to use libthread_db correctly.

slide-21
SLIDE 21

21 MTAAP 2010 CEA,DAM,DIF

Our contribution: User Level DB

slide-22
SLIDE 22

22 MTAAP 2010 CEA,DAM,DIF

User Level DB Library Goals

  • Provide debugger support to user-level thread libraries.
  • Low development cost to support a new thread library.
  • Portable:

Thread libraries. Processors. Operating systems. Debuggers.

slide-23
SLIDE 23

23 MTAAP 2010 CEA,DAM,DIF

User Level DB Library Architecture

slide-24
SLIDE 24

24 MTAAP 2010 CEA,DAM,DIF

User Level DB Library

Provided by ULDB

slide-25
SLIDE 25

25 MTAAP 2010 CEA,DAM,DIF

User Level DB Library

Have to be implemented by each thread library

slide-26
SLIDE 26

26 MTAAP 2010 CEA,DAM,DIF

User Level DB API

  • /* Enable or disable the ULDB library */
  • tdb_err_e uldb_enable_lib_thread_db (void)
  • tdb_err_e uldb_disable_lib_thread_db (void)
  • /* Provide the offsets of x86 registers */
  • tdb_err_e uldb_set_eip_offset (size_t offset)
  • tdb_err_e uldb_set_esp_offset (size_t offset)
  • tdb_err_e uldb_set_ebp_offset (size_t offset)
  • tdb_err_e uldb_set_ebx_offset (size_t offset)
  • tdb_err_e uldb_set_edi_offset (size_t offset)
  • /* Provide a lock object and its accessors */
  • tdb_err_e uldb_set_lock (void *lock,int (*acquire) (void *),int (*release) (void *),int

(*lock_free) (void *))

slide-27
SLIDE 27

27 MTAAP 2010 CEA,DAM,DIF

User Level DB API

  • /* Add or remove a thread to the internal list */
  • uldb_add_thread (const void *tid, tdb_thread_debug_t **thread)
  • uldb_remove_thread (tdb_thread_debug_t *thread)
  • /* Report the events monitored by the debugger*/
  • uldb_report_creation_event (tdb_thread_debug_t *thread)
  • uldb_report_death_event (tdb_thread_debug_t *thread)
  • /* Provide the address of the context of a sleeping thread */
  • uldb_set_thread_context (tdb_thread_debug_t *thread, void *context)
slide-28
SLIDE 28

28 MTAAP 2010 CEA,DAM,DIF

User Level DB API

  • /* Provide further details about a thread (optional) */
  • uldb_set_thread_startfunc (tdb_thread_debug_t *thread, char *tls)
  • uldb_set_thread_stkbase (tdb_thread_debug_t *thread, void *stkbase)
  • uldb_set_thread_stksize (tdb_thread_debug_t *thread, int stksize)
  • uldb_set_thread_type (tdb_thread_debug_t *thread, td_thr_type_e type)
  • /* Provide the current LWP id / state (active or not) of a thread */
  • uldb_update_thread_lid (tdb_thread_debug_t *thread, lwpid_t lid)
  • uldb_update_thread_state (tdb_thread_debug_t *thread, td_thr_state_e

state)

slide-29
SLIDE 29

29 MTAAP 2010 CEA,DAM,DIF

Experimentations

  • Debuggers:

DBX: just set the environment variable _DBX_LIBTHREAD_DB_OVERRIDE to the path of the ULDB library. GDB: Create an environment variable GDB_LIBTHREAD_DB to select another libthread_db. GDB does not use correctly libthread_db. Rewrite the thread module part of GDB from the GDB Solaris support. All GDB-based frontend: DDD, Insight, Eclipse-Debug, DDT, ..

slide-30
SLIDE 30

30 MTAAP 2010 CEA,DAM,DIF

Experimentations

  • Thread libraries:

MPC MxN thread library. 600 lines of patch. GnuPTH Mx1 thread library. 100 lines of patch, less than a day. Marcel MxN thread library. 500 lines of patch, few weeks.

slide-31
SLIDE 31

31 MTAAP 2010 CEA,DAM,DIF

Experimentations

  • Architectures:

Operating system: Solaris. Linux. Processor: Sparc. X86. X86_64.

slide-32
SLIDE 32

32 MTAAP 2010 CEA,DAM,DIF

Conclusion & Future Work

slide-33
SLIDE 33

33 MTAAP 2010 CEA,DAM,DIF

Conclusion

  • ULDB allows to debug user-level thread.
  • ULDB is portable:

2 command line debuggers. 4 graphical frontends. 3 thread libraries. 3 processor types. 2 operating systems.

  • ULDB provides user-level threads with a low cost:

Very low level of expertise required. Small patches (< 1000 lines) for each thread library.

slide-34
SLIDE 34

34 MTAAP 2010 CEA,DAM,DIF

Future Work

  • Thread-synchronization debugging support:

ULDB API extension. GDB extension (part of the libthread_db not supported yet).

  • Debugging support of tasks in OpenMP 3.0:

An OpenMP task is almost a user thread. Currently not supported by GDB and the libthread_db. Contact: marc.perache@cea.fr, patrick.carribault@cea.fr http://mpc.sourceforge.net/