Skip to main content

Posts

Showing posts from July, 2025

How to use gdb in Ubuntu Terminal

Here's a practical, minimal guide for using GDB in Ubuntu terminal — from launching to setting breakpoints and navigating your code. 🧰 Step 1: Compile with Debug Symbols Use -g and disable optimizations ( -O0 preferred for debugging): bash Copy Edit g++ -g -O0 -o myprog myprog.cpp 🚀 Step 2: Launch GDB bash Copy Edit gdb ./myprog You'll see a (gdb) prompt. 🎯 Step 3: Set Breakpoints You can set breakpoints in three main ways : ✅ a. At a function gdb Copy Edit (gdb) break main ✅ b. At a specific file and line gdb Copy Edit (gdb) break myprog.cpp:42 ✅ c. At a method in a class gdb Copy Edit (gdb) break MyClass::doSomething If the symbol is mangled (C++), GDB usually demangles automatically, especially if compiled with -g . ▶️ Step 4: Run the Program gdb Copy Edit (gdb) run 🧭 Step 5: Navigate Command Meaning next or n Step over current line step or s Step into function call finish Run until current function returns continue or c Continue until...

How to use gdb in Ubuntu Terminal

Here's a practical, minimal guide for using GDB in Ubuntu terminal — from launching to setting breakpoints and navigating your code. 🧰 Step 1: Compile with Debug Symbols Use -g and disable optimizations ( -O0 preferred for debugging): bash Copy Edit g++ -g -O0 -o myprog myprog.cpp 🚀 Step 2: Launch GDB bash Copy Edit gdb ./myprog You'll see a (gdb) prompt. 🎯 Step 3: Set Breakpoints You can set breakpoints in three main ways : ✅ a. At a function gdb Copy Edit (gdb) break main ✅ b. At a specific file and line gdb Copy Edit (gdb) break myprog.cpp:42 ✅ c. At a method in a class gdb Copy Edit (gdb) break MyClass::doSomething If the symbol is mangled (C++), GDB usually demangles automatically, especially if compiled with -g . ▶️ Step 4: Run the Program gdb Copy Edit (gdb) run 🧭 Step 5: Navigate Command Meaning next or n Step over current line step or s Step into function call finish Run until current function returns continue or c Continue until...

Install gcc-15.1 form source in Ubuntu (chatGpt reply)

✅ Step-by-step: Build and Install GCC 15.1 on Ubuntu ⚠️ Estimated time : ~30–60 mins ✅ Works on Ubuntu 20.04 / 22.04 / 24.04 1. Install dependencies bash Copy Edit sudo apt update sudo apt install -y build-essential wget curl git \ libgmp-dev libmpfr-dev libmpc-dev libisl-dev \ flex bison libzstd-dev 2. Download GCC 15.1 source bash Copy Edit cd ~/Downloads wget https://ftp.gnu.org/gnu/gcc/gcc-15.1.0/gcc-15.1.0.tar.xz tar -xf gcc-15.1.0.tar.xz cd gcc-15.1.0 ./contrib/download_prerequisites This will fetch GMP, MPFR, MPC, and ISL into the source tree. 3. Create build directory bash Copy Edit mkdir ../gcc-15.1-build cd ../gcc-15.1-build 4. Configure build bash Copy Edit ../gcc-15.1.0/configure \ --prefix=/opt/gcc-15.1 \ --disable-multilib \ --enable-languages=c,c++,fortran \ --enable-bootstrap \ --enable-checking=release 5. Build (takes time) bash Copy Edit make -j$( nproc ) 6. Install bash Copy Edit sudo make install 7. Use GCC 15.1 Add it to y...