Author Topic: debugging a shared library with host application  (Read 6185 times)

Offline ote

  • Single posting newcomer
  • *
  • Posts: 9
debugging a shared library with host application
« on: February 27, 2012, 07:26:32 pm »
Hi,

I've been trying all day to find a way for debugging my code which is a plugin to 3D soft Houdini in the form of a shared library (.so)

I'm able to do that with eclipse, but I would like to use again Code::Blocks for that project, and I haven't succeeded alone...

I've installed one of the latest nightly build of the debugger branch (SVN 7845), use Project > set Project's argument to supply the path to the application (Houdini), and try different settings, but it doesn't work. I can do whatever I want in my 3D soft, my breakpoints never stops anything.

Here's the debugger log :

Code: [Select]
Building to ensure sources are up-to-date
Selecting target:
Debug11
Adding source dir: /home/ote/reconstruction/dev/LmTriangulate2D/
Adding source dir: /home/ote/reconstruction/dev/LmTriangulate2D/
Adding file: /shared/apps/houdini/hfs11.1.118_64/bin/houdini-bin
Changing directory to: /home/ote/reconstruction/dev/LmTriangulate2D/.
Starting debugger: /usr/bin/gdb -nx -fullname  -quiet  -args /shared/apps/houdini/hfs11.1.118_64/bin/houdini-bin
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.1-ubuntu
Program exited normally.

Any clue on something I'm missing ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12005
    • Travis build status
Re: debugging a shared library with host application
« Reply #1 on: February 27, 2012, 11:08:50 pm »
Enable the full log (Settings->Debugger->Common->Full log) and post again.

Another option is to start houdini from a console and then use Debug->Attach. This will work for 99.9% of the cases.
(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 ote

  • Single posting newcomer
  • *
  • Posts: 9
Re: debugging a shared library with host application
« Reply #2 on: February 28, 2012, 11:02:53 am »
Thanks for the reply oBFusCATed. Debug -> Attach to process works when I type the PID of the instance of Houdini running ! \o/

I've not been exact in my previous post : houdini is kind of starting when Debug -> Start, but with a lot of errors that cause it to crash. When I try the same command in a console, it gives the same result. Normally, I start Houdini from a console typing : /shared/apps/houdini/hfs11.1.118_64/bin/houdini which is a script bash calling another one setting some environment variables, and then calling /shared/apps/houdini/hfs11.1.118_64/bin/houdini-bin. When I change the host application to the first command, it fails : Starting the debuggee failed: No executable file specified. But anyway, if I manage to make this way work, it will start houdini, not attach it to an instance already running, right ? It's the latter that I want. And the way you told me is working the way I want, except it would be perfect if I could type the name of the process, rather than the PID that I have to get every time I'm starting a debugging session. Is there's a way to do that, cause I already tried with attach : houdini-bin, and I've got the same errors and crash of Houdini.



Offline ote

  • Single posting newcomer
  • *
  • Posts: 9
Re: debugging a shared library with host application
« Reply #3 on: February 28, 2012, 11:19:15 am »
Now that it works, one question : can the debuggging view start automatically when Debug -> Attach to process ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12005
    • Travis build status
Re: debugging a shared library with host application
« Reply #4 on: February 28, 2012, 12:04:52 pm »
You can make it work with Debug->Start, by using the envvar plugin and you must set the correct values for all vars houdini-bin is expecting.
I use C::B to run/debug Maya2011 which uses the same mechanism  and looking at the scripts of Houdini, I see no problem to do the same with it.

About the attach problem: It should switch the perspective, it does it for me. Can you reproduce this problem with some simple hello world program?
Also what is the setting of Settings->Debugger->Common->Perspective?

p.s. the improvement to the attach dialog is in my todo list, but it is very low priority.
(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 ote

  • Single posting newcomer
  • *
  • Posts: 9
Re: debugging a shared library with host application
« Reply #5 on: February 28, 2012, 04:50:06 pm »
Under Settings->Debugger->Common->Perspective it was set to "One perspective per Debugger configuration". Switching to "Only one perspective" makes starting the debugging view when using attach to process.

Thanks for the tip on the envvar plugin, I'll try if I need to start Houdini from Code::Blocks. Right now I just need to attach it to some instance already running.

I'm having some issues now with search -> goto declaration which isn't opening the right header file as I'm working with 2 different versions of the Houdini library. But I'm going to open a new post for that.

Thanks for the help.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12005
    • Travis build status
Re: debugging a shared library with host application
« Reply #6 on: February 28, 2012, 04:53:22 pm »
Under Settings->Debugger->Common->Perspective it was set to "One perspective per Debugger configuration". Switching to "Only one perspective" makes starting the debugging view when using attach to process.
Is this reproducible with a simple project?

Code: [Select]
int main() { while(true) {} return 0; }
(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 ote

  • Single posting newcomer
  • *
  • Posts: 9
Re: debugging a shared library with host application
« Reply #7 on: February 28, 2012, 05:25:07 pm »
Doing the hello world project from an empty project with previous setting (One perspective per Debugger configuration), I've understand that it was actually switching to some debugging view (GDB debugger:default) which has the same layout as the one I use for coding. That's why I thought it wasn't switching, didn't see the difference between the 2. Sorry

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12005
    • Travis build status
Re: debugging a shared library with host application
« Reply #8 on: February 28, 2012, 05:42:05 pm »
OK, so it works and there is not bug to be fixed there...
(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 ote

  • Single posting newcomer
  • *
  • Posts: 9
Re: debugging a shared library with host application
« Reply #9 on: March 01, 2012, 01:11:19 pm »
Is it normal that my watch list is empty when I start a debug ? I can add variables by typing their name in the first column, and then their value is correctly display. This variables stay in the watch list during different sessions of debugging, but the local variables and function arguments are not added automatically. In settings -> Debugger -> default, watch function arguments, local variable are checked.

Also, I can't paste some text in the first field of the watch list. If I try, the text is paste to the location of the cursor in the editor.

I've tested that behavior in my project and it does the same for a SDL project created from the template list of projects.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12005
    • Travis build status
Re: debugging a shared library with host application
« Reply #10 on: March 01, 2012, 01:22:03 pm »
No locals, nor function arguments, they are not re-implemented and the options have not been removed...

The copy-paste issue is known, but I don't know a good way to fix it. Suggestions or patches are welcomed....
(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!]