Remove typechecker-only options from GlobalOptions to avoid code duplication
[hiphop-php.git] / hphp / doc / debug.gdb
blob89fdba4d2a8831fb9d484cc4fc51302cfdb33aff
2 <h2>Useful gdb Commands</h2>
4   info threads
5   thread apply [threadno] [all] args
6   set follow-fork-mode parent
7   set detach-on-fork on
8   set print pretty
9   handle SIGPIPE nostop noprint pass
10   dump binary memory [filename] [start_addr] [end_addr]
11   symbol-file [un-stripped binary OR symbol file from strip]
13 =  b main.no.cpp:55
15 If you get "Couldn't get registers" error when starting a program with gdb,
16 instead of attaching to a running process, this is because gdb has a bug,
17 not able to switch to the main thread/process when it forks:
19   [Thread debugging using libthread_db enabled]
20   [New Thread 46912496246512 (LWP 30324)]
21   [New Thread 1084229952 (LWP 30327)]
22   [Thread 1084229952 (LWP 30327) exited]
23   Couldn't get registers: No such process.
25 Set a break point at line 55 of main.no.cpp, then "r", you will get this,
27   [Thread debugging using libthread_db enabled]
28   [New Thread 46912496246512 (LWP 30632)]
29   [New Thread 1084229952 (LWP 30636)]
30   [Thread 1084229952 (LWP 30636) exited]
31   <b>[Switching to Thread 46912496246512 (LWP 30632)]</b>
33   Breakpoint 1, main (argc=3, argv=0x7fff41b5b138) at sys/main.no.cpp:55
34   55        return HPHP::execute_program(argc, argv);
35   (gdb) c
37 Magically, gdb is able to switch to main thread, attaching to it, then it will
38 be able to debug it, even if it forks afterwards.
40 <h2> Getting PHP symbols in the JIT under gdb </h2>
42 The VM periodically emits DWARF files containing function address
43 information for the JIT code it generates. These DWARF files are synced with gdb
44 asynchronously (by default every ~128 tracelets). This means that the backtrace
45 you see under gdb  may contain some unresolved PHP symbols that show up as ??s,
46 for symbols that have not been synced.
48 There are three ways to resolve this:
50 1. pass -v Eval.GdbSyncChunks=1 in the command line. This forces the VM to sync
51 debug info synchronously with gdb.
53 2. call HPHP::g_context.m_node.m_p->syncGdbState() from the gdb CLI. This
54 forces a manual sync of all outstanding symbols to gdb.
56 3. if the program has hit a seg fault (or another signal), press continue on
57 the CLI. The HHVM signal handler will sync outstanding DWARF symbols to gdb,
58 and a subsequent 'bt' should show all symbols.