How do debug object files? Possibly a vague question
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > How do debug object files? Possibly a vague question




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-07 06: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?






[ Post a follow-up to this message ]



    Re: How do debug object files? Possibly a vague question  
Frank Cusack


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-07 06: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





[ Post a follow-up to this message ]



    Re: How do debug object files? Possibly a vague question  
Quentin Godfroy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-07 06: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.






[ Post a follow-up to this message ]



    Re: How do debug object files? Possibly a vague question  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-07 06: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.





[ Post a follow-up to this message ]



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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-07 06: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.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:01 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register