Solved

debugging

Posted on 2011-03-07
10
345 Views
Last Modified: 2012-05-11
hi all,
 I have a small program to send file from client to server and it has segmentation fault. I compile them by g++. Could you please show me step by step how to run debugger ? tks.
0
Comment
Question by:BeginToLearn
10 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 35062727
You'll find a complete tutorial here http://www.delorie.com/gnu/docs/gdb/gdb_toc.html ("Debugging with GDB")
0
 

Author Comment

by:BeginToLearn
ID: 35062776
i am using those break, run, next, display to trace my "segmentation fault" now. can u show me what i did wrong in my code hihi?
0
 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 300 total points
ID: 35062902
actually you need not even use the debugger. Just insert a lot of log statements in your code. I mean printfs and output these log statements. Then run your program, you will be able to narrow down your search to a few lines as to where the problem might be

Once you have a fair idea of where the problem might be just check the pointer initializations and operations you are doing in your program. It most probably is a simple issue with some pointer you are using


however also take a look at these links

http://www.unknownroad.com/rtfm/gdbtut/gdbsegfault.html
http://www.cprogramming.com/debugging/segfaults.html


Let me know if this helps
0
 

Author Comment

by:BeginToLearn
ID: 35062965
for links. I grab those tutorial from here
  http://www.csc.sdstate.edu/~gamradtk/resources/debuggercpp.pdf
 very succient and enough for me.
 I can see that before sending, the buffer is exactly what i expected. But the server can't receive data of that buffer. hix hix.
0
 

Author Comment

by:BeginToLearn
ID: 35063156
server only received x)
So i don't know why
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:BeginToLearn
ID: 35066456
The filenam was sent sucessfully. it fails to send trunk of file. please advise.
0
 
LVL 8

Assisted Solution

by:ssnkumar
ssnkumar earned 100 total points
ID: 35104968
Core file will be useful in debugging. It has the call stack of the crashed code.
So, install gdb on your computer.
Then invoke gdb with the following command: gdb a.out core
And in the gdb prompt, issue the command: bt

That will show the call stack and the exact place where the code crashed.
For this to work, you will need to compile your code with -g option and then get a core file.
0
 

Author Comment

by:BeginToLearn
ID: 35105675
tks
0
 
LVL 12

Accepted Solution

by:
trinitrotoluene earned 300 total points
ID: 35106018
>>>>>>>>The filenam was sent sucessfully. it fails to send trunk of file. please advise.

what do you mean? so have you solved the segmentation fault.

Have you allocated enough memory for the buffer? Is there a buffer overflow? If its a C-string has it been terminated with a null char? How is the socket being declared?

Answer these questions else it is really difficult to figure out your problem
0
 

Author Comment

by:BeginToLearn
ID: 35106036
oh I know what cause core dump already. Tks all.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 96
sorting efficency of sorting algorithm 30 103
Problem to open Excel file 15 97
Problem to page 4 72
This article will show, step by step, how to integrate R code into a R Sweave document
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now