Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17924] Enable debugger in Titanium #6493

Merged
merged 6 commits into from
Dec 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions iphone/Classes/APIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#import "TiBase.h"
#import "TiApp.h"
#import "TiExceptionHandler.h"
#ifdef TI_DEBUGGER_PROFILER
#import "TiDebugger.h"
#endif
extern NSString * const TI_APPLICATION_DEPLOYTYPE;

@implementation APIModule
Expand All @@ -24,7 +22,6 @@ -(NSString*)apiName
-(void)logMessage:(NSArray*)args severity:(NSString*)severity
{

#ifdef TI_DEBUGGER_PROFILER
NSString* lcSeverity = [severity lowercaseString];
DebuggerLogLevel level = OUT;
if ([lcSeverity isEqualToString:@"warn"]) {
Expand Down Expand Up @@ -52,15 +49,12 @@ -(void)logMessage:(NSArray*)args severity:(NSString*)severity
TiDebuggerLogMessage(level, [messages componentsJoinedByString:@" "]);
}
else
#endif
{
#ifdef TI_DEBUGGER_PROFILER
if ([TI_APPLICATION_DEPLOYTYPE isEqualToString:@"production"]) {
if (level != ERR) {
return;
}
}
#endif
NSLog(@"[%@] %@", [severity uppercaseString], [args componentsJoinedByString:@" "]);
fflush(stderr);
}
Expand Down
12 changes: 1 addition & 11 deletions iphone/Classes/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
#ifdef KROLL_COVERAGE
# include "KrollCoverage.h"
#endif
#ifdef TI_DEBUGGER_PROFILER
#import "TiDebugger.h"
#endif
extern BOOL const TI_APPLICATION_ANALYTICS;
extern NSString * const TI_APPLICATION_DEPLOYTYPE;
extern NSString * const TI_APPLICATION_GUID;
Expand Down Expand Up @@ -450,17 +448,13 @@ - (void)evalFileOnThread:(NSString*)path context:(KrollContext*)context_

// only continue if we don't have any exceptions from above
if (exception == NULL) {
#ifdef TI_DEBUGGER_PROFILER
if ([[self host] debugMode]) {
TiDebuggerBeginScript(context_,urlCString);
}
#endif
TiEvalScript(jsContext, jsCode, NULL, jsURL, 1, &exception);
#ifdef TI_DEBUGGER_PROFILER
if ([[self host] debugMode]) {
TiDebuggerEndScript(context_);
}
#endif
if (exception == NULL) {
evaluationError = NO;
}
Expand Down Expand Up @@ -913,21 +907,17 @@ -(id)require:(KrollContext*)kroll path:(NSString*)path
NSString* urlPath = (filepath != nil) ? filepath : fullPath;
NSURL *url_ = [TiHost resourceBasedURL:urlPath baseURL:NULL];
KrollWrapper* wrapper = nil;
#ifdef TI_DEBUGGER_PROFILER
const char *urlCString = [[url_ absoluteString] UTF8String];
if ([[self host] debugMode] && ![module isJSModule]) {
TiDebuggerBeginScript([self krollContext],urlCString);
}
#endif
NSString * dataContents = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
wrapper = [self loadCommonJSModule:dataContents withSourceURL:url_];
[dataContents release];

#ifdef TI_DEBUGGER_PROFILER

if ([[self host] debugMode] && ![module isJSModule]) {
TiDebuggerEndScript([self krollContext]);
}
#endif
if (![wrapper respondsToSelector:@selector(replaceValue:forKey:notification:)]) {
[self setCurrentURL:oldURL];
@throw [NSException exceptionWithName:@"org.appcelerator.kroll"
Expand Down
6 changes: 0 additions & 6 deletions iphone/Classes/KrollContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
#import "TiLocale.h"

#include <pthread.h>
#ifdef TI_DEBUGGER_PROFILER
#import "TiDebugger.h"
#endif
#import "TiProfiler/TiProfiler.h"
#import "TiExceptionHandler.h"

Expand Down Expand Up @@ -946,10 +944,8 @@ -(void)stop
stopped = YES;
if (debugger!=NULL)
{
#ifdef TI_DEBUGGER_PROFILER
TiObjectRef globalRef = TiContextGetGlobalObject(context);
TiDebuggerDestroy(self,globalRef,debugger);
#endif
debugger = NULL;
}
[condition signal];
Expand Down Expand Up @@ -1168,11 +1164,9 @@ -(void)main

// TODO: We might want to be smarter than this, and do some KVO on the delegate's
// 'debugMode' property or something... and start/stop the debugger as necessary.
#ifdef TI_DEBUGGER_PROFILER
if ([[self delegate] shouldDebugContext]) {
debugger = TiDebuggerCreate(self,globalRef);
}
#endif
if ([[self delegate] shouldProfileContext]) {
TiProfilerEnable(globalRef,context);
}
Expand Down
8 changes: 1 addition & 7 deletions iphone/Classes/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
#import "TiErrorController.h"
#import "NSData+Additions.h"
#import "ImageLoader.h"
#ifdef TI_DEBUGGER_PROFILER
#import "TiDebugger.h"
#endif
#import "TiProfiler/TiProfiler.h"
#import <QuartzCore/QuartzCore.h>
#import <AVFoundation/AVFoundation.h>
Expand Down Expand Up @@ -182,7 +180,6 @@ - (void)boot

sessionId = [[TiUtils createUUID] retain];
TITANIUM_VERSION = [[NSString stringWithCString:TI_VERSION_STR encoding:NSUTF8StringEncoding] retain];
#ifdef TI_DEBUGGER_PROFILER
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"debugger" ofType:@"plist"];
if (filePath != nil) {
NSMutableDictionary *params = [[[NSMutableDictionary alloc] initWithContentsOfFile:filePath] autorelease];
Expand Down Expand Up @@ -213,8 +210,7 @@ - (void)boot
}
#endif
}
#endif
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"profiler" ofType:@"plist"];
filePath = [[NSBundle mainBundle] pathForResource:@"profiler" ofType:@"plist"];
if (!self.debugMode && filePath != nil) {
NSMutableDictionary *params = [[[NSMutableDictionary alloc] initWithContentsOfFile:filePath] autorelease];
NSString *host = [params objectForKey:@"host"];
Expand Down Expand Up @@ -938,9 +934,7 @@ - (void)dealloc
RELEASE_TO_NIL(remoteNotification);
RELEASE_TO_NIL(splashScreenImage);
if ([self debugMode]) {
#ifdef TI_DEBUGGER_PROFILER
TiDebuggerStop();
#endif
}
RELEASE_TO_NIL(backgroundServices);
RELEASE_TO_NIL(localNotification);
Expand Down
4 changes: 0 additions & 4 deletions iphone/Classes/TiBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
*/
#import "TiBase.h"
#import "TiApp.h"
#ifdef TI_DEBUGGER_PROFILER
#import "TiDebugger.h"
#endif
#include <stdarg.h>
#include <pthread.h>
#include <sys/time.h>
Expand Down Expand Up @@ -92,9 +90,7 @@ void TiLogMessage(NSString* str, ...) {

NSString* message = [[NSString alloc] initWithFormat:str arguments:args];
if ([[TiApp app] debugMode]) {
#ifdef TI_DEBUGGER_PROFILER
TiDebuggerLogMessage(OUT, message);
#endif
}
else {

Expand Down
31 changes: 31 additions & 0 deletions iphone/Classes/TiDebugger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2011 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#include "TiBase.h"

typedef enum {
OUT,
LOG_DEBUG, // Have to distinguish from the DEBUG macro
TRACE,
WARN,
ERR
} DebuggerLogLevel;

#ifdef __cplusplus
#define EXTERN_FUNC extern "C"
#else
#define EXTERN_FUNC extern
#endif

EXTERN_FUNC void* TiDebuggerCreate(KrollContext*,TiObjectRef);
EXTERN_FUNC void TiDebuggerDestroy(KrollContext*,TiObjectRef,void*);
EXTERN_FUNC void TiDebuggerStart(NSString*,NSInteger);
EXTERN_FUNC void TiDebuggerStop();
EXTERN_FUNC void TiDebuggerBeginScript(KrollContext*,const char*);
EXTERN_FUNC void TiDebuggerEndScript(KrollContext*);
EXTERN_FUNC void TiDebuggerLogMessage(DebuggerLogLevel level,NSString* message);
EXTERN_FUNC void TiDebuggerDiscoveryStart(NSString*, NSArray*, void(^)(NSString *, NSInteger));
8 changes: 8 additions & 0 deletions iphone/iphone/Titanium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@
B6C5206118035AF3002471C6 /* TiUIiOSAttributedStringProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B6C5206018035AF3002471C6 /* TiUIiOSAttributedStringProxy.m */; };
B6C5206218035AF3002471C6 /* TiUIiOSAttributedStringProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B6C5206018035AF3002471C6 /* TiUIiOSAttributedStringProxy.m */; };
B6C5206318035AF3002471C6 /* TiUIiOSAttributedStringProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B6C5206018035AF3002471C6 /* TiUIiOSAttributedStringProxy.m */; };
B6DFC5CF1A3B902300A857B7 /* libti_ios_debugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAA4B2AD134E3DBD00AB6011 /* libti_ios_debugger.a */; };
B6DFC5D01A3B902300A857B7 /* libti_ios_debugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAA4B2AD134E3DBD00AB6011 /* libti_ios_debugger.a */; };
B6DFC5D11A3B902400A857B7 /* libti_ios_debugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAA4B2AD134E3DBD00AB6011 /* libti_ios_debugger.a */; };
BB26FC8019AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = BB26FC7D19AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m */; };
BB26FC8119AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = BB26FC7D19AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m */; };
BB26FC8219AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = BB26FC7D19AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m */; };
Expand Down Expand Up @@ -1473,6 +1476,7 @@
B6A0A2B0180DF4DA00E3FAA6 /* TiUIiOSTransitionAnimationProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUIiOSTransitionAnimationProxy.m; sourceTree = "<group>"; };
B6C5205F18035AF3002471C6 /* TiUIiOSAttributedStringProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiUIiOSAttributedStringProxy.h; sourceTree = "<group>"; };
B6C5206018035AF3002471C6 /* TiUIiOSAttributedStringProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUIiOSAttributedStringProxy.m; sourceTree = "<group>"; };
B6DFC5CE1A3B8FC200A857B7 /* TiDebugger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TiDebugger.h; path = ../Classes/TiDebugger.h; sourceTree = "<group>"; };
BB26FC7C19AB13B9007A35AF /* TiAppiOSNotificationActionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiAppiOSNotificationActionProxy.h; sourceTree = "<group>"; };
BB26FC7D19AB13B9007A35AF /* TiAppiOSNotificationActionProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiAppiOSNotificationActionProxy.m; sourceTree = "<group>"; };
BB26FC7E19AB13B9007A35AF /* TiAppiOSNotificationCategoryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiAppiOSNotificationCategoryProxy.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1558,6 +1562,7 @@
24CA8C8E111167B60084E2DE /* libsqlite3.dylib in Frameworks */,
24CA8C90111167B60084E2DE /* libz.dylib in Frameworks */,
24CA8CED1111689B0084E2DE /* AudioToolbox.framework in Frameworks */,
B6DFC5CF1A3B902300A857B7 /* libti_ios_debugger.a in Frameworks */,
24CA8CF4111168AE0084E2DE /* MediaPlayer.framework in Frameworks */,
24CA8CFB111168C30084E2DE /* AVFoundation.framework in Frameworks */,
24EB0A58111E1BAE001DC2D1 /* libxml2.dylib in Frameworks */,
Expand Down Expand Up @@ -1591,6 +1596,7 @@
24D8E4A0119B9D8A00F8CAA6 /* MapKit.framework in Frameworks */,
24D8E4A1119B9D8A00F8CAA6 /* MessageUI.framework in Frameworks */,
24D8E4A2119B9D8A00F8CAA6 /* MobileCoreServices.framework in Frameworks */,
B6DFC5D01A3B902300A857B7 /* libti_ios_debugger.a in Frameworks */,
24D8E4A3119B9D8A00F8CAA6 /* OpenGLES.framework in Frameworks */,
24D8E4A4119B9D8A00F8CAA6 /* QuartzCore.framework in Frameworks */,
24D8E4A5119B9D8A00F8CAA6 /* SystemConfiguration.framework in Frameworks */,
Expand Down Expand Up @@ -1630,6 +1636,7 @@
DABB37A912E8CB280026A6EA /* MapKit.framework in Frameworks */,
DABB37AA12E8CB280026A6EA /* MessageUI.framework in Frameworks */,
DABB37AB12E8CB280026A6EA /* MobileCoreServices.framework in Frameworks */,
B6DFC5D11A3B902400A857B7 /* libti_ios_debugger.a in Frameworks */,
DABB37AC12E8CB280026A6EA /* OpenGLES.framework in Frameworks */,
DABB37AD12E8CB280026A6EA /* QuartzCore.framework in Frameworks */,
DABB37AE12E8CB280026A6EA /* SystemConfiguration.framework in Frameworks */,
Expand Down Expand Up @@ -1736,6 +1743,7 @@
24CA8903111160C30084E2DE /* Thirdparty */ = {
isa = PBXGroup;
children = (
B6DFC5CE1A3B8FC200A857B7 /* TiDebugger.h */,
844812C21A1D49FB00FBE03A /* TiProfiler */,
8488C04E1A14079200B01A87 /* JavaScriptCore */,
312E36BE190B06D9008EAB8D /* APSAnalytics */,
Expand Down
Binary file modified iphone/lib/libti_ios_debugger.a
Binary file not shown.