From 2774040599d9c2e7b690467fa63800b891a2f052 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 15:37:38 +0900 Subject: [PATCH 1/8] add builtin command for lldb --- Rakefile | 2 +- lldb/lldb.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 lldb/lldb.py diff --git a/Rakefile b/Rakefile index 606d30fc..ad7a6182 100644 --- a/Rakefile +++ b/Rakefile @@ -86,7 +86,7 @@ task :install do public_binaries = ['./bin/motion'] binaries = public_binaries.dup.concat(['./bin/ios/deploy', './bin/ios/sim', './bin/osx/sim', './bin/llc', './bin/ruby', './bin/ctags', - 'lib/yard/bin/yard', 'lib/yard/bin/yardoc', 'lib/yard/bin/yri']) + 'lib/yard/bin/yard', 'lib/yard/bin/yardoc', 'lib/yard/bin/yri', './lldb/lldb.py']) data = ['./NEWS'] data.concat(Dir.glob('./lib/**/*', File::FNM_DOTMATCH)) data.delete_if { |x| true if x.include?("lib/yard/bin/") } diff --git a/lldb/lldb.py b/lldb/lldb.py new file mode 100755 index 00000000..d78a0687 --- /dev/null +++ b/lldb/lldb.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +import lldb + +def pro(debugger, command, result, internal_dict): + """ + pro(obj): inspects the given 'obj' + """ + args = command.split() + if len(args) != 1: + print pro.__doc__ + return + + cmd = "po rb_inspect(" + args[0] + ")" + lldb.debugger.HandleCommand(cmd) + + +def pri(debugger, command, result, internal_dict): + """ + pri(name): inspects the given instance variable 'name' on self + pri(rcv, name): inspects the given instance variable 'name' on 'rcv' + """ + args = command.split() + if len(args) == 1: + cmd = "po rb_inspect((void *)rb_ivar_get(self, (void *)rb_intern(" + args[0] + ")))" + elif len(args) == 2: + cmd = "po rb_inspect((void *)rb_ivar_get(" + args[0] + ", (void *)rb_intern(" + args[1] + ")))" + else: + print pri.__doc__ + return + + lldb.debugger.HandleCommand(cmd) + + +# And the initialization code to add your commands +def __lldb_init_module(debugger, internal_dict): + debugger.HandleCommand('command script add -f lldb.pro print-ruby-object') + debugger.HandleCommand('command script add -f lldb.pro pro') + debugger.HandleCommand('command script add -f lldb.pri print-ruby-ivar') + debugger.HandleCommand('command script add -f lldb.pri pri') + From 098c8c48b95da49528866df6af370750a16f8ce4 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 15:43:24 +0900 Subject: [PATCH 2/8] split the method in where save command into temporary file --- bin/sim.m | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/bin/sim.m b/bin/sim.m index b8385589..096e87ab 100644 --- a/bin/sim.m +++ b/bin/sim.m @@ -872,7 +872,7 @@ again: } static NSString * -gdb_commands_file(void) +save_debugger_command(NSString *cmds) { #if defined(SIMULATOR_IOS) # define SIMGDBCMDS_BASE @"_simgdbcmds_ios" @@ -882,6 +882,22 @@ gdb_commands_file(void) NSString *cmds_path = [NSString pathWithComponents: [NSArray arrayWithObjects:NSTemporaryDirectory(), SIMGDBCMDS_BASE, nil]]; + + NSError *error = nil; + if (![cmds writeToFile:cmds_path atomically:YES + encoding:NSASCIIStringEncoding error:&error]) { + fprintf(stderr, + "can't write gdb commands file into path %s: %s\n", + [cmds_path UTF8String], + [[error description] UTF8String]); + exit(1); + } + return cmds_path; +} + +static NSString * +gdb_commands_file(void) +{ NSString *cmds = @""\ "set breakpoint pending on\n"\ "break rb_exc_raise\n"\ @@ -902,16 +918,8 @@ gdb_commands_file(void) #endif ]; } - NSError *error = nil; - if (![cmds writeToFile:cmds_path atomically:YES - encoding:NSASCIIStringEncoding error:&error]) { - fprintf(stderr, - "can't write gdb commands file into path %s: %s\n", - [cmds_path UTF8String], - [[error description] UTF8String]); - exit(1); - } - return cmds_path; + + return save_debugger_command(cmds); } #if defined(SIMULATOR_IOS) From 060e24d3497e9cfae42cd8fc3ac748257e531b32 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 17:14:45 +0900 Subject: [PATCH 3/8] add lldb_commands_file for the initial configuration in lldb --- bin/sim.m | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/bin/sim.m b/bin/sim.m index 096e87ab..f0445ede 100644 --- a/bin/sim.m +++ b/bin/sim.m @@ -922,6 +922,34 @@ gdb_commands_file(void) return save_debugger_command(cmds); } +static NSString * +lldb_commands_file(int pid) +{ + NSString *cmds = [NSString stringWithFormat:@""\ + "process attach -p %d\n"\ + "command script import /Library/RubyMotion/lldb/lldb.py\n"\ + "breakpoint set --name rb_exc_raise\n"\ + "breakpoint set --name malloc_error_break\n", + pid]; + NSString *user_cmds = [NSString stringWithContentsOfFile: + @"debugger_cmds" encoding:NSUTF8StringEncoding error:nil]; + if (user_cmds != nil) { + cmds = [cmds stringByAppendingString:user_cmds]; + cmds = [cmds stringByAppendingString:@"\n"]; + } + if (getenv("no_continue") == NULL) { + cmds = [cmds stringByAppendingString: +#if defined(SIMULATOR_IOS) + @"continue\n" +#else + @"run\n" +#endif + ]; + } + + return save_debugger_command(cmds); +} + #if defined(SIMULATOR_IOS) - (void)session:(id)session didEndWithError:(NSError *)error { @@ -998,8 +1026,7 @@ gdb_commands_file(void) else if ([[NSFileManager defaultManager] fileExistsAtPath:lldb_path]) { gdb_task = [[NSTask launchedTaskWithLaunchPath:lldb_path arguments:[NSArray arrayWithObjects:@"-a", @"i386", - @"-p", [pidNumber description], @"-x", gdb_commands_file(), - nil]] retain]; + @"-s", lldb_commands_file([pidNumber intValue]), nil]] retain]; } else { fprintf(stderr, "can't locate a debugger (gdb `%s' or lldb `%s')\n", From 543d8de4c3290bb6d9f0b614567078a15aa0b819 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 20:50:42 +0900 Subject: [PATCH 4/8] add line in NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 66a5d7be..b6397274 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ += RubyMotion 2.7 = + + * [iOS] Fixed a bug in debugger where built-in debugger command does not + work with lldb in iOS 7 simulator. + = RubyMotion 2.6 = * Added support for iOS 7.0 Beta 4 and Xcode 5.0 DP 4. From 5285031125c440e89badc4caa0b1c91c5cbfc5b0 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 22:51:40 +0900 Subject: [PATCH 5/8] add test for Range.new --- test/test/spec/memory_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test/spec/memory_spec.rb b/test/test/spec/memory_spec.rb index fe48de3f..5064a8c9 100644 --- a/test/test/spec/memory_spec.rb +++ b/test/test/spec/memory_spec.rb @@ -302,3 +302,22 @@ describe "NSMutableArray" do $nsarray_dealloc.should == true end end + +class Range + def dealloc + $dealloc_test = true + super + end +end +describe "Range" do + before do + $dealloc_test = false + end + + it "#new should work without malloc error" do + autorelease_pool do + Range.new(10, 20) + end + $dealloc_test.should == true + end +end From 754180ed563171b83864882178359ec3aa08c897 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Aug 2013 22:53:17 +0900 Subject: [PATCH 6/8] add line in NEWS --- NEWS | 1 + vm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b6397274..8788cf1a 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ = RubyMotion 2.7 = + * fix a bug in Range.new where it would cause malloc_error_break error. * [iOS] Fixed a bug in debugger where built-in debugger command does not work with lldb in iOS 7 simulator. diff --git a/vm b/vm index 4e03d5b7..b53195a0 160000 --- a/vm +++ b/vm @@ -1 +1 @@ -Subproject commit 4e03d5b719606e85c000a5d76a9b77fea1f63b58 +Subproject commit b53195a0bfac02fa579524f66457a6aaa9cc83b4 From 785fd65d590cbfded9eedfe441ffcc1ffbce46fb Mon Sep 17 00:00:00 2001 From: Chris Radford Date: Mon, 5 Aug 2013 12:47:36 +0100 Subject: [PATCH 7/8] Update to add new status bar style Added UIStatusBarStyleLightContent as an option for status_bar_style, a new option added in iOS7. --- lib/motion/project/template/ios/config.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/motion/project/template/ios/config.rb b/lib/motion/project/template/ios/config.rb index f97be4b7..eaf17ef5 100644 --- a/lib/motion/project/template/ios/config.rb +++ b/lib/motion/project/template/ios/config.rb @@ -252,6 +252,7 @@ module Motion; module Project; when :default then 'UIStatusBarStyleDefault' when :black_translucent then 'UIStatusBarStyleBlackTranslucent' when :black_opaque then 'UIStatusBarStyleBlackOpaque' + when :light_content then 'UIStatusBarStyleLightContent' else App.fail "Unknown status_bar_style value: `#{@status_bar_style}'" end From bc2d425a0fa195dd6976a6012af6602a31b4fe01 Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 7 Aug 2013 20:37:03 +0900 Subject: [PATCH 8/8] add line in NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 8788cf1a..2deecf96 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ = RubyMotion 2.7 = * fix a bug in Range.new where it would cause malloc_error_break error. + * [iOS] Added `:light_content' as new status bar style for UIStatusBarStyle + property. Thanks to Chris Radford for the patch (pull request #116). * [iOS] Fixed a bug in debugger where built-in debugger command does not work with lldb in iOS 7 simulator.