Skip to content

Commit

Permalink
add radix choices #102; Parse gdb version from arm-non-eabi-gdb (#83)…
Browse files Browse the repository at this point in the history
…; various improvements
  • Loading branch information
cs01 committed Oct 30, 2017
1 parent 7172264 commit 88b4843
Show file tree
Hide file tree
Showing 32 changed files with 298 additions and 234 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,8 +2,10 @@

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

## 0.7.9.5
Expand Down
8 changes: 2 additions & 6 deletions HELP.md
@@ -1,18 +1,14 @@
# gdbgui help
You can get help using gdbgui in several different ways.

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

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

### Fix a bug / Add a feature
* See [CONTRIBUTING.md](https://github.com/cs01/gdbgui/blob/master/CONTRIBUTING.md)
* Join the [gitter chat room](https://gitter.im/gdbgui/Lobby)

### Learn more about gdb
* [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
99 changes: 6 additions & 93 deletions README.rst
Expand Up @@ -13,7 +13,7 @@ A browser-based frontend for GDB
.. image:: https://img.shields.io/badge/python-2.7,3.4,3.5,3.6,pypy-blue.svg
:target: https://pypi.python.org/pypi/gdbgui/

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.
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.

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

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

Screenshots
-----------
`See SCREENSHOTS.md <https://github.com/cs01/gdbgui/SCREENSHOTS.md>`_

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

How Does it Work?
-----------------
1. The `pygdbmi library <https://github.com/cs01/pygdbmi>`__ manages gdb as a subprocess, and returns structured data to the frontend.
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.
1. The `pygdbmi library <https://github.com/cs01/pygdbmi>`_ manages gdb as a subprocess, and returns structured data to the frontend.
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.
3. The browser manages its ui with mostly vanilla JavaScript and some libraries.

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


Screenshots
-----------
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.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png

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.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png

Stack/Threads
-------------------------
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.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png

Source Code
-----------
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.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/source.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/source.png

With assembly. Note the bold line is the current instruction that gdb is stopped on.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png


Variables and Expressions
-------------------------

All local variables are automatically displayed, and are clickable to explore their fields.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png

Hover over a variable and explore it, just like in the Chrome debugger.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png


Arbitrary expressions can be evaluated as well.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png

Expressions record their previous values, and can be displayed in an x/y plot.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png

Expressions can be interactively explored in a tree view.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png

Memory Viewer
-------------
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.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png


Registers
---------
View all registers. If a register was updated it is highlighted in yellow.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png


gdb console
-----------
Read gdb output, and write to the gdb subprocess as desired. Don't let any gdb commandline skills you've developed go to waste.

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/console.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/console.png


gdbgui at launch:

.. image:: https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png
:target: https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png

Contributing
------------

Expand Down
96 changes: 96 additions & 0 deletions SCREENSHOTS.md
@@ -0,0 +1,96 @@
# Screenshots

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.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/load_binary_and_args.png)

Intuitive control of your program. From left to right: Run, Continue,
Next, Step, Return, Next Instruction, Step Instruction.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/controls.png)

## Stack/Threads

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.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/stack_and_threads.png)

## Send Signal to Inferior
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.
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/send_signal.png)

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.
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/SIGSEV.png)


## Source Code
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. There are two different color schemes: dark (monokai), and a light theme (default).

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/source.png)

With assembly. Note the bold line is the current instruction that gdb is
stopped on.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/source_with_assembly.png)

If the source file is not found, it will display assembly, and allow you to step through it as desired.
![image](https://github.com/cs01/gdbgui/raw/master/screenshots/assembly.png)


## Variables and Expressions

All local variables are automatically displayed, and are clickable to
explore their fields.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/locals.png)

Hover over a variable and explore it, just like in the Chrome debugger.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/hover.png)

Arbitrary expressions can be evaluated as well. These expressions persist as the program is stepped through. The base/radix can be modified as desired.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/expressions.png)

Expressions record their previous values, and can be displayed in an x/y
plot.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/plots.png)

