LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2024, 02:04 PM   #1
amikoyan
Member
 
Registered: Mar 2021
Distribution: Slackware64 -current
Posts: 316

Rep: Reputation: 169Reputation: 169
what are your favorite gdb features?


I have spent some time using GDB as a learning tool recently.

I particularly like the Text User Interface (TUI) https://sourceware.org/gdb/current/o....html/TUI.html because you can watch your code unfold.

Does anyone else have any other helpful ways GDB can be used to learn about how a program works?

Last edited by amikoyan; 04-04-2024 at 02:06 PM.
 
Old 04-04-2024, 05:30 PM   #2
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
People never thank me when I tell them that they are doing it wrong.

You are doing it wrong.

The way to learn about how a program works is by studying the source code. The source may even have documentation.

gdb is for low-level debugging. You want to start at a high-level of abstraction and then work down. Gdb is appropriate when the high-level design is right, but some implementation bug has crept in.

P.S. You can be an exception to the above rule by thanking me.
Ed
 
1 members found this post helpful.
Old 04-05-2024, 02:00 AM   #3
amikoyan
Member
 
Registered: Mar 2021
Distribution: Slackware64 -current
Posts: 316

Original Poster
Rep: Reputation: 169Reputation: 169
Thank you EdGr.


I am always willing to listen to advice from people who know more than me.

GDB lets me see 'inside' the program as it executes allowing me to check it is actually doing what I think it does.

I have found GDB useful to better understand my own very simple programs. For example I use it to check that a nested loop is doing what I think it is doing. More than once GDB has highlighted a misconception that I have with loops.

Any tips you can give on learning C will be heeded.
 
Old 04-05-2024, 02:45 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
yes, you must be in serious trouble if you need gdb to catch the error.
But anyway, you can definitely learn it if you wish. And also there are cases when it is really useful.
For example if you want to learn how a c code actually runs.

Last edited by pan64; 04-05-2024 at 12:10 PM.
 
1 members found this post helpful.
Old 04-05-2024, 08:42 AM   #5
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
amikoyan - You are welcome.

Once you master C semantics, you will write programs that are large enough to require layers of abstraction. Top-down design becomes mandatory.

I think you are making good progress. The way to become good at programming is to write a lot of code.
Ed
 
1 members found this post helpful.
Old 04-05-2024, 10:05 AM   #6
amikoyan
Member
 
Registered: Mar 2021
Distribution: Slackware64 -current
Posts: 316

Original Poster
Rep: Reputation: 169Reputation: 169
I will keep going. I think EdGr's advice to write more code is good advice.

Thank you for the encouragement.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are your favorite terminals and features? LAPIII Linux - Software 31 06-11-2016 09:48 PM
normal gdb and spec gdb for kgdb Igor007 Programming 1 09-23-2005 04:15 PM
normal gdb and spec gdb for kgdb Igor007 Linux - Newbie 1 09-23-2005 01:41 PM
Your Favorite Features.. Cliekid Yoper 19 12-11-2004 11:54 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 03:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration