LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2014, 11:03 PM   #1
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Rep: Reputation: Disabled
running gdb with Makefile


Having difficulty using gdb with a "speller" with an Makefile:
Code:
#
# Makefile
#
# Computer Science 50
# Problem Set 5
#


# compiler to use
CC = clang

# flags to pass compiler
CFLAGS = -ggdb -O0 -Qunused-arguments -std=c99 -Wall -Werror
CFLAGS+ = -g
# name for executable
EXE = speller

# space-separated list of header files
HDRS = dictionary.h 

# space-separated list of libraries, if any,
# each of which should be prefixed with -l
LIBS =

# space-separated list of source files
SRCS = speller.c dictionary.c 

# automatically generated list of object files
OBJS = $(SRCS:.c=.o)


# default target
$(EXE): $(OBJS) $(HDRS) Makefile
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)

# dependencies 
$(OBJS): $(HDRS) Makefile

# housekeeping
clean:
	rm -f core $(EXE) *.o
The command line for running this program would be:
Quote:
./speller textfile_to_be_spell-checked
Can anyone explain what command line can be used with gdb in order to make use of this app, which would include argv[1]. Can't find any applicable instructions after much searching.
Thanks for your attention.
Thank
 
Old 02-23-2014, 11:29 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Code:
gdb ./speller
run textfile_to_be_spell-checked
 
1 members found this post helpful.
Old 02-24-2014, 07:50 AM   #3
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Code:
gdb ./speller
run textfile_to_be_spell-checked
oh! So simple a solution. Yet so hard to find on the web!
Thanks
 
Old 02-24-2014, 08:26 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Note: if you want to run it from Makefile:
Code:
debug: ./speller
        echo 'break main' >debug.tmp
        echo 'run sometestfile' >>debug.tmp
        exec gdb -x debug.tmp ./speller
 
1 members found this post helpful.
Old 02-25-2014, 10:25 AM   #5
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Note: if you want to run it from Makefile:
Code:
debug: ./speller
        echo 'break main' >debug.tmp
        echo 'run sometestfile' >>debug.tmp
        exec gdb -x debug.tmp ./speller
is there any advantage for "running it" from Makefile?
 
Old 02-25-2014, 11:24 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
It might be handy if you have to run the debugger again and again with the same parameters (breakpoints, etc)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gdb or way to see all memory of a running bash script (accidently lost most source) StuartRothrock Programming 9 11-03-2009 06:06 PM
Question about running a program with gdb calypso9 Linux - Newbie 1 04-09-2009 05:30 PM
error running my makefile yogeshk@redim.net Linux - Software 1 01-06-2007 01:34 AM
Having some problem in running the Makefile Sulman Shah Fedora 2 12-19-2006 04:26 AM
attach gdb to a running process linwenyuan Linux - Desktop 1 10-15-2006 01:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration