473,421 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

How to configure gdb ?

19
Hi,

I have implemented strcpy function using arrays. Wantedly i have coded in order to generate segmentation fault. How to debug it using gdb ?

My code snippet :
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int i;
  7.     char *dest="murali";
  8.     char *src = "krishna";
  9.     strcpy_temp(dest,src);
  10.     printf("value of dest and src is %s %s\n",*dest,*src);
  11. }
  12.  
  13. int strcpy_temp(char *dest, char*src)
  14. {
  15.     int i=0;
  16.     while(src[i] != '\0')
  17.     {
  18.         dest[i] = src[i];
  19.     }
  20.     return 0;
  21. }
  22.  
After compiling this i got a.out. After executing a.out it got crashed .Now if i give $gdb a.out

Following is the message displayed.

[mmk@localhost c]$ gdb a.out
GNU gdb Red Hat Linux (6.1post-1.20040607.43.0.1rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) bt
No stack.
(gdb)


Please suggest me how to proceed. Do I need to modify anything in .gdbinit ?
Apr 3 '08 #1
2 3101
ashitpro
542 Expert 512MB
First of all..
have you compiled your code with -ggdb option,,If not do it.
Later when you give the command
'gdb a.out' and you end up with '(gdb)' prompt, you need to tell the gdb explicitly to run a.out by giving command 'run' or 'r' .
So before back tracing you've to run the executable..

There is no problem with your gdb installation..
Apr 3 '08 #2
mmk
19
First of all..
have you compiled your code with -ggdb option,,If not do it.
Later when you give the command
'gdb a.out' and you end up with '(gdb)' prompt, you need to tell the gdb explicitly to run a.out by giving command 'run' or 'r' .
So before back tracing you've to run the executable..

There is no problem with your gdb installation..
Hi Ashit,

Thank you, I got it :).
Apr 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Christopher De Vries | last post by:
The predominant operating system in my workplace is Solaris, with a bit of Linux and MacOS X thrown in. As such people expect to install new software with the sequence: ../configure make make...
0
by: Markus Wollny | last post by:
Hello! When I try to run ./configure --with-java, it complains that ant doesn't work. However ant is installed, as is the latest Java SDK 1.4.2 from sun, PATH and JAVA_HOME are set correctly; ...
0
by: Samuel M. Smith | last post by:
I am trying to build python2.4.2 on an arm 9 running Debian 3 Sarge when I run ./configure it fails with ../configure checking MACHDEP... linux2 checking EXTRAPLATDIR... checking for...
1
by: Markus Wollny | last post by:
Hi! I am trying to build PostgreSQL 7.4.3 with Java enabled; I've got Apache Ant version 1.5 and j2sdk1.4.1_05 installed: Verifiying ant: # which javac /usr/java/j2sdk1.4.1_05/bin/javac #...
7
by: Hal Vaughan | last post by:
I have a problem with port forwarding and I have been working on it for over 2 weeks with no luck. I have found C programs that almost work and Java programs that almost work, but nothing that...
14
by: david | last post by:
I have developed web forms including login by using ASP.NET via HTTP. Now I want to secure the connection from client to the server via HTTPS. How can I configure the server or something else to...
0
by: Satish S Nandihalli | last post by:
following errors were found on executing configure file: 1) configure: WARNING: thread.h: present but cannot be compiled configure: WARNING: thread.h: check for missing prerequisite headers?...
1
by: Jim McCullars | last post by:
Greetings: Getting configure errors trying to build PHP 5.2.5 under Solaris 9. The configure command I use is this: ../configure --with-mysql --with-gd --with-jpeg-dir=/usr/local...
7
by: Mathieu Prevot | last post by:
Hi, I have the following error when I run configure: checking size of wchar_t... configure: error: cannot compute sizeof (wchar_t) what can I do ? Mathieu
0
by: lee.walczak | last post by:
I actually post a topic relating to my problem here: (http://groups.google.co.uk/group/comp.lang.python/browse_thread/ thread/a073d532c4481bfe?hl=en# ) But I thought it could be useful to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.