diff --git a/NEWS b/NEWS index 66a5d7be..2deecf96 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ += 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. + = RubyMotion 2.6 = * Added support for iOS 7.0 Beta 4 and Xcode 5.0 DP 4. 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/bin/sim.m b/bin/sim.m index b8385589..f0445ede 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,36 @@ 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 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"]; } - return cmds_path; + 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) @@ -990,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", 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 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') + 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 diff --git a/vm b/vm index 4e03d5b7..b53195a0 160000 --- a/vm +++ b/vm @@ -1 +1 @@ -Subproject commit 4e03d5b719606e85c000a5d76a9b77fea1f63b58 +Subproject commit b53195a0bfac02fa579524f66457a6aaa9cc83b4