How to setup Eclipse debugging for onePK C Apps

Document created by cdnadmin on Jan 25, 2014
Version 1Show Document
  • View in full screen mode
This document was generated from CDN thread

Created by: Joseph Clarke on 11-12-2012 02:15:28 PM
I am writing an app in C that keeps crashing on me.  I haven't used an IDE like Eclipse before, but I hear that it can make debugging a bit easier.  Is it possible to use Eclipse to debug C apps?  Thanks.

Subject: RE: How to setup Eclipse debugging for onePK C Apps
Replied by: Chidambaram Arunachalam on 11-12-2012 02:41:18 PM
Yes, we can use Eclipse to debug onePK C Apps. Eclipse IDE is pre-installed in the onePK VM, please follow the steps below to debug your C application running in this VM :
 
Step 1 - Install Gcc c++ compiler
yum install gcc-c++
 
Step 2 - Enable GDB option in the Makefile
Eclipse used GDB to perform C debugging. So we have to compile the source file with GDB option turned on. This can be done by making the following changes to the Makefile :

ONEP_SDK ?=/home/cisco/onePK-sdk-c-rel-0.6.0.5

obj/%.o: %.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
$(CC) -g -O0 $(CC_INCDIRS) $(CC_BLDFLAGS) -MMD -MP \
-MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Step 3 - Compile your code
make clean
make -f Makefile
 
Step 4 - Start the Eclipse IDE
[cisco@onePK-EFT1 ~]$ sudo ~/eclipse/eclipse
 
Step 5 - Install the CDT eclipse plugin
Go to Help > Install New Software
Set "Work with" to http://download.eclipse.org/tools/cdt/releases/juno
Select both "CDT Main Features" and "CDT optional features" checkbox
Press "Next" and "Finish" buttons
 
Step 6 - Create a new project in Eclipse and import the executable file
 
Step 7 - Configure the Debug options
Go to "Run > Debug Configuration" and set the following :
Arguments (example: -a 1.1.1.1 -u user1 -p pass1)
Environment (Add a new variable "LD_LIBRARY_PATH" with value "/home/cisco/onePK-sdk-c-rel-0.6.0.5/c/lib/")
Press "Apply" button


Step 8 - Start debugging by selecting "Run > Debug"
 
Step 9 - Configure breakpoints
Go to the line of code where you want to insert a breakpoint and then select "Run > Toggle Breakpoint"

Attachments

    Outcomes