Expressions can be interactively explored in a tree view.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/tree_explorer.png)


## Memory Viewer

All hex addresses are automatically converted to clickable links to
explore memory. Length of memory is configurable. In this case 10 bytes
are displayed per row.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/memory.png)

## Registers

View all registers. If a register was updated it is highlighted in
yellow.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/registers.png)

## gdb console

Read gdb output, and write to the gdb subprocess as desired. Don't let
any gdb commandline skills you've developed go to waste.

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/console.png)

## gdbgui at launch

![image](https://github.com/cs01/gdbgui/raw/master/screenshots/ready.png)


52 changes: 25 additions & 27 deletions examples/c/threads.c
@@ -1,46 +1,44 @@
#include <pthread.h>
#include <stdio.h>

static const int num_increments = 2;

/* this function is run by the second thread */
void *inc_x(void *x_void_ptr)
void *thread_callback(void *arg)
{

/* increment x to 100 */
int *x_ptr = (int *)x_void_ptr;
while(++(*x_ptr) < 2);

printf("x increment finished\n");

/* the function must return something - NULL will do */
return NULL;

int *val = (int*)arg;
while((*val) < num_increments){
printf("incrementing\n");
(*val)++;
}
printf("increment finished\n");
}

int main()
{
int x = 0, y = 0;
/* show the initial values of x and y */
printf("x: %d, y: %d\n", x, y);
/* this variable is our reference to the second thread */
pthread_t inc_x_thread;
pthread_t thread_to_increment_x, thread_to_increment_y;

/* create a second thread which executes inc_x(&x) */
if(pthread_create(&inc_x_thread, NULL, inc_x, &x)) {
fprintf(stderr, "Error creating thread\n");
/* create and run threads */
if(pthread_create(&thread_to_increment_x, NULL, thread_callback, &x)) {
printf("error: pthread_create returned non-zero value\n");
return 1;
}

/* increment y to 100 in the first thread */
while(++y < 2);
printf("y increment finished\n");

/* wait for the second thread to finish */
if(pthread_join(inc_x_thread, NULL)) {
fprintf(stderr, "Error joining thread\n");
return 2;
if(pthread_create(&thread_to_increment_y, NULL, thread_callback, &y)) {
printf("error: pthread_create returned non-zero value\n");
return 1;
}

/* show the results - x is now 100 thanks to the second thread */
/* wait for threads to finish */
if(pthread_join(thread_to_increment_x, NULL)) {
printf("error: pthread_join returned non-zero value\n");
return 1;
}
if(pthread_join(thread_to_increment_y, NULL)) {
printf("error: pthread_join returned non-zero value\n");
return 1;
}
printf("x: %d, y: %d\n", x, y);

return 0;
Expand Down
3 changes: 2 additions & 1 deletion gdbgui/src/js/Actions.js
Expand Up @@ -2,6 +2,7 @@ import {store} from './store.js';
import GdbApi from './GdbApi.js';
import SourceCode from './SourceCode.jsx';
import Locals from './Locals.jsx';
import Memory from './Memory.jsx';
import constants from './constants.js';

const Actions = {
Expand All @@ -12,7 +13,7 @@ const Actions = {
store.set('current_thread_id', undefined)
store.set('stack', [])
store.set('threads', [])
store.set('memory_cache', {})
Memory.clear_cache()
Locals.clear()
},
inferior_program_running: function(){
Expand Down
2 changes: 1 addition & 1 deletion gdbgui/src/js/FileOps.js
Expand Up @@ -317,7 +317,7 @@ const FileOps = {
let cached_source_files = store.get('cached_source_files')
for (let cached_file of cached_source_files){
if(cached_file.fullname === fullname){
cached_file.assembly = $.extend(true, cached_file.assembly, assembly_to_save)
cached_file.assembly = Object.assign(cached_file.assembly, assembly_to_save)

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

Expand Down

0 comments on commit 88b4843

Please sign in to comment.