News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

remote ip in cb project file

Started by renega_666, August 29, 2012, 06:04:38 PM

Previous topic - Next topic

renega_666

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.




oBFusCATed

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

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.

renega_666

QuoteThe 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?

oBFusCATed

Quote from: renega_666 on August 29, 2012, 07:06:28 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!]

MortenMacFly

Quote from: renega_666 on August 29, 2012, 06:04:38 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

zabzonk

QuoteI 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.

renega_666

QuoteWhy 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.

QuoteWhy 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.

dmoore

Quote from: renega_666 on August 29, 2012, 08:49:07 PM
QuoteWhy 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.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

renega_666

QuoteWhat 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.

QuoteThere 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!

MortenMacFly

Quote from: renega_666 on August 29, 2012, 09:21:25 PM
QuoteWhat 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:
class GdbCmd_RemoteTarget : public DebuggerCmd
[...]
                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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

#11
Quote from: MortenMacFly on August 30, 2012, 06:58:25 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())?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

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!]

MortenMacFly

Quote from: oBFusCATed on August 30, 2012, 08:08:52 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

Quote from: oBFusCATed on August 30, 2012, 08:08:52 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]