2011-03-29 08:08:12     Debugging using Gdb

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-03-29 08:08:12     Debugging using Gdb

Mahalakshmi M (INDIA)

Message: 99427   

 

Hi,

 

I am trying to debugg using gdb. I can able to debugg till thread creation i.e., pthread_create() .After this if i keep breakpoint at thread run function i.e., TempThread_RunFunction() its not hitting it shows. SIGTRAP trace/breakpoint trap.

 

Please help to solve this.

 

My main.c file is as follows.

 

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <pthread.h>

 

pthread_attr_t Thread_Attribute;

void *TempThread_RunFunction(void *inPtr)

{

        int d =100;

                printf("Function %s \t Line No %d \n",__FUNCTION__,__LINE__);

        printf("In Thread d %d \n",d);

}

 

void main ()

{

        pthread_attr_init(&Thread_Attribute);

        int ret;

        int stacksize;

        pthread_t Tempthreadid;

        ret = pthread_attr_setstacksize(&Thread_Attribute, 4*8192);

        printf("pthread_attr_setstacksize ret %d \n",ret);

        ret = pthread_attr_getstacksize (&Thread_Attribute, &stacksize);

        printf("pthread_attr_getstacksize ret %d \n",ret);

        printf("stack size1 = %li\n", stacksize);

 

 

        pthread_create(&Tempthreadid, &Thread_Attribute, &TempThread_RunFunction, NULL );

 

        while(1)

        {

                usleep(500000);

 

        }

 

}

My Makefile is as follows:

 

CXX = bfin-linux-uclibc-g++

CC = bfin-linux-uclibc-gcc

# define the directory here

 

FS_OBJS = main.o

 

INCLUDES = -I

 

UCLINUX_COMPILE_OPTIONS = -Wall -Wstrict-prototypes -Wshadow -Os -fomit-frame-pointer -D_GNU_SOURCE -DNDEBUG -O0 -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin

 

UCLINUX_COMPILE_OPTIONS_CXX = -Wall -Wshadow -Os -fomit-frame-pointer -D_GNU_SOURCE -DNDEBUG -O0 -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin

 

COMPILE_OPTS =  -g $(INCLUDES) -I. -O0 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 $(UCLINUX_COMPILE_OPTIONS) $(UCLINUX_INCLUDE_PATH) -I../include -I./ -DUCLINUXBASE=1

 

COMPILE_OPTS_CXX =  -g $(INCLUDES) -I. -O0 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 $(UCLINUX_COMPILE_OPTIONS_CXX) -I../include -I./ -DUCLINUXBASE=1

 

linkflags       = -Os -lpthread -lm -ldl -L$(GCCPATH)../lib

 

C_COMPILER              =  $(CC)

CFLAGS                  = $(COMPILE_OPTS) -mfdpic -mstack-check-l1

CPLUSPLUS_COMPILER      = $(CXX)

CPLUSPLUS_FLAGS         = $(COMPILE_OPTS_CXX) -Wall -DBLKFN=1 -mfdpic

 

LDLIBS += #-LLib/ \

     

test: $(FS_OBJS)

        $(CPLUSPLUS_COMPILER) $(CPLUSPLUS_FLAGS) -lpthread  -g -o $@ $(FS_OBJS) $(LDLIBS)

 

all: test

clean:

        rm -rf test *.o *.elf *.gdb

 

.$(C).$(OBJ):

        echo "Compiling C : $<"

        $(C_COMPILER) -g -c -o $@ $(CFLAGS) $<

 

.$(CPP).$(OBJ):

        echo "Compiling C++ : $<"

        $(CPLUSPLUS_COMPILER) -g -c $(CPLUSPLUS_FLAGS) $<

QuoteReplyEditDelete

 

 

2011-04-06 04:00:56     Re: Debugging using Gdb

Sonic Zhang (CHINA)

Message: 99620   

 

Which release do you use?

 

How do you set the breakpoint?

Attachments

    Outcomes