Re: setting unix environment variables for debugging
Re: setting unix environment variables for debugging
- Subject: Re: setting unix environment variables for debugging
- From: Chad Jones <email@hidden>
- Date: Wed, 06 Feb 2008 16:04:23 -0600
Not positive what you mean here. But from what I understand I'd probably add some UNIX calls to my code to control the creation
of symbolic links. First I would add some code to my main project which would be activated by a debugger flag.
The debugger flag I would define under "Other Warning Flags" using "-D AddSyms" but of course any name could be chosen. The
debugger flags allows your configuration to be easily configured for your test environment. :) This code when activated would use
popen to get a list of the symbolic links or (alternatively system() could be used to create your symbolic links) see man popen, man system
in terminal for more information. Other UNIX commands for creating symbolic links can likewise be used. Here's some test code
below that uses the debugger flag and popen to print out a list of the files in "/". I imagine you could use something like the following
to even create or analyze symlinks using UNIX calls readlink, symlink or unlink and the like matched with the appropriate popen/system call.
Note the below code will only do anything if you have AddSyms defined.
#include <stdio.h>
int main (int argc, const char * argv[])
{
#pragma unused( argc, argv )
#if defined( AddSyms )
FILE *fp;
int status;
char path[1024];
fp = popen("ls /", "r");
if (fp == NULL)
{ /* Handle error */ }
while (fgets(path, 1024, fp) != NULL)
printf("%s", path);
status = pclose(fp);
if (status != -1)
{ printf( "Success\n" ); }
else
{ printf( "Failure\n" ); }
#endif
return 0;
}
So I guess I'm saying that you maybe shouldn't be using environment variables at all but instead use debugger flags. :) But if you
really want to use environment variables off the top of my head if you use "open /Developer/Applications/Xcode.app"
from terminal it will launch XCode and then I believe XCode will inherit the environment variables you set in terminal using setenv and the like.
>Does someone have an
>example for setting a symbolic link?
see "man symlink" in terminal? Also google. :)
> A related question is how do I verify the env var are set correctly
> before debugging?
For this I'd use UNIX popen() similar to above and check the output is what you expect. There may be other file system calls which
are more appropriate for this as well.
email@hidden wrote:
The issue of setting environment variables has come up before but I
don't think in this context. I have an application that must have
symbolic links defined for 30 files before it can be tested. How do I
set these variables before debugging in Xcode? I know about the
environment.plist and setting env var in Executable Info. The .plist
option is not very useful because the variables will change with
different test configurations. The arguments/variables panel under
Executable Info potentially may work but it has not worked in the case
I've tried - perhaps I don't have the format right. Does someone have an
example for setting a symbolic link?
A related question is how do I verify the env var are set correctly
before debugging?
Joe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden