- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there precompiled binary of GDB & GDB-SERVER available for debugging applications on linux? Please provide link if available.
Thanks ShakthiLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
what about debugging by using the Eclipse IDE? actually i never used this but according to the linux docs it should work. I prefer to debug with printf.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, try using this for debuging . Not great but better than having printfs everywhere .
/* * debug_segfault.c * Handy little code for debugging embedded applications where too many * printfs on console changes program behaviour. Mighty useful if no gdb * or other debugger support. *# define DEBUG_SEGFAULT, register signal(SIGSEGV,(void*) sig_segv_handle) * in main and sprinkle code with macro DEBUG_SEGFAULT_POINT * * Copyright © 2006 by Vishal Oliyil Kunnil * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Original author: * Vishal Oliyil Kunnil <vishal.ok@gmail.com> * */ # define DEBUG_SEGFAULT # include <stdio.h># include <unistd.h># include <string.h># include <signal.h> /* Contents of below# ifdef to be globally visible */# ifdef DEBUG_SEGFAULT char seg_file[10],seg_function[20]; int seg_line_number; void sig_segv_handle(void) { printf("caught SIGSEGV in\n"); printf("\tfile = %s\n", seg_file); printf("\tfunction = %s\n", seg_function); printf("\tapprox. line = %d\n", seg_line_number); exit(0); } # define DEBUG_SEGFAULT_POINT strcpy(seg_file, __FILE__); strcpy(seg_function, __FUNCTION__); seg_line_number = __LINE__; # else # define DEBUG_SEGFAULT_POINT do { } while(0)# endif int foo(void) { DEBUG_SEGFAULT_POINT return 0; } int bad_bad_function(void) { char *null_pointer; null_pointer=NULL; DEBUG_SEGFAULT_POINT //should segfault - de-referencing null pointer, do not try this @home! printf("%c",*null_pointer); return 0; } int main(void) { int ret; # ifdef DEBUG_SEGFAULT signal(SIGSEGV,(void*) sig_segv_handle); # endif DEBUG_SEGFAULT_POINT foo(); printf("zzzzz...... sleeping ....\n"); DEBUG_SEGFAULT_POINT sleep(1); printf("call segfaulting function....\n"); ret=bad_bad_function(); if (!ret) printf("no segfault, exiting ok....\n"); return 0; }
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page