将应用程序部署到越狱版iPhone后,奇怪的GDB行为 [英] Strange GDB behaviour once application is deployed to a jailbroken iPhone

查看:182
本文介绍了将应用程序部署到越狱版iPhone后,奇怪的GDB行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作一个应用程序,它通过NSTask向GDB发送命令,并将输出指向UITextView。它适用于Mac(iOS模拟器)。但是,当部署到实际设备(iPhone)时,它不会在命令info registers后显示任何寄存器。代码如下:

   - (void)viewDidLoad 
{
self.title = @GDB;

NSLog(@用于GDB执行的Pid是:%@,pid);

UIBarButtonItem * btnClicked = [[UIBarButtonItem alloc]
initWithTitle:@Commands
style:UIBarButtonItemStyleBordered
target:self
action:@selector( btnClicked :)]
self.navigationItem.rightBarButtonItem = btnClicked;
[btnClicked release];


stringInput = @info registers;



task = [[NSTask alloc] init];
[task setLaunchPath:@/ usr / bin / gdb];


参数;
arguments = [NSArray arrayWithObjects:@abc,pid,nil];
[task setArguments:arguments];




//
dataInput = [stringInput dataUsingEncoding:NSUTF8StringEncoding];



outputPipe;
outputPipe = [NSPipe管道];
[task setStandardOutput:outputPipe];

//
inputPipe;
inputPipe = [NSPipe pipe];
[task setStandardInput:inputPipe];


taskOutput;
taskOutput = [outputPipe fileHandleForReading];

//
taskInput;
taskInput = [inputPipe fileHandleForWriting];



[任务发布];


[[[standard standardInput] fileHandleForWriting] writeData:dataInput];
close([taskInput fileDescriptor]);


dataOutput;
dataOutput = [taskOutput readDataToEndOfFile];




NSString * stringOutput;
stringOutput = [[NSString alloc] initWithData:dataOutput encoding:NSUTF8StringEncoding];
NSLog(@GDB输出:\%%@,stringOutput);

// NSLog(@GDB Input:\\\
@,stringInput);





// [字符串发布];
[任务发布];
[参数发布];

textView = [[UITextView alloc] initWithFrame:CGRectMake(8,17,330,440)];


textView.editable = NO;
textView.scrollEnabled = YES;
[self.view addSubview:textView];

textView.text = [textView.text stringByAppendingString:stringOutput];

[super viewDidLoad];


$ / code>

IOS Simulator上的输出如下所示(x86寄存器)





实际设备(iPhone)上的输出如下所示:





  RE:注意:启动:com.apple.gdb 
abc:没有这样的文件或目录
// 420:没有这样的文件或目录
无法访问process-id 420的任务:(os / kern)失败。
该程序现在没有寄存器。
2011-08-29 09:10:05.923 TableViewController_09 [421:507] GDB输出:
GNU gdb 6.3.50.20050815-cvs(Fri May 20 08:08:42 UTC 2011)
Copyright 2004 Free Software Foundation,Inc.
GDB是GNU通用公共许可证所涵盖的免费软件,在某些情况下,您可以随时更改和/或分发它。
输入show copying查看条件。
GDB绝对没有担保。输入显示保修以获取详细信息。
这个GDB配置为--host = arm-apple-darwin9 --target =...
(gdb)(gdb)
pre>

作为附注,我甚至尝试添加参数-arch armv7 *。它仍然无法附加到指定的过程。



编辑:我可能已经找到了我的困境的来源。当我尝试通过应用程序在我的iPhone中调用gdb时,它在控制台中显示出来:

  Sep 8 11:13:26 unknown sandboxd< Notice> ;: gdb(2137)否认mach-priv-task-port 

处理:gdb [2137]
路径:/ usr / bin / gdb
加载地址:0x1000
标识符:gdb
版本:??? (1.0)
代码类型:ARM(Native)
父进程:TableViewController_09 [2135]

日期/时间:2011-09-08 11:13:25.948 +0800 $

$ b Backtrace:
0 libsystem_kernel.dylib 0x36223c8c task_for_pid + 8
1 gdb 0x001e4428 macosx_child_attach + 44(macosx-nat-i​​nferior.c:1781)
2 gdb 0x00082f18 attach_command + 116(infcmd.c:3089)
3 gdb 0x000a3788 catch_command_errors + 100(exceptions.c:540)
4 gdb 0x000a53e4 captured_main + 2632(main.c:888)
5 gdb 0x000a3838 catch_errors + 104(exceptions.c:525)
6 gdb 0x000a4988 gdb_main + 56(main.c:1033)
7 gdb 0x0000224c main + 40(gdb.c:36)
8 gdb 0x0000217c _start + 312
9 gdb 0x00002018 start + 24
10 gdb 0x001e3dac macosx_lookup_task + 1596(macosx-nat-i​​nferior.c:1522)

二进制映像:
0x1000 - 0x2fbf5b + gdb arm / usr / bin / gdb
0x36214000 - 0x3622bfff libsystem_kernel.dylib armv7< a06ec84e53bf32098b63c0caebdb45b6> /usr/lib/system/libsystem_kernel.dylib

如果有人知道解决此问题的方法,请请分享。我一直在寻找一个解决方案几周无济于事......

