🌐
OnlineGDB
onlinegdb.com
GDB online Debugger | Compiler - Code, Compile, Run, Debug online C, C++
Online GDB is online compiler and debugger for C/C++. You can compile, run and debug code with gdb online. Using gcc/g++ as compiler and gdb as debugger. Currently C and C++ languages are supported.
Online C
OnlineGDB is online IDE with c compiler. Quick and easy way to compile c program online. It supports gcc compiler for c.
Online C++
OnlineGDB is online IDE with C++ compiler. Quick and easy way to compiler c++ program online. It supports g++ compiler for c++.
Java
OnlineGDB is online IDE with java compiler. Quick and easy way to run java program online.
Python
OnlineGDB is online IDE with python compiler. Quick and easy way to compile python program online. It supports python3.
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 12 › html › user_guide › chap-gdb
Chapter 8. GNU Debugger (GDB) | User Guide | Red Hat Developer Toolset | 12 | Red Hat Documentation
In Red Hat Developer Toolset, the ... To compile a C program with debugging information that can be read by the GNU Debugger, make sure the gcc compiler is run with the -g option:...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › gdb-step-by-step-introduction
GDB (Step by Step Introduction) - GeeksforGeeks
January 10, 2025 - GDB stands for GNU Project Debugger and is a powerful debugging tool for C (along with other languages like C++). It helps you to poke around inside your C programs while they are executing and also allows you to see what exactly happens when ...
🌐
Caltech
users.cms.caltech.edu › ~mvanier › CS11_C › misc › gdb.html
CS 11 C track: Using gdb for debugging
It’s a good habit to always use these options.) The -g option puts debugging information into the executable. Most importantly, it puts the text of the source code file into the executable so you can examine it as the program executes (we’ll see how below). Type gdb myprog (for the example above).
🌐
Reddit
reddit.com › r/c_programming › a quick intro to gdb.
r/C_Programming on Reddit: A quick intro to gdb.
May 28, 2023 -

GDB Quick Guide

I found out I didn't need cgdb by the way, it was better to just gdb -tui on Debian. Less modem noise in the form of uninterpreted escape sequences too.

So it paid up to do gdb -help.

The guide doesn't mention watch or watch -l but it points to Debugging with GDB where you can find everything.

It is a good quick start, with a couple of examples.

🌐
Recurse Center
recurse.com › blog › 5-learning-c-with-gdb
Learning C with gdb - Blog - Recurse Center
The ptype command might be my favorite command. It tells you the type of a C expression: (gdb) ptype i type = int (gdb) ptype &i type = int * (gdb) ptype main type = int (void)
🌐
UCSD
cseweb.ucsd.edu › classes › fa09 › cse141 › tutorial_gcc_gdb.html
Tutorial of gcc and gdb
The optimization options may differ in each platform. For example, the gcc under Mac OS also supports -Os and -Oz to allow optimization for code size. ... gcc is a debugger by GNU project. Gdb can step through your source code line-by-line or even instruction by instruction.
Find elsewhere
🌐
Swarthmore College
cs.swarthmore.edu › ~newhall › unixhelp › howto_gdb.php
gdb (and ddd) guide
Getting Started with gdb C and C++ programs compiled with the GNU compiler and the -g option can be debugged using GNU's debugger gdb (actually, you can use gdb on code that is not compiled with -g, but unless you like trying to figure out how assembly code sequences map to your source code I wouldn't recommend doing so).
🌐
Cprogramming.com
cprogramming.com › gdbtutorial.html
Tutorials - An Introduction to GDB - Cprogramming.com
How to begin Get the book · C tutorial C++ tutorial Game programming Graphics programming Algorithms More tutorials
🌐
University of Chicago
classes.cs.uchicago.edu › archive › 2017 › winter › 51081-1 › LabFAQ › lab2 › gdb.html
Debugging "C" And "C++" Programs Using "gdb"
Before invoking the debugger. make sure you compiled your program (all its modules, as well as during linking) with the "-g" flag. Otherwise, life will be tough. Lets compile the "debug_me.c" program, and then invoke "gdb" to debug it:
🌐
OnlineGDB
onlinegdb.com › online_c_compiler
Online C Compiler - online editor
OnlineGDB is online IDE with c compiler. Quick and easy way to compile c program online. It supports gcc compiler for c.
🌐
Landing.Jobs
landing.jobs › home › an intermediate guide to debugging c code with online gdb c compilers
An intermediate guide to debugging C code with online GDB C compilers - Landing.Jobs
February 16, 2023 - We’re a bunch of cool (and weird) people talking about tech and careers. ... You already know that debugging is an indispensable part of the development process, especially when using an online GDB C compiler. Debugging with an online GDB C compiler involves identifying, analyzing, and fixing errors in your code.
🌐
Suchprogramming
suchprogramming.com › debugging-with-gdb-part-1
Such Programming - Debugging C Programs with GDB – Part 1
The bad news is that your program doesn’t make any sense because you’ve written flaws into it. That’s fine, you’ve either written janky C programs, or not written any C. The good news is that GDB is here to help us learn from our mistakes!
Top answer
1 of 2
5

First, start the program to stop exactly at the beginning of main function.

(gdb) start

Switch to assembly layout to see assembly instructions interactively in a separate window.

(gdb) layout asm

