| Article Index |
|---|
| GDB UPC Sample Sessions |
| Multiple Unix Processes |
| Single Unix Process |
| Multiple Posix Threads |
| Single Thread Debugging |
| All Pages |
Multiple Posix Threads
Pthreads implementation is another variant of GCC UPC run-time where each thread is mapped into pthreads instead of Unix processes. Pthreads run-time does not use UPC threads start-up synchronization.
Compile Options
-g -O0 -dwarf-2-upc -fupc-pthreads-model-tls
Debugging Options
set pagination off set target-async on set detach-on-fork off set non-stop on
Sample Debugging Session
Compile example code (static or dynamic thread allocation can be used):
$ upc -fupc-threads-4 -fupc-pthreads-model-tls -g -O0 -dwarf-2-upc \
-o upc-example upc-example.upc
Create GDB's startup file .gdbinitin the current directory with the following content:
set pagination off set target-async on set detach-on-fork off set non-stop on
Note: You may choose to create some other file instead of .gdbinit. In this case you will need to run GDB UPC with "-x your-startup-file" option.
Note: GDB UPC upcstartgate option is not necessary as one thread GCC UPC run-time does not uses thread synchronization mechanism.
Specify UPC Debugging Assistant shared library for GCC UPC compiler:
csh shell: $ setenv UDA_GUPC_PLUGIN_LIBRARY [...]/plugin/uda-plugin.so bash shell: $ UDA_GUPC_PLUGIN_LIBRARY=[...]/plugin/uda-plugin.so $ export UDA_GUPC_PLUGIN_LIBRAR
Make sure that GDB on your path is indeed GDB UPC. For example:
$ gdb -v GNU gdb (GDB) 7.1.50.2 20100918 (GDB UPC/dev) Copyright (C) 2010 Free Software Foundation, Inc. [...]
For bug reporting instructions, please see: [...]
At this point you can start your debugging session.
$ gdb upc_example [...] (gdb) b upc_main Breakpoint 1 at 0x4016cd: file upc-example.upc, line 23. (gdb) r [Thread debugging using libthread_db enabled] upc_lang: using GUPC plugin. [New UPC Thread 0] [New UPC Thread 1] [New UPC Thread 2] [New UPC Thread 3] Breakpoint 1, main () at upc-example.upc:23 23 if (!MYTHREAD) Current language:· auto The current source language is "auto; currently upc". Breakpoint 1, main () at upc-example.upc:23 23 if (!MYTHREAD) Breakpoint 1, main () at upc-example.upc:23 23 if (!MYTHREAD) Breakpoint 1, main () at upc-example.upc:23 23 if (!MYTHREAD) Starting program: /eng/upc/dev/nenad/GDB UPC-dev/examples/upc-example Breakpoint 1, main () at upc-example.upc:23 23 if (!MYTHREAD)
Current language:· auto The current source language is "auto; currently upc". (gdb)
At this point all of the UPC threads are running, however as GDB UPC is still in the GDB mode, all threads report a breakpoint event.· Execute upc-sync command to switch debugging into the UPC mode.
(gdb) upc-sync UPC Mode activated. (gdb-upc) info threads 3 UPC Thread 3· main () at upc-example.upc:23 2 UPC Thread 2· main () at upc-example.upc:23 1 UPC Thread 1· main () at upc-example.upc:23 * 0 UPC Thread 0· main () at upc-example.upc:23 (gdb-upc)
Continue debugging of your program.








