Skip to content

Commit 7b22389

Browse files
committed
add radix choices cs01#102; Parse gdb version from arm-non-eabi-gdb (cs01#83); various improvements
1 parent 7172264 commit 7b22389

33 files changed

+302
-235
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## dev
44
Changes that are in master but have not yet been pushed to pyPI (pip)
5-
* Rewrite all components to React
6-
* Add component to send signals to inferior program
5+
* Add ability to change radix of variables (issue #102)
6+
* Add component to send signals to inferior program (issues #31, #90)
7+
* Parse gdb version from arm-non-eabi-gdb (issue #83)
8+
* Rewrite most components to React (issue #17)
79
* Improve CSS in various components
810

911
## 0.7.9.5

HELP.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# gdbgui help
2-
You can get help using gdbgui in several different ways.
32

43
### How to use
54
* Read documentation on the [homepage](https://github.com/cs01/gdbgui/)
65
* Watch videos on the [YouTube channel](https://www.youtube.com/channel/UCUCOSclB97r9nd54NpXMV5A)
7-
* Join the [gitter chat room](https://gitter.im/gdbgui/Lobby)
8-
* [Create an issue on github](https://github.com/cs01/gdbgui/issues)
6+
* Ask a question in the [gdbui chat room](https://gitter.im/gdbgui/Lobby)
7+
* [Ask question in an issue on github](https://github.com/cs01/gdbgui/issues)
98

109
### Report a bug / Request a feature
1110
* Read [CONTRIBUTING.md](https://github.com/cs01/gdbgui/blob/master/CONTRIBUTING.md), then [create an issue on github]('https://github.com/cs01/gdbgui/issues')
1211

1312
### Fix a bug / Add a feature
1413
* See [CONTRIBUTING.md](https://github.com/cs01/gdbgui/blob/master/CONTRIBUTING.md)
1514
* Join the [gitter chat room](https://gitter.im/gdbgui/Lobby)
16-
17-
### Learn more about gdb
18-
* [Using GNU's GDB Debugger - Memory Layout And The Stack](http://dirac.org/linux/gdb/02a-Memory_Layout_And_The_Stack.php) by Peter Jay Salzman

README.rst

+6-93
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A browser-based frontend for GDB
1313
.. image:: https://img.shields.io/badge/python-2.7,3.4,3.5,3.6,pypy-blue.svg
1414
:target: https://pypi.python.org/pypi/gdbgui/
1515

16-
A modern, browser-based frontend to gdb (gnu debugger). Add breakpoints, view stack traces, and more in C, C++, Go, and Rust! Simply run ``gdbgui`` from the terminal and a new tab will open in your browser. `Screenshots <https://github.com/cs01/gdbgui#screenshots>`_ are below, or check out the `YouTube channel <https://www.youtube.com/channel/UCUCOSclB97r9nd54NpXMV5A>`_ or `Help page <https://github.com/cs01/gdbgui/blob/master/HELP.md>`_ for demos and tutorials.
16+
A modern, browser-based frontend to gdb (gnu debugger). Add breakpoints, view stack traces, and more in C, C++, Go, and Rust! Simply run ``gdbgui`` from the terminal and a new tab will open in your browser. `See SCREENSHOTS.md <https://github.com/cs01/gdbgui/SCREENSHOTS.md>`_, or check out the `YouTube channel <https://www.youtube.com/channel/UCUCOSclB97r9nd54NpXMV5A>`_ or `Help page <https://github.com/cs01/gdbgui/blob/master/HELP.md>`_ for demos and tutorials.
1717

1818
If you are using gdbgui in a commercial setting, `consider donating to the project <https://paypal.me/grassfedcode/20>`_.
1919

@@ -158,6 +158,9 @@ If your program exits unexpectedly from something like a SEGFAULT, ``gdbgui`` di
158158
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/SIGSEGV.png
159159
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/SIGSEGV.png
160160

161+
Screenshots
162+
-----------
163+
`See SCREENSHOTS.md <https://github.com/cs01/gdbgui/SCREENSHOTS.md>`_
161164

162165
License
163166
-------
@@ -167,8 +170,8 @@ pyPI and this github page are the only official sources of gdbgui.
167170

168171
How Does it Work?
169172
-----------------
170-
1. The `pygdbmi library <https://github.com/cs01/pygdbmi>`__ manages gdb as a subprocess, and returns structured data to the frontend.
171-
2. The `Flask-SocketIO <https://flask-socketio.readthedocs.io/en/latest/>`__ server (Flask+websockets) serves the webpage and provides realtime interactivity. http/websocket endpoints are available for the browser. Each websocket connection (browser tab) runs a pygdbmi-managed instance of gdb. A separate coroutine/thread continuously parses and forwards gdb's output to the browser.
173+
1. The `pygdbmi library <https://github.com/cs01/pygdbmi>`_ manages gdb as a subprocess, and returns structured data to the frontend.
174+
2. The `Flask-SocketIO <https://flask-socketio.readthedocs.io/en/latest/>`_ server (Flask+websockets) serves the webpage and provides realtime interactivity. http/websocket endpoints are available for the browser. Each websocket connection (browser tab) runs a pygdbmi-managed instance of gdb. A separate coroutine/thread continuously parses and forwards gdb's output to the browser.
172175
3. The browser manages its ui with mostly vanilla JavaScript and some libraries.
173176

174177
The main components of gdbgui are
@@ -186,96 +189,6 @@ The main components of gdbgui are
186189
4. ``gdbgui.css``: css stylesheet
187190

188191

189-
Screenshots
190-
-----------
191-
Enter the binary and args just as you'd call them on the command line. Binary is restored when gdbgui is opened at a later time.
192-
193-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png
194-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png
195-
196-
Intuitive control of your program. From left to right: Run, Continue, Next, Step, Return, Next Instruction, Step Instruction, send interrupt signal (SIGINT) to inferior process.
197-
198-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png
199-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png
200-
201-
Stack/Threads
202-
-------------------------
203-
View all threads, the full stack on the active thread, the current frame on inactive threads. Switch between frames on the stack, or threads by pointing and clicking.
204-
205-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png
206-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png
207-
208-
Source Code
209-
-----------
210-
View source, assembly, add breakpoints. All symbols used to compile the target are listed in a dropdown above the source code viewer, and have autocompletion capabilities.
211-
212-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/source.png
213-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/source.png
214-
215-
With assembly. Note the bold line is the current instruction that gdb is stopped on.
216-
217-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png
218-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png
219-
220-
221-
Variables and Expressions
222-
-------------------------
223-
224-
All local variables are automatically displayed, and are clickable to explore their fields.
225-
226-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png
227-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png
228-
229-
Hover over a variable and explore it, just like in the Chrome debugger.
230-
231-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png
232-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png
233-
234-
235-
Arbitrary expressions can be evaluated as well.
236-
237-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png
238-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png
239-
240-
Expressions record their previous values, and can be displayed in an x/y plot.
241-
242-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png
243-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png
244-
245-
Expressions can be interactively explored in a tree view.
246-
247-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png
248-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png
249-
250-
Memory Viewer
251-
-------------
252-
All hex addresses are automatically converted to clickable links to explore memory. Length of memory is configurable. In this case 16 bytes are displayed per row.
253-
254-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png
255-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png
256-
257-
258-
Registers
259-
---------
260-
View all registers. If a register was updated it is highlighted in yellow.
261-
262-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png
263-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png
264-
265-
266-
gdb console
267-
-----------
268-
Read gdb output, and write to the gdb subprocess as desired. Don't let any gdb commandline skills you've developed go to waste.
269-
270-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/console.png
271-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/console.png
272-
273-
274-
gdbgui at launch:
275-
276-
.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png
277-
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png
278-
279192
Contributing
280193
------------
281194

SCREENSHOTS.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Screenshots
2+
3+
Enter the binary and args just as you'd call them on the command line.
4+
Binary is restored when gdbgui is opened at a later time.
5+
6+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png)
7+
8+
Intuitive control of your program. From left to right: Run, Continue,
9+
Next, Step, Return, Next Instruction, Step Instruction.
10+
11+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png)
12+
13+
## Stack/Threads
14+
15+
View all threads, the full stack on the active thread, the current frame
16+
on inactive threads. Switch between frames on the stack, or threads by
17+
pointing and clicking.
18+
19+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png)
20+
21+
## Send Signal to Inferior
22+
Choose from any signal your OS supports to send to the inferior. For example, to mock `CTRL+C` in plain gdb, you can send `SIGINT` to interrupt the inferior process. If the inferior process is hung for some reason, you can send `SIGKILL`, etc.
23+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/send_signal.png)
24+
25+
Signals are also recognized by `gdbgui`, and a button is presented to let you step back into the program and inspect the program's state in case it exits unexpectedly.
26+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/SIGSEV.png)
27+
28+
29+
## Source Code
30+
View source, assembly, add breakpoints. All symbols used to compile the
31+
target are listed in a dropdown above the source code viewer, and have
32+
autocompletion capabilities. There are two different color schemes: dark (monokai), and a light theme (default).
33+
34+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/source.png)
35+
36+
With assembly. Note the bold line is the current instruction that gdb is
37+
stopped on.
38+
39+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png)
40+
41+
If the source file is not found, it will display assembly, and allow you to step through it as desired.
42+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/assembly.png)
43+
44+
45+
## Variables and Expressions
46+
47+
All local variables are automatically displayed, and are clickable to
48+
explore their fields.
49+
50+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png)
51+
52+
Hover over a variable and explore it, just like in the Chrome debugger.
53+
54+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png)
55+
56+
Arbitrary expressions can be evaluated as well. These expressions persist as the program is stepped through. The base/radix can be modified as desired.
57+
58+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png)
59+
60+
Expressions record their previous values, and can be displayed in an x/y
61+
plot.
62+
63+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png)
64+
65+
Expressions can be interactively explored in a tree view.
66+
67+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png)
68+
69+
70+
## Memory Viewer
71+
72+
All hex addresses are automatically converted to clickable links to
73+
explore memory. Length of memory is configurable. In this case 10 bytes
74+
are displayed per row.
75+
76+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png)
77+
78+
## Registers
79+
80+
View all registers. If a register was updated it is highlighted in
81+
yellow.
82+
83+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png)
84+
85+
## gdb console
86+
87+
Read gdb output, and write to the gdb subprocess as desired. Don't let
88+
any gdb commandline skills you've developed go to waste.
89+
90+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/console.png)
91+
92+
## gdbgui at launch
93+
94+
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png)
95+
96+

