valgrind 和 iOS SDK 4.2?

发布于 2024-10-10 01:50:56 字数 1723 浏览 5 评论 0原文

使用 valgrind 运行 iOS 4.2 应用程序时遇到问题。

我从 Macports 安装了 valgrind 3.6.0-SVN。 Xcode 3.2.5。

当我修改 main() 来运行 valgrind 时,我得到以下输出:

Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
open$UNIX2003 called from function _vgrZU_libSystemZdZaZddylib_arc4random in image vgpreload_core-x86-darwin.so.
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.

==99640== 
==99640== Process terminating with default action of signal 6 (SIGABRT)
==99640==    at 0x8B5DEF6: __kill (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8BF062C: raise (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8C066E3: abort (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x33F2547: __springboard_unimplemented (in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib)
==99640==    by 0x33FC208: open$UNIX2003 (in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib)
==99640==    by 0x1AAD6F3: arc4random (vg_preloaded.c:163)
==99640==    by 0x8AFFB7E: create_scalable_zone (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8AFF7EA: _malloc_initialize (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B23449: malloc_create_zone (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B233F8: _dispatch_ccache_init (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B21E0D: dispatch_once_f (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B233D3: _dispatch_continuation_alloc_from_heap (in /usr/lib/libSystem.B.dylib)

错误似乎非常清楚。我该如何解决这个问题?我听说过在 SDK 3.x 上运行 valgrind 的成功尝试。发生了什么变化?

还有其他建议吗?

Having problems running iOS 4.2 apps with valgrind.

I installed valgrind 3.6.0-SVN from Macports. XCode 3.2.5.

When I modify my main() to run valgrind I get the following output:


Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
open$UNIX2003 called from function _vgrZU_libSystemZdZaZddylib_arc4random in image vgpreload_core-x86-darwin.so.
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.

==99640== 
==99640== Process terminating with default action of signal 6 (SIGABRT)
==99640==    at 0x8B5DEF6: __kill (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8BF062C: raise (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8C066E3: abort (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x33F2547: __springboard_unimplemented (in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib)
==99640==    by 0x33FC208: open$UNIX2003 (in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib)
==99640==    by 0x1AAD6F3: arc4random (vg_preloaded.c:163)
==99640==    by 0x8AFFB7E: create_scalable_zone (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8AFF7EA: _malloc_initialize (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B23449: malloc_create_zone (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B233F8: _dispatch_ccache_init (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B21E0D: dispatch_once_f (in /usr/lib/libSystem.B.dylib)
==99640==    by 0x8B233D3: _dispatch_continuation_alloc_from_heap (in /usr/lib/libSystem.B.dylib)

The error seems to be pretty clear. How can I fix this? I've heard of successful attempts running valgrind on SDK 3.x. What has changed?

Any other advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦初启 2024-10-17 01:50:56

这是一个可怕的黑客行为,我不知道这意味着什么......但它确实解决了问题:

在你的 valgrind 源代码中,打开 vg_preloaded.c 并找到第 163 行(在你的堆栈跟踪中引用)。将那里的代码更改为:

/*    if (rnd < 0) rnd = open("/dev/random", O_RDONLY);                     
      read(rnd, &result, sizeof(result)); */
result = random();

这似乎是阻止 valgrind 工作的唯一因素...您的情况可能会有所不同。

This is a hideous hack, and I have no idea what the implications are... but it did solve the problem:

In your valgrind source, open up vg_preloaded.c and find line 163 (referenced in your stack trace there). Change the code that is there to:

/*    if (rnd < 0) rnd = open("/dev/random", O_RDONLY);                     
      read(rnd, &result, sizeof(result)); */
result = random();

This appears to be the only thing that keeps valgrind from working... Your mileage may vary.

冧九 2024-10-17 01:50:56

将以下内容添加到 Objective-C 文件之一的顶部:

#import "stdio.h"
#import "fcntl.h"

int open$UNIX2003(const char *pathname, int flags, mode_t mode) {
    return open(pathname, flags, mode);
}

int read$UNIX2003(int fildes, void *buf, size_t nbyte) {
    return read(fildes, buf, nbyte);
}

int close$UNIX2003(int fildes) {
    return close(fildes);
}

Add the following to the top of one of your Objective-C files:

#import "stdio.h"
#import "fcntl.h"

int open$UNIX2003(const char *pathname, int flags, mode_t mode) {
    return open(pathname, flags, mode);
}

int read$UNIX2003(int fildes, void *buf, size_t nbyte) {
    return read(fildes, buf, nbyte);
}

int close$UNIX2003(int fildes) {
    return close(fildes);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文