Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: renega_666 on August 29, 2012, 06:04:38 pm

Title: remote ip in cb project file
Post by: renega_666 on August 29, 2012, 06:04:38 pm
Hi!

We have an issue with the remote target ip address being stored in the cb project file. The project file is under version control and each team member has a dedicated remote machine to test and debug our code. The issue is that as every time we synchronize our work we have conflicts on the cb project file because of different remote ip.

To fix the problem I tried to use a global variable but cb doesn't seem to recognize it (the global variable dialog  does not show (it does for every other global variable used in the project)).

Isn't there any way to specify the remote ip as a global IDE settings?

EDIT:

Codeblocks rev 8059 (17 june 2012) on windows xp.



Title: Re: remote ip in cb project file
Post by: oBFusCATed on August 29, 2012, 06:39:06 pm
No, but you can force you colleagues not commit this setting :)
Title: Re: remote ip in cb project file
Post by: zabzonk on August 29, 2012, 07:00:56 pm
The normal way to handle this is either to store the IP address in a file that isn't version controlled (or is only version controlled locally), or to use an environment variable, set outside of the development environment, for example during login.
Title: Re: remote ip in cb project file
Post by: renega_666 on August 29, 2012, 07:06:28 pm
Quote
The normal way to handle this is either to store the IP address in a file

I thought about it but how would you make cb aware of this file? Using a script?
Title: Re: remote ip in cb project file
Post by: oBFusCATed on August 29, 2012, 08:03:26 pm
I thought about it but how would you make cb aware of this file? Using a script?
By patching C::B of course and fixing the real problem.
Title: Re: remote ip in cb project file
Post by: MortenMacFly on August 29, 2012, 08:21:55 pm
Isn't there any way to specify the remote ip as a global IDE settings?
Why don't you use a macro / global compiler variable / environment variable for that purpose? All three solutions should work and are not saved inside the project file.
Title: Re: remote ip in cb project file
Post by: zabzonk on August 29, 2012, 08:23:14 pm
Quote
I thought about it but how would you make cb aware of this file?

Why would CB need to be aware of it? It's your code that needs to know about it.
Title: Re: remote ip in cb project file
Post by: renega_666 on August 29, 2012, 08:49:07 pm
Quote
Why don't you use a macro / global compiler variable / environment variable for that purpose? All three solutions should work and are not saved inside the project file.

I tried to use a global compiler variable but cb didn't detect it (I'm using a lot of other global compiler variables in the project without any problems). I will have to investigate it a little further tomorrow morning.

Quote
Why would CB need to be aware of it? It's your code that needs to know about it.

I don't understand. Why does my source code have to know about how I'm going to debug it? I'm talking about the ip adress for remote debugging from codeblocks.
Title: Re: remote ip in cb project file
Post by: dmoore on August 29, 2012, 09:02:25 pm
Quote
Why don't you use a macro / global compiler variable / environment variable for that purpose? All three solutions should work and are not saved inside the project file.

I tried to use a global compiler variable but cb didn't detect it (I'm using a lot of other global compiler variables in the project without any problems). I will have to investigate it a little further tomorrow morning.

What you haven't stated, which is perhaps what some of the replies have missed, is whether you are setting the IP in "Project->Properties->Debugger". I expect that specifying an environment var or global var in that textcontrol won't get a variable substitution. There may be a workaround or a simple fix we can make, but I'm not all that familiar with that part of the code base, so don't have immediate suggestions.
Title: Re: remote ip in cb project file
Post by: renega_666 on August 29, 2012, 09:21:25 pm
Quote
What you haven't stated, which is perhaps what some of the replies have missed, is whether you are setting the IP in "Project->Properties->Debugger".

Yes that's exactly what I do. I should have said that, my bad.

Quote
There may be a workaround or a simple fix we can make, but I'm not all that familiar with that part of the code base, so don't have immediate suggestions.

Ok.

Thank you everyone for your answers!
Title: Re: remote ip in cb project file
Post by: MortenMacFly on August 30, 2012, 06:58:25 am
Quote
What you haven't stated, which is perhaps what some of the replies have missed, is whether you are setting the IP in "Project->Properties->Debugger".
Yes that's exactly what I do. I should have said that, my bad.
Ah - I missed that, to.

Well this should be simple: We could introduce a macro replacement for these fields in gdb_commands.h:
Code
class GdbCmd_RemoteTarget : public DebuggerCmd
[...]
Code
                case RemoteDebugging::TCP:
                {
                    if (!rd->ip.IsEmpty() && !rd->ipPort.IsEmpty())
                        m_Cmd << targetRemote << _T("tcp:") << rd->ip << _T(":") << rd->ipPort;
                }

It should be a 1-3 liner actually... I wonder what oBFusCATed has to tell...
Title: Re: remote ip in cb project file
Post by: MortenMacFly on August 30, 2012, 07:11:01 am
It should be a 1-3 liner actually... I wonder what oBFusCATed has to tell...
Well here it is: a two-liner. :-)

It does the macro replacement specifically for remote debugging only.
@oBFusCATed: An alternative would be to generally replace macros in commands when they are sent to the debugger. Do you think this is a wise thing to do (i.e. in DebuggerDriver::RunQueue())?
Title: Re: remote ip in cb project file
Post by: oBFusCATed on August 30, 2012, 08:08:52 am
I don't know how wise it is, but if it works why not, generally playing with the RunQueue is not pretty safe.

But please separate the patch. One patch for the formatting and one to fix the problem. Pretty please.
Title: Re: remote ip in cb project file
Post by: MortenMacFly on August 30, 2012, 08:14:12 am
But please separate the patch. One patch for the formatting and one to fix the problem. Pretty please.
Oh dear... this just came from the fact that there was one additional line where I indented an if-statement. Isn't your request a little over-done therefore? Notice that the #includes had to change, so this is part of the patch to work.
Title: Re: remote ip in cb project file
Post by: MortenMacFly on August 30, 2012, 08:15:53 am
generally playing with the RunQueue is not pretty safe.
That was my feeling, too. So I'd rather keep the patch as it is.