Use stepi or nexti commands to step through the program. You will see current instruction pointer in assembly window moving when you walk over the assembly instructions in your program.

2 of 2
3

printf is pretty much the last function you would want to use to learn assembly, library calls would come later, but you wouldnt need to use library/system calls. Using a debugger is going to lead you into a rats nest using system calls as well. Try something like this, particularly if you want to learn assembly language from this exercise.

unsigned int fun ( unsigned int a, unsigned int b )
{
    return(a^b^3);
}

gcc -O2 -c so.c -o so.o
objdump -D so.o

Disassembly of section .text:

0000000000000000 <fun>:
   0:   89 f0                   mov    %esi,%eax
   2:   83 f0 03                xor    $0x3,%eax
   5:   31 f8                   xor    %edi,%eax
   7:   c3                      retq   

I highly recommend you avoid x86 as your first instruction set. Try something cleaner...

arm-none-eabi-gcc -O2 -c so.c -o so.o
arm-none-eabi-gcc -O2 -c -mthumb  so.c -o so.o
arm-none-eabi-objdump -D so.o

00000000 <fun>:
   0:   2303        movs    r3, #3
   2:   4059        eors    r1, r3
   4:   4048        eors    r0, r1
   6:   4770        bx  lr

msp430-gcc -O2 -c so.c -o so.o
msp430-objdump -D so.o

00000000 <fun>:
   0:   3f e0 03 00     xor #3, r15 ;#0x0003
   4:   0f ee           xor r14,    r15 
   6:   30 41           ret

dead serious about this one being the first instruction set, msp430 is close to it but this one makes the most sense, unfortunately the gnu assembler syntax doesnt match the books, and also unfortunate the world thought in octal then and we think hex now...

pdp11-aout-gcc -O2 -c so.c -o so.o
pdp11-aout-objdump -D so.o


00000000 <_fun>:
   0:   1166            mov r5, -(sp)
   2:   1185            mov sp, r5
   4:   15c0 0003       mov $3, r0
   8:   1d41 0006       mov 6(r5), r1
   c:   7840            xor r1, r0
   e:   1d41 0004       mov 4(r5), r1
  12:   7840            xor r1, r0
  14:   1585            mov (sp)+, r5
  16:   0087            rts pc

Nice simulators or hardware for all, best to learn in a simulator than on real hardware...

Most of the instruction sets I learned I learned by writing a disassembler, arm and thumb would fall into this category as they are fixed instruction length (if you avoid thumb2 extensions). Or just write a simulator, msp430 and pdp11 fall into this category. Either of the latter is an afternoon project, either of the former is a long weekend project. You will know each instruction set better than the average person, even some who have been programming in it for a while.

If you insist on x86 (I strongly urge you away from this) use an 8086/8088 simulator like pcemu and stick to the original instruction set, use nasm or a86 or whatever as needed to do this. It is not as nice of an instruction set even back then but back then makes more sense than now. bitsavers has nice scanned with search capability versions of the original intel documents, best place to start.

arm docs are at arm (looking for the architectural reference manual for armv5 I think they call it now). msp430 just look at wikipedia instruction set is there pdp11 google it and using C to machine code to disassembly figure out the syntax.

If you really really want to have fun get the amber core from opencores it is an arm2/3, almost all the instructions are the same as in armv4 and later, can use the gnu tools. Use verilator to build and simulate and see a working processor from the inside. Understand that just like taking 100 programmers and giving them a programming task and getting anywhere from 1 to 100 different solutions, take an instruction set and give 100 engineers the task of implementing it you get anywhere from 1 to 100 different solutions. Arm itself has re-designed their cores for the same instruction sets several times over, much less the few legal clones.

recommended order pdp11, msp430, thumb, arm, then mips and if you still feel you need to disassemble some x86. PIC12/14 is simple and educational (should take you like a half hour to an hour to make a simulator for that), 6502, z80, 8051, 6800 and a number of others are also historically educational like x86 to look at the documentation but not necessary to write programs. if you start with a good one, then each Nth instruction set is that much easier from the second one on. They are more alike than different but you do get to see different things like how to do things without flags in mips, etc...I have left out several other instruction sets that are either still available in silicon or are interesting for various reasons.

Another approach is install clang/llvm and take a quick or longer look at every instruction set that llc can produce (compile to bitcode/bytecode then use llc to do the backend to whatever instruction set). Like above taking the same code and seeing what different instruction sets look like at least with that compiler and its settings is very educational and helps mentally get a feel for how to break programming tasks down into these atomic steps.

🌐
Wikipedia
en.wikipedia.org › wiki › GNU_Debugger
GNU Debugger - Wikipedia
1 month ago - The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, Assembly, C, C++, D, Fortran, Haskell, Go, Objective-C, OpenCL C, Modula-2, Pascal, Rust, and partially others.
🌐
Quora
quora.com › I-want-to-run-a-C-program-on-GDB-which-reads-a-text-file-How-do-I-do-that-Ive-tried-putting-in-the-full-path-nothing-seems-to-work
I want to run a C program on GDB which reads a text file. How do I do that? I've tried putting in the full path, nothing seems to work. - Quora
Answer (1 of 3): Depends on lots of details. If you are normally running myprog input.txt, then you probably want to use gdb \-\-args myprog input.txt. This will tell gdb that everything after args is arguments to your program, not to gdb. Every now and again, I make the mistake of just going “...