On Wed, Oct 25, 2006 at 02:00:49AM -0000, soniathakur3 wrote:
>
> hi,
>
> I am trying to debug a program on my TS7200 board. I am not sure how
> gdb works.I think i have to set up a gdb server on the target(which is
> the TS7200 board), but i have no idea how to do that.Can somebody tell
> me exactly how to debug a program. I have linux machine and the board
> is connected through serial port.
I've spent a fair amount of time in gdb, but I rarely do it any more. It's good
if you have complex data structures you are walking, and need to step, step,
step through the pointers, but frequently it's more hassle than it's worth.
Instead of gdb I tend to just: if (debug) printf(........)
As somebody else said, the best thing is to really understand what you really
need to do, plan your strategies and write code that works. Print it all out,
review it line for line, fix your glaring mistakes, and then try to compile.
Write little stub programs so you can test your modules and make sure they work
before combining as a whole. Get them working on your PC before you carry it
over to your embedded platform (I simulate analog inputs with random numbers).
Then when you bring it over to the embedded platform, it's mainly just a
recompile and debugging your I/O timing that you didn't understand as well as
you thought.
If you are familiar with the debugger in Visual Basic, and are looking for
something like that, forget it. That is like training wheels for people who
don't want to think it through. Get past that, and you will be a much better
programmer.
So much for the brainwashing... now to answer your question...
- You probably don't need a gdb server. Just use command line gdb. In fact, if
your only access is the console, you probably don't have a choice.
- I'm sure there are some good gdb tutorials out there. I learned with cheat
sheet handout from a college processor, but I suppose they are all on the web
now :-) This one looks pretty good:
http://linux.wku.edu/~lamonml/programming/debug/gdb_usage.html
- It goes something like this.
$ gcc -g myprog.c -o myprog (compile with -g adds debug symbols)
$ gdb myprog
(gdb) break my_buggy_function (tells it where to break execution, before run)
(gdb) run (executes until the break point)
(gdb) print x (shows contents of variable x)
(gdb) next (executes next line)
(gdb) quit
- IMO the best way to debug is with 3 windows open. (1) editing the code, (2)
with your compile/make window, and (3) with your execute/debug window.
Alt-tab, up arrow, enter... ad nauseum.
- On a full PC with X-windows, there is ddd and xxgdb, which are semi-GUI front
ends for gdb. I've tried them, but tend to stick with regular gdb. To each his
own.
- Spend a few minutes playing with GDB on a working program so you can get an
idea how it is supposed to work. You didn't learn everything about vi in one
minute either.
Hope that helps.
Joe
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|