Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Ubuntu gdb cores Xcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ubuntu gdb cores Xcode



On Fri, Nov 14, 2008 at 2:06 AM, Steve Checkoway <email@hidden> wrote:
>Without showing more code, it's pretty hard to guess what's going wrong.
>
>HTH,
1) What does HTH mean?

2) Here is more code.  Even in these comments, I'm reminded that I was
struggling with a previous Segmentation fault around fgets.  Maybe I
have an unhandled case but only on OSX, not Ubuntu?!?

3) Even if I may have logged in using ssh -X to run the wine app that
writes to the pipe, after a while apparently the X server is not happy
(if the shell was sitting around idle) and I have to relogin.  Someone
suggested I try ssh -Y (which I have not done yet), but the printf is
just to notify me about the "X error" case.

4) Can I use sscanf for a variable case like how I use StreamSymbol,
instead of the constant case as in "GBPCHF" we discussed?  sscanf
looks more efficient than dealing with strtok and atof, etc.

5) Did you compile blarg on the fly with a heredoc?  If I end up using
Ubuntu, I would use a 3rd party host and would like to not keep the
strategy on that remote server, and would prefer to pass the strategy
encrypted on the fly.  One method, concluded to be an unwieldy
approach in a different discussion, was to try to execute code from
memory (like in a byte array) without having a file touch the file
server.  But if netcat "nc" or something similar could be used, maybe
a "loader" program could be on the remote server and the strategy may
be able to be loaded on the fly through stdin?
loader < nc ...?

6) I thought free() only executes if what is passed is not NULL, but
throughout my code I have added additional checks due to double free
errors reported.  Also, I have some pointers explicitly set to NULL
after a free.

Thanks for any help, advice, and improvements you may provide.

//main.c BEGIN
#include "strategist.h" //which eventually...#include
<stdbool.h>...char StreamSymbol[7];...

int main (int argc, const char * argv[]) {
	if(argc > 1){
		strncpy(StreamSymbol, argv[1], 6);
	}else{
		strncpy(StreamSymbol, "EURUSD", 6);
	}
	StreamSymbol[6] = '\0';
	printf("Strategist for [%s]\n", StreamSymbol);
	Strategist* strategist = Strategist_Construct();
	while(strategist->shouldWatchMarket){
		if(!Strategist_ShouldStrategize(strategist)){
			sleep(strategist->sleepSeconds);
		}
	}
	Strategist_Destruct(strategist);
	return (0);
}
//TO DO: Take a look at monit ubuntugeek and howtoforge or launchd on osx
//main.c END

//strategist.c BEGIN
...
bool Strategist_ShouldStrategize(Strategist* strategist){
	static double lastBid = 0.0;
	static double lastAsk = 0.0;
	char stream[StreamSize];
	char raw[32];
	char* c1;
	char* c2;
	double bid, ask;
	while(fgets(stream, StreamSize, stdin) != NULL){
//printf("STREAM:%s", stream);//ON DEBUG, SEEMS TO EMBED nc command
INTO STREAM, CAUSING A SEGMENTATION FAULT {OLD ERROR - COULD BE
RELATED}
	// Parse for:
	// AccountInfo										// [AI-
	// Trade Record x out of n records (Open Positions)	// [TR-x/n-
	// Got Quote										// [GQ-
	// PID and Port for PBS started at datetime			// FX_ProxyBrokerServer
YYYY-MM-DD HH:MM:SS.sssss PID:aPID listening on port {aPort}
		char* streamCopy = strdup(stream);
		if(strstr(stream, "Make sure that your X server is running and that
$DISPLAY is set correctly") != NULL){
			printf("Make sure that your X server is running and that $DISPLAY
is set correctly...\nIN OTHER WORDS...RELOGIN FROM xterm\n");
			printf("Shutting Down [X error]...shouldWatchMarket set to false.\n");
			strategist->shouldWatchMarket = false;
		}else if(strstr(stream, "Error setting pumping mode [some error]") != NULL){
			printf("Shutting Down [pumping mode error]...shouldWatchMarket set
to false.\n");
			strategist->shouldWatchMarket = false;
		}else if(strstr(stream, "[AI") != NULL){
//TO DO: Make more efficient with sscanf
			Trader_updateAccountInfoFromStream(strategist->streamTrader, stream+4);
		}else if(strstr(stream, "[TR-") != NULL){
//TO DO: Make more efficient with sscanf
			Strategist_ApplyExitStrategy(strategist, stream+4);
		}else if(stream[0] == '[' && strstr(stream, "[GQ-") != NULL &&
strstr(stream, StreamSymbol) != NULL){
//TO DO: Make more efficient with sscanf
			strncpy(raw, stream+29, sizeof(raw));
			c1 = strtok(raw, "/");
			c2 = strtok(NULL, "]");
			bid = atof(c1);
			ask = atof(c2);
			if(lastBid != bid || lastAsk != ask){
				lastBid = bid;
				lastAsk = ask;
				StudyManager_add(strategist->streamTickInfoEURUSD, bid, ask);
				if(!strategist->isStrategizing){
					strategist->isStrategizing = true;
					Strategist_CopyStreamInfoToThreadInfo(strategist);
					if(pthread_create(&Strategist_ThreadId, NULL,
Strategist_Strategize, strategist) != 0){
						// Thread was not created. (!=0)
						strategist->isStrategizing = false;
					}else{
						pthread_detach(Strategist_ThreadId);
					}
				}
			}
		}else if(strstr(stream, "FX_ProxyBrokerServer") != NULL &&
strstr(stream, "PID:") != NULL && strstr(stream, "listening on port
{") != NULL){
//TO DO: Make more efficient with sscanf
			Trader_updateTraderInfoFromStream(strategist->streamTrader, stream);
		}else{
			if(streamCopy){
//UNCOMMENT TO SHOW UNHANDLED				printf("*UNHANDLEDSTREAM[%s]*\n", streamCopy);
				free(streamCopy);
			}
		}
	}
	return strategist->shouldStrategize;
}
...
//strategist.c END
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: Steve Checkoway <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: Steve Checkoway <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: Steve Checkoway <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.