X11workbench Toolkit  1.0
gdb_helper.c
1 // //
3 // _ _ _ _ //
4 // __ _ __| || |__ | |__ ___ | | _ __ ___ _ __ ___ //
5 // / _` | / _` || '_ \ | '_ \ / _ \| || '_ \ / _ \| '__|/ __| //
6 // | (_| || (_| || |_) | | | | || __/| || |_) || __/| | _| (__ //
7 // \__, | \__,_||_.__/_____|_| |_| \___||_|| .__/ \___||_|(_)\___| //
8 // |___/ |_____| |_| //
9 // //
11 
12 /*****************************************************************************
13 
14  X11workbench - X11 programmer's 'work bench' application and toolkit
15  Copyright (c) 2010-2018 by Bob Frazier (aka 'Big Bad Bombastic Bob')
16  all rights reserved
17 
18  DISCLAIMER: The X11workbench application and toolkit software are supplied
19  'as-is', with no warranties, either implied or explicit.
20 
21  BSD-like license:
22 
23  There is no restriction as to what you can do with this software, so long
24  as you include the above copyright notice and DISCLAIMER for any distributed
25  work that is linked with, equivalent to, or derived from any portion of this
26  software, along with this paragraph that explains the terms of the license if
27  the source is also being made available. "Linked with" includes the use of a
28  portion of any of the source and/or header files, or their compiled binary
29  output, as a part of your application or library. A "derived work"
30  describes a work that uses a significant portion of the source files or the
31  algorithms that are included with this software.
32 
33  EXCLUSIONS
34 
35  Specifically excluded from this requirement are files that were generated by
36  the software, or anything that is included with the software that is part of
37  another package (such as files that were created or added during the
38  'configure' process).
39 
40  DISTRIBUTION
41 
42  The license also covers the use of part or all of any of the X11 workbench
43  toolkit source or header files in your distributed application, in source or
44  binary form. If you do not ship the source, the above copyright statement
45  and DISCLAIMER is still required to be placed in a reasonably prominent
46  place, such as documentation, splash screens, and/or 'about the application'
47  dialog boxes.
48 
49  Use and distribution are in accordance with GPL, LGPL, and/or the above
50  BSD-like license. See COPYING and README.md files for more information.
51 
52  Additionally, this software, in source or binary form, and in whole or in
53  part, may be used by explicit permission from the author, without the need
54  of a license.
55 
56  Additional information at http://sourceforge.net/projects/X11workbench
57  and http://bombasticbob.github.io/X11workbench/
58 
59 ******************************************************************************/
60 
61 
62 
63 #include "X11workbench.h"
64 #include "gdb_helper.h"
65 
66 #include "platform_helper.h"
67 
68 
69 // NOTES:
70 //
71 // command line gdb {executable} where '{executable}' is the binary executable file
72 //
73 // (NOTE: output of 'gdb' typically ends with the text "(gdb)" which then waits for input)
74 //
75 // commands from within gdb that should be useful:
76 //
77 // set height 0
78 // this will eliminate the "Type <return> to continue, or q <return> to quit" prompting
79 //
80 //
81 // list ,main
82 // this will set the 'main()' source file as "current source" and allow 'info source' to work
83 //
84 // info source
85 // information on the 'current' source file being displayed. output similar to this:
86 // Current source file is X11workbench.c
87 // Compilation directory is /d-drive/SecureStorage/root/source/X11workbench
88 // Located in /d-drive/SecureStorage/root/source/X11workbench/X11workbench.c
89 // Contains 2306 lines.
90 // Source language is c.
91 // Compiled with DWARF 2 debugging format.
92 // Does not include preprocessor macro info.
93 //
94 //
95 // To get a list of all files/functions, use 'info function' and then pick a function to load via 'list ,function'
96 //
97 //
98 // **NOTE** - the debugger source path is the canonical one, not necessarily the one for the file(s) being edited,
99 // so use WBGetCanonicalPath() to make sure that I compare the path names correctly for open files.
100 //
101 //
102 // info sources
103 // information on ALL source files. output similar to this:
104 // Source files for which symbols have been read in:
105 //
106 // X11workbench.c, file_help.h, window_helper.h
107 //
108 // Source files for which symbols will be read in on demand:
109 //
110 // dialog_controls.c, dialog_window.c, clipboard_helper.c, text_object.c, platform_helper.c, window_dressing.c, draw_text.c,
111 // file_help.c, conf_help.c, menu_popup.c, menu_bar.c, menu.c, dialog_support.c, dialog_impl.c, frame_window.c, child_frame.c,
112 // edit_window.c, font_helper.c, window_helper.c, pixmap_helper.c, gizzard.c
113 //
114 //
115 // info function:
116 //
117 // command: info function WBInit\b <-- the '\b' causes an exact match
118 //
119 // output:
120 //
121 // All functions matching regular expression "WBInit\b":
122 //
123 // File window_helper.c:
124 // Display *WBInit(const char *);
125 //
126 //
127 // info functions
128 // this gives you a list of ALL functions and the source files that define them. example:
129 //
130 // All defined functions:
131 //
132 // File pixmap_helper.c:
133 // Pixmap PXM_GetIconPixmap(int, XPM_ATTRIBUTES *, Pixmap *);
134 // Pixmap PXM_GetIconPixmapFromAtom(Atom, XPM_ATTRIBUTES *, Pixmap *);
135 // ...
136 // static int clip255(int);
137 //
138 // File font_helper.c:
139 // XFontStruct *WBCopyFont(XFontStruct *);
140 // XFontSet WBCopyModifyFontSet(Display *, XFontSet, int, int);
141 // void WBDumpFontInfo(const char *);
142 // int WBFontAvgCharWidth(Display *, const XFontStruct *);
143 // ...
144 //
145 // etc.
146 //
147 // the list will include static functions appropriate to each source file, and ends with
148 // a bunch of addresses labeled 'non-debugging symbols':
149 //
150 // Non-debugging symbols:
151 // 0x0000000000404248 _init
152 // 0x000000000040426c XSetInputFocus
153 // 0x000000000040427c XFreePixmap
154 // ...
155 // 0x0000000000405070 _start
156 // 0x0000000000405110 __do_global_dtors_aux
157 // 0x0000000000405150 frame_dummy
158 // 0x0000000000453f80 __do_global_ctors_aux
159 // 0x0000000000453fb4 _fini
160 //
161 // Apparently, none of these have source available (typically contained in a linked-to library)
162 //
163 //
164 //
165 // other commands like list, backtrace, breakpoint, etc. can be applied as needed.
166 //
167 //
168 //
169 // ------------------------------
170 // Server/mouse/keyboard grabbing
171 // ------------------------------
172 //
173 // If XGrabServer() has been called, then everything will appear to freeze up during breakpoint handling.
174 // If XGrabKeyoard() or XGrabPointer() have been called, the kb/mouse will appear to freeze up.
175 //
176 // Additionally, calling XGrabKeyoard() or XGrabPointer() on the application window (for example) would
177 // return 'AlreadyGrabbed' if a grab is already in effect. it might be prudent to grab the keyboard/mouse
178 // this way whenever a breakpoint is reached, in order to avoid deadlocking the system.
179 //
180 // Alternately, a watchdog timer could call XUngrabServer() after a time period, using event handling (in general)
181 // to detect that no events are being received. A watchdog COULD post a client event to the main window via a
182 // timer, and then detect whether the event has arrived.
183 //
184 // Without additional info, the grab won't be "restorable" on return from the breakpoint. An
185 // appropriate warning message should appear if the debugger has to 'Ungrab' something.
186 //
187 
188 
189 
190 
Definition file for platform-specific utility functions.