Author Topic: Debug in a separate window?  (Read 10322 times)

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Debug in a separate window?
« on: December 29, 2009, 10:52:14 pm »
I have an application that uses a shared library.  I am debugging this shared library.  When I debug the library in C::B, it works fine except I have no access to the base program to send it commands and change options.

Is there any way to launch the debug process in a separate terminal window when everything is handled through bash and GDB?  In other words, how do I run the base application as a console application?  Since it is being run from GDB?

C::B 8.02
Linux Mint 7/Ubuntu 9.04 (Gnome)

Thanks,
Keeper

EDIT:  Other than attaching to it after I run it via a script?
« Last Edit: December 30, 2009, 06:41:10 am by Keeper »

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #1 on: December 30, 2009, 11:22:01 am »
Do you have the source of the host application and do you have a C::B project for it?
If you have, you could make a workspace that contains the application and the library.
Then you could debug the application and set breakpoints in the library code (I think).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #2 on: December 30, 2009, 03:27:26 pm »
No, the source application is a private app.  I'm writing a plugin for it, so I have the SDK, but not the full blown code.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Debug in a separate window?
« Reply #3 on: December 30, 2009, 10:08:28 pm »
It should work, if you set it as host application in "Project -> Set programs arguments..." .

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #4 on: December 30, 2009, 10:13:24 pm »
The debugging works, but I have no interaction with the main program.  That's the problem.  KDevelop offers me a checkmark to debug in a separate window.  Didn't known if C::B had the same sort of option or workaround.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Debug in a separate window?
« Reply #5 on: December 30, 2009, 11:16:20 pm »
I'm not sure what you mean.
If you are able to debug and set breakpoints the interaction with the main app should work as if you do not run it through the debugger.

If I create a C::B plugin, I can link it again and run it through a stripped version of C::B (no debugging symbols). I can interact with the main app (C::B in this case) as if I debug the plugin with the C::B sources available.

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #6 on: December 30, 2009, 11:21:03 pm »
Ok, let me clear it up a bit  :D

Say you open a terminal, and change directories to where the executable is.

I run this executable and it runs in that same terminal window.  It doesn't open a new window, it's a text/console application.

So when you run it via the debugger, it only shows up if I turn on debugging log.  Even then it doesn't show everything.  In order to run debugging from C::B, I would need to somehow tell GDB ( I guess ) to start this up in another window.   Or C::B could open the console and bash all the commands via that and then the program would start in that window instead of "behind the scenes" in C::B.


Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #7 on: December 31, 2009, 01:34:02 am »
jens: he wants the host app to be run inside terminal, I think.

C::B should be modified to support this feature. I'll add it in my TODO for the debugger branch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #8 on: December 31, 2009, 01:45:07 am »
jens: he wants the host app to be run inside terminal, I think.

Why is it I can never seem to express exactly what I want?!??!?!?!   Yes, that is exactly what I was trying to say.  :D

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Debug in a separate window?
« Reply #9 on: December 31, 2009, 09:33:36 am »
jens: he wants the host app to be run inside terminal, I think.

Why is it I can never seem to express exactly what I want?!??!?!?!   Yes, that is exactly what I was trying to say.  :D
I understood after your answer to my previous post.

What you can try, is to start the app in a console, get the pid with ps and attach the debugger via "Debug -> Attach to process".
I never did this, so I don't know how usable it is.

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #10 on: March 08, 2010, 09:36:17 pm »
You can attach to the process once it's running.  But if you want to debug the program as it loads, you are out of luck.  Any news as to when this will be added to the debugging features?

TIA,
Keeper

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #11 on: March 08, 2010, 10:00:16 pm »
What a coincidence, I started work on this feature yesterday :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #12 on: March 09, 2010, 10:30:25 pm »
This is great news!!!  Thank you  :D

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #13 on: August 08, 2010, 11:58:58 pm »
I've been out of the linux dev side for a while ... I have downloaded the latest from the SVN.   I didn't see where I can set this type of debugging up.  Is this implemented yet?

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #14 on: August 09, 2010, 12:14:22 am »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #15 on: August 09, 2010, 05:19:37 am »
I'm getting this:
warning: GDB: Failed to set controlling terminal: Operation not permitted

Also, is it possible to set the path to the executable?  it needs to be run from a different directory than the codebase.  I have tried several things, but I seem to be missing it.

Thanks!
Keeper

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #16 on: August 09, 2010, 09:24:15 am »
1. The warning is emitted by gdb and it is not a problem.
2. You can set the working directory in Project -> Properties -> Build options -> Working dir or something like that.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #17 on: August 09, 2010, 01:32:40 pm »
Well, I tried to run GDB just on it's own outside of codeblocks and it seems it doesn't work.   I get the "Cannot find new threads: generic error" error.

Oh well.

Thanks for the help!

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #18 on: August 09, 2010, 02:16:04 pm »
This seems like a very popular gdb problem, use your favorite search engine to find solutions for it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #19 on: August 09, 2010, 02:53:02 pm »
Well I tried just GDB on my lenny distro and it worked.  Must be some kind of issue with the newest Ubuntu.

I'm going to reload my lenny and see if I can get it to work there.

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #20 on: August 15, 2010, 02:59:27 am »
Ok, after many problems with Ubuntu.  I finally reloaded Debian.  Of course, my hard drive went out, and then I couldn't get the "debuggers branch" to compile on lenny.  I figured out the issues and got it compiled.

Worked like a charm.  Cheers!

Will this make it to the main distro?

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #21 on: August 15, 2010, 12:54:50 pm »
Will this make it to the main distro?
Of C::B? Yes it will, someday, but first it needs some testing...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Keeper

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug in a separate window?
« Reply #22 on: August 15, 2010, 02:50:57 pm »
Sounds good!  I'm going to use it/test it all the time ... I'll post back here if I see any issues.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Debug in a separate window?
« Reply #23 on: August 15, 2010, 04:46:46 pm »
Please post in http://forums.codeblocks.org/index.php/topic,10908.0.html if you find problems...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]