Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

debugging

Posted on 2011-03-07
10
Medium Priority
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 400 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 1200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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 400 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 1200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This article will show, step by step, how to integrate R code into a R Sweave document
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

704 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