解决方案

最后找到了解决办法。我所要做的就是将我的应用程序安装到我的iPhone上的/ Application文件夹中并设置它。这样,它将以root权限运行,并因此被允许在Apple的沙箱限制之外运行。


Im trying to make an application which sends commands to GDB via NSTask and directs the output to the UITextView. It works well on the Mac (iOS Simulator). However, when deployed to the actual device (iPhone), it does not display any registers after the command "info registers" The code is as such :

 - (void)viewDidLoad
{
self.title = @"GDB";

NSLog(@"Pid for GDB execution is :%@", pid);

UIBarButtonItem *btnClicked = [[UIBarButtonItem alloc] 
                               initWithTitle:@"Commands"                                            
                               style:UIBarButtonItemStyleBordered 
                               target:self 
                               action:@selector(btnClicked:)];
self.navigationItem.rightBarButtonItem = btnClicked;
[btnClicked release];


stringInput = @"info registers";



task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/gdb"];


arguments;
arguments = [NSArray arrayWithObjects:@"abc", pid, nil];
[task setArguments: arguments];




//
dataInput = [stringInput dataUsingEncoding:NSUTF8StringEncoding];



outputPipe;
outputPipe = [NSPipe pipe];
[task setStandardOutput: outputPipe];

//
inputPipe;
inputPipe = [NSPipe pipe];
[task setStandardInput:inputPipe];


taskOutput;
taskOutput = [outputPipe fileHandleForReading];

//
taskInput;
taskInput = [inputPipe fileHandleForWriting];



[task launch];


[[[task standardInput] fileHandleForWriting] writeData:dataInput];
close([taskInput fileDescriptor]);


dataOutput;
dataOutput = [taskOutput readDataToEndOfFile];




NSString *stringOutput;
stringOutput = [[NSString alloc] initWithData: dataOutput encoding: NSUTF8StringEncoding];
NSLog (@"GDB Output:\n%@", stringOutput);

//NSLog(@"GDB Input:\n@", stringInput);





//[string release];
[task release];
[arguments release];

textView = [[UITextView alloc]initWithFrame:CGRectMake(8,17,330,440)];


textView.editable=NO;
textView.scrollEnabled=YES;
[self.view addSubview:textView];

textView.text = [textView.text stringByAppendingString:stringOutput];

    [super viewDidLoad];

}

The output on the IOS Simulator looks like this (x86 registers)

The output on the actual device (iPhone) looks like this :

The build output when run on the iPhone looks like this :

RE:Notice: Launching: com.apple.gdb
abc: No such file or directory
//420: No such file or directory
Unable to access task for process-id 420: (os/kern) failure.
The program has no registers now.
2011-08-29 09:10:05.923 TableViewController_09[421:507] GDB Output:
GNU gdb 6.3.50.20050815-cvs (Fri May 20 08:08:42 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=arm-apple-darwin9 --target="...
(gdb) (gdb) 

As a side note, I have even tried to add the arguments -arch armv7*. It is still unable to attach to the specified process.

Edit : I may have found the source of my woes. This showed up in the console when I tried invoking gdb in my iPhone through the application :

Sep  8 11:13:26 unknown sandboxd[2138] <Notice>: gdb(2137) deny mach-priv-task-port

Process:         gdb [2137]
Path:            /usr/bin/gdb
Load Address:    0x1000
Identifier:      gdb
Version:         ??? (1.0)
Code Type:       ARM (Native)
Parent Process:  TableViewController_09 [2135]

Date/Time:       2011-09-08 11:13:25.948 +0800
OS Version:      iPhone OS 4.3.3 (8J2)
Report Version:  104

Backtrace:
0   libsystem_kernel.dylib          0x36223c8c task_for_pid + 8
1   gdb                             0x001e4428 macosx_child_attach + 44 (macosx-nat-inferior.c:1781)
2   gdb                             0x00082f18 attach_command + 116 (infcmd.c:3089)
3   gdb                             0x000a3788 catch_command_errors + 100 (exceptions.c:540)
4   gdb                             0x000a53e4 captured_main + 2632 (main.c:888)
5   gdb                             0x000a3838 catch_errors + 104 (exceptions.c:525)
6   gdb                             0x000a4988 gdb_main + 56 (main.c:1033)
7   gdb                             0x0000224c main + 40 (gdb.c:36)
8   gdb                             0x0000217c _start + 312
9   gdb                             0x00002018 start + 24
10  gdb                             0x001e3dac macosx_lookup_task + 1596 (macosx-nat-inferior.c:1522)

Binary Images:
    0x1000 -   0x2fbf5b +gdb arm  /usr/bin/gdb
0x36214000 - 0x3622bfff  libsystem_kernel.dylib armv7  <a06ec84e53bf32098b63c0caebdb45b6> /usr/lib/system/libsystem_kernel.dylib

If any one knows a way around this problem, please kindly share. I have been searching for a solution for weeks to no avail...

解决方案

Finally found a way around it. All I had to do was to install my app into the /Application folder on my iPhone and setuid it. This way, it would run with root privileges, and would thus be allowed to run outside Apple's sandbox limitations.

这篇关于将应用程序部署到越狱版iPhone后,奇怪的GDB行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