Site icon Embedkari

Embedded Debugging Concepts@GDB

I have discussed this blog at  GDB YouTube video in detail. Please SUBSCRIBE to YouTube channel Embedkari  for further discussion on Embedded Systems.

I discussed about Linux dynamic library and gdb in the   last blog post.  I strongly recommend you to read earlier blogs for better understanding . If you find something missing, Please provide feedback in comment box so that I can take corrective action

gdb utilizes system call ptrace to fetch required information. This particular discussion is limited to native debugging using x86-64 Architecture.

Step-by-Step Debugging

There are various step-by-step debugging options available with gdb. Here are some frequently used scenarios :

View Variables

View Registers

You can find registers specific info using

View Memory

View Stack Frame

Breakpoints

Wathchpoints

Catchpoints

Attaching to the Running Process

This is very important feature of any debugger where you get connected with running program to gather required information. In the example below, the program will halt at while() after execution and then I will attach to this to analyze the run time data.

#include<stdio.h>
#include<math.h>
void main()
{
  int number,count;
  unsigned char hold=1; 
  float val;
  for(number=1;number<100 ;number++) {
     val=sqrt(number);
     while(hold);
     printf("Number=%d, Sqrt value=%f \r\n",number,val);
  }
}

Frequently Used GDB commands

Following commands may be useful  from gdb prompt

Thanks for reading till end. I am trying to improve usability of my  site. Did you find this discussion helpful ? If so,  Please subscribe to YouTube channel Embedkari as well for additional embedded related stuff.

Exit mobile version