Author Topic: remote ip in cb project file  (Read 7540 times)

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
remote ip in cb project file
« 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.



« Last Edit: August 29, 2012, 06:06:40 pm by renega_666 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: remote ip in cb project file
« Reply #1 on: August 29, 2012, 06:39:06 pm »
No, but you can force you colleagues not commit this setting :)
(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!]

zabzonk

  • Guest
Re: remote ip in cb project file
« Reply #2 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.

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: remote ip in cb project file
« Reply #3 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: remote ip in cb project file
« Reply #4 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.
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: remote ip in cb project file
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

zabzonk

  • Guest
Re: remote ip in cb project file
« Reply #6 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.

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: remote ip in cb project file
« Reply #7 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: remote ip in cb project file
« Reply #8 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.

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: remote ip in cb project file
« Reply #9 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!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: remote ip in cb project file
« Reply #10 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: remote ip in cb project file
« Reply #11 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())?
« Last Edit: August 30, 2012, 07:13:15 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: remote ip in cb project file
« Reply #12 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.
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: remote ip in cb project file
« Reply #13 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: remote ip in cb project file
« Reply #14 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