Here's how to run the debugger on realtime code in the "unified-build-candidate3" branch from linuxcnc.org. This assumes you are using a run-in-place tree with a userspace realtime model, and that you understand the basics of gdb.

First, start realtime, e.g.,

$ halrun
halrun:

Now, in a second terminal, attach to the rtapi process with your debugger and set a breakpoint or whatever, then continue (if you want to debug a segfault then you can just continue; gdb will break when the fault occurs):

$ sudo gdb -p `pidof rtapi:0`
…
(gdb) b export_siggen
Function "export_siggen" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (export_siggen) pending.
(gdb) c
Continuing.

Back in the first terminal, do whatever it takes to reach your breakpoint:

halrun: loadrt siggen
Waiting for component 'siggen' to become ready..........

Now in the debugger, you've stopped:

Breakpoint 1, export_siggen (num=0, addr=0x7f7f517ef458, 
    prefix=0x7fff07fde416 "siggen.0") at hal/components/siggen.c:273
273	{
(gdb) p *addr
$1 = {square = 0x0, sawtooth = 0x0, triangle = 0x0, sine = 0x0, cosine = 0x0, 
  clock = 0x0, frequency = 0x0, amplitude = 0x0, offset = 0x0, index = 0}
(gdb) continue

Of course, any time you break in gdb you lose realtime, but the debugger is still useful. Probably (I haven't tested this :-P) it's useful for debugging some crashes that would leave you with a system that required rebooting to unload modules under the old kernel-only realtime system of the master branch.

Extra tip: you can use the "rt-preempt" flavor on a plain old kernel by

$ env FLAVOR=rt-preempt halrun
but of course you don't get the realtime performance.