Unix Programming - How do debug object files? Possibly a vague question

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2007 > How do debug object files? Possibly a vague question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How do debug object files? Possibly a vague question
K-mart Cashier

2007-05-24, 1:16 am

Say I have a function called add() in the file addme.c

int add(int a, int b) {

return(a+b);
}

and it's compiled, with debugging flags, as on object file ie
addme.o

Is there anyway on to debug only the object file under gdb? What I'm
looking for in this cause would be to insert a break point by return
and then just test input values for 'a' and 'b'. Or would I have to go
through the effort of creating a main() file?

Frank Cusack

2007-05-24, 1:16 am

On 23 May 2007 17:27:48 -0700 K-mart Cashier <cdalten@gmail.com> wrote:
> Say I have a function called add() in the file addme.c
>
> int add(int a, int b) {
>
> return(a+b);
> }
>
> and it's compiled, with debugging flags, as on object file ie
> addme.o
>
> Is there anyway on to debug only the object file under gdb? What I'm
> looking for in this cause would be to insert a break point by return
> and then just test input values for 'a' and 'b'.


break point by return?

anyway, gdb cannot do this.

> Or would I have to go through the effort of creating a main() file?


yes, gdb only debugs *programs*. so you would have to go through the
monumental effort to write a program around it.

-frank
Quentin Godfroy

2007-05-24, 1:16 am

On May 23, 8:27 pm, K-mart Cashier <cdal...@gmail.com> wrote:
> Is there anyway on to debug only the object file under gdb? What I'm
> looking for in this cause would be to insert a break point by return
> and then just test input values for 'a' and 'b'. Or would I have to go
> through the effort of creating a main() file?


You could compile this as a dynamic library, LD_PRELOAD it to any
executable and play, but I do not see the point in doing that.

Paul Pluzhnikov

2007-05-24, 1:16 am

K-mart Cashier <cdalten@gmail.com> writes:

> Is there anyway on to debug only the object file under gdb?


No.

> What I'm
> looking for in this cause would be to insert a break point by return


In order to insert a breakpoint, you need a running process.
And to have a running process, you need a runnable program.

> and then just test input values for 'a' and 'b'. Or would I have to go
> through the effort of creating a main() file?


There are automated tools, such as C++Test (www.parasoft.com),
which can write this "test harness" for you, and allow you to
"unit test" individual classes or functions.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
K-mart Cashier

2007-05-24, 1:16 am

On May 23, 9:40 pm, Paul Pluzhnikov <ppluzhnikov-...@charter.net>
wrote:
> K-mart Cashier <cdal...@gmail.com> writes:
>
> No.
>
>
> In order to insert a breakpoint, you need a running process.
> And to have a running process, you need a runnable program.
>
>
> There are automated tools, such as C++Test (www.parasoft.com),
> which can write this "test harness" for you, and allow you to
> "unit test" individual classes or functions.
>
> Cheers,
> --


Yes, that is what I was looking for. Thanks.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com