examples/c/threads.c

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
#include <pthread.h>
22
#include <stdio.h>
33

4+
static const int num_increments = 2;
5+
46
/* this function is run by the second thread */
5-
void *inc_x(void *x_void_ptr)
7+
void *thread_callback(void *arg)
68
{
7-
8-
/* increment x to 100 */
9-
int *x_ptr = (int *)x_void_ptr;
10-
while(++(*x_ptr) < 2);
11-
12-
printf("x increment finished\n");
13-
14-
/* the function must return something - NULL will do */
15-
return NULL;
16-
9+
int *val = (int*)arg;
10+
while((*val) < num_increments){
11+
printf("incrementing\n");
12+
(*val)++;
13+
}
14+
printf("increment finished\n");
1715
}
1816

1917
int main()
2018
{
2119
int x = 0, y = 0;
22-
/* show the initial values of x and y */
2320
printf("x: %d, y: %d\n", x, y);
24-
/* this variable is our reference to the second thread */
25-
pthread_t inc_x_thread;
21+
pthread_t thread_to_increment_x, thread_to_increment_y;
2622

27-
/* create a second thread which executes inc_x(&x) */
28-
if(pthread_create(&inc_x_thread, NULL, inc_x, &x)) {
29-
fprintf(stderr, "Error creating thread\n");
23+
/* create and run threads */
24+
if(pthread_create(&thread_to_increment_x, NULL, thread_callback, &x)) {
25+
printf("error: pthread_create returned non-zero value\n");
3026
return 1;
3127
}
32-
33-
/* increment y to 100 in the first thread */
34-
while(++y < 2);
35-
printf("y increment finished\n");
36-
37-
/* wait for the second thread to finish */
38-
if(pthread_join(inc_x_thread, NULL)) {
39-
fprintf(stderr, "Error joining thread\n");
40-
return 2;
28+
if(pthread_create(&thread_to_increment_y, NULL, thread_callback, &y)) {
29+
printf("error: pthread_create returned non-zero value\n");
30+
return 1;
4131
}
4232

43-
/* show the results - x is now 100 thanks to the second thread */
33+
/* wait for threads to finish */
34+
if(pthread_join(thread_to_increment_x, NULL)) {
35+
printf("error: pthread_join returned non-zero value\n");
36+
return 1;
37+
}
38+
if(pthread_join(thread_to_increment_y, NULL)) {
39+
printf("error: pthread_join returned non-zero value\n");
40+
return 1;
41+
}
4442
printf("x: %d, y: %d\n", x, y);
4543

4644
return 0;

gdbgui/src/js/Actions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {store} from './store.js';
22
import GdbApi from './GdbApi.js';
33
import SourceCode from './SourceCode.jsx';
44
import Locals from './Locals.jsx';
5+
import Memory from './Memory.jsx';
56
import constants from './constants.js';
67

78
const Actions = {
@@ -12,7 +13,7 @@ const Actions = {
1213
store.set('current_thread_id', undefined)
1314
store.set('stack', [])
1415
store.set('threads', [])
15-
store.set('memory_cache', {})
16+
Memory.clear_cache()
1617
Locals.clear()
1718
},
1819
inferior_program_running: function(){

gdbgui/src/js/Breakpoints.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class Breakpoints extends React.Component {
166166
static has_breakpoint(fullname, line){
167167
let bkpts = store.get('breakpoints')
168168
for (let b of bkpts){
169-
console.log(b)
170169
if (b.fullname === fullname && b.line == line){
171170
return true
172171
}

gdbgui/src/js/FileOps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ const FileOps = {
317317
let cached_source_files = store.get('cached_source_files')
318318
for (let cached_file of cached_source_files){
319319
if(cached_file.fullname === fullname){
320-
cached_file.assembly = $.extend(true, cached_file.assembly, assembly_to_save)
320+
cached_file.assembly = Object.assign(cached_file.assembly, assembly_to_save)
321321

322322
let max_assm_line = Math.max(Object.keys(cached_file.assembly))
323323

0 commit comments

Comments
 (0)