diff options
| author | Eli Zaretskii | 2016-09-05 19:32:21 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-09-05 19:32:21 +0300 |
| commit | 304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4 (patch) | |
| tree | fb86cd473a185a1fd1ca7b10afe822c4030cc223 /etc/DEBUG | |
| parent | 56bf7d7e274e1ab68c28516026d0510173c41904 (diff) | |
| download | emacs-304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4.tar.gz emacs-304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4.zip | |
; * etc/DEBUG: Improve documentation of getting control to GDB.
Suggested by Alain Schneble <a.s@realize.ch>.
Diffstat (limited to 'etc/DEBUG')
| -rw-r--r-- | etc/DEBUG | 71 |
1 files changed, 49 insertions, 22 deletions
| @@ -190,24 +190,40 @@ kick in, provided that you run under GDB. | |||
| 190 | 190 | ||
| 191 | ** Getting control to the debugger | 191 | ** Getting control to the debugger |
| 192 | 192 | ||
| 193 | Setting a breakpoint in a strategic place, after loading Emacs into | ||
| 194 | the debugger, but before running it, is the most efficient way of | ||
| 195 | making sure control will be returned to the debugger when you need | ||
| 196 | that. | ||
| 197 | |||
| 193 | 'Fsignal' is a very useful place to put a breakpoint in. All Lisp | 198 | 'Fsignal' is a very useful place to put a breakpoint in. All Lisp |
| 194 | errors go through there. If you are only interested in errors that | 199 | errors go through there. If you are only interested in errors that |
| 195 | would fire the debugger, breaking at 'maybe_call_debugger' is useful. | 200 | would fire the Lisp debugger, breaking at 'maybe_call_debugger' is |
| 201 | useful. | ||
| 196 | 202 | ||
| 197 | It is useful, when debugging, to have a guaranteed way to return to | 203 | Another technique for get control to the debugger is to put a |
| 198 | the debugger at any time. When using X, this is easy: type C-z at the | 204 | breakpoint in some rarely used function. One such convenient function |
| 199 | window where Emacs is running under GDB, and it will stop Emacs just | 205 | is Fredraw_display, which you can invoke at will interactively with |
| 200 | as it would stop any ordinary program. When Emacs is running in a | 206 | "M-x redraw-display RET". |
| 201 | terminal, things are not so easy. | 207 | |
| 208 | It is also useful to have a guaranteed way to return to the debugger | ||
| 209 | at any arbitrary time. When using X, this is easy: type C-z at the | ||
| 210 | window where you are interacting with GDB, and it will stop Emacs just | ||
| 211 | as it would stop any ordinary program. When Emacs is displaying on a | ||
| 212 | text terminal, things are not so easy, so we describe the various | ||
| 213 | alternatives below (however, those of them that use signals only work | ||
| 214 | on Posix systems). | ||
| 202 | 215 | ||
| 203 | The src/.gdbinit file in the Emacs distribution arranges for SIGINT | 216 | The src/.gdbinit file in the Emacs distribution arranges for SIGINT |
| 204 | (C-g in Emacs) to be passed to Emacs and not give control back to GDB. | 217 | (C-g in Emacs on a text-mode frame) to be passed to Emacs and not give |
| 205 | On modern POSIX systems, you can override that with this command: | 218 | control back to GDB. On modern systems, you can override that with |
| 219 | this command: | ||
| 206 | 220 | ||
| 207 | handle SIGINT stop nopass | 221 | handle SIGINT stop nopass |
| 208 | 222 | ||
| 209 | After this 'handle' command, SIGINT will return control to GDB. If | 223 | After this 'handle' command, SIGINT will return control to GDB. If |
| 210 | you want the C-g to cause a QUIT within Emacs as well, omit the 'nopass'. | 224 | you want the C-g to cause a QUIT within Emacs as well, omit the 'nopass'. |
| 225 | See the GDB manual for more details about signal handling and the | ||
| 226 | 'handle' command. | ||
| 211 | 227 | ||
| 212 | A technique that can work when 'handle SIGINT' does not is to store | 228 | A technique that can work when 'handle SIGINT' does not is to store |
| 213 | the code for some character into the variable stop_character. Thus, | 229 | the code for some character into the variable stop_character. Thus, |
| @@ -216,26 +232,37 @@ the code for some character into the variable stop_character. Thus, | |||
| 216 | 232 | ||
| 217 | makes Control-] (decimal code 29) the stop character. | 233 | makes Control-] (decimal code 29) the stop character. |
| 218 | Typing Control-] will cause immediate stop. You cannot | 234 | Typing Control-] will cause immediate stop. You cannot |
| 219 | use the set command until the inferior process has been started. | 235 | use the set command until the inferior process has been started, so |
| 220 | Put a breakpoint early in 'main', or suspend the Emacs, | 236 | start Emacs with the 'start' command, to get an opportunity to do the |
| 221 | to get an opportunity to do the set command. | 237 | above 'set' command. |
| 222 | 238 | ||
| 223 | Another technique for get control to the debugger is to put a | 239 | On a Posix host, you can also send a signal using the 'kill' command |
| 224 | breakpoint in some rarely used function. One such convenient function | 240 | from a shell prompt, like this: |
| 225 | is Fredraw_display, which you can invoke at will interactively with | ||
| 226 | "M-x redraw-display RET". | ||
| 227 | 241 | ||
| 228 | When Emacs is running in a terminal, it is sometimes useful to use a separate | 242 | kill -TSTP Emacs-PID |
| 229 | terminal for the debug session. This can be done by starting Emacs as usual, | ||
| 230 | then attaching to it from gdb with the 'attach' command which is explained in | ||
| 231 | the node "Attach" of the GDB manual. | ||
| 232 | 243 | ||
| 233 | On MS-Windows, you can start Emacs in its own separate terminal by | 244 | where Emacs-PID is the process ID of Emacs being debugged. Other |
| 234 | setting the new-console option before running Emacs under GDB: | 245 | useful signals to send are SIGUSR1 and SIGUSR2; see "Error Debugging" |
| 246 | in the ELisp manual for how to use those. | ||
| 247 | |||
| 248 | When Emacs is displaying on a text terminal, it is useful to have a | ||
| 249 | separate terminal for the debug session. This can be done by starting | ||
| 250 | Emacs as usual, then attaching to it from gdb with the 'attach' | ||
| 251 | command which is explained in the node "Attach" of the GDB manual. | ||
| 252 | |||
| 253 | On MS-Windows, you can alternatively start Emacs from its own separate | ||
| 254 | console by setting the new-console option before running Emacs under | ||
| 255 | GDB: | ||
| 235 | 256 | ||
| 236 | (gdb) set new-console 1 | 257 | (gdb) set new-console 1 |
| 237 | (gdb) run | 258 | (gdb) run |
| 238 | 259 | ||
| 260 | If you do this, then typing C-c or C-BREAK into the console window | ||
| 261 | through which you interact with GDB will stop Emacs and return control | ||
| 262 | to the debugger, no matter if Emacs displays GUI or text-mode frames. | ||
| 263 | This is the only reliable alternative on MS-Windows to get control to | ||
| 264 | the debugger, besides setting breakpoints in advance. | ||
| 265 | |||
| 239 | ** Examining Lisp object values. | 266 | ** Examining Lisp object values. |
| 240 | 267 | ||
| 241 | When you have a live process to debug, and it has not encountered a | 268 | When you have a live process to debug, and it has not encountered a |
| @@ -848,7 +875,7 @@ directed to the xterm window you opened above. | |||
| 848 | Similar arrangement is possible on a character terminal by using the | 875 | Similar arrangement is possible on a character terminal by using the |
| 849 | 'screen' package. | 876 | 'screen' package. |
| 850 | 877 | ||
| 851 | On MS-Windows, you can start Emacs in its own separate terminal by | 878 | On MS-Windows, you can start Emacs in its own separate console by |
| 852 | setting the new-console option before running Emacs under GDB: | 879 | setting the new-console option before running Emacs under GDB: |
| 853 | 880 | ||
| 854 | (gdb) set new-console 1 | 881 | (gdb) set new-console 1 |