- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是在 M1 mini 上运行的,运行 11.1 和更新的 Xcode。 (已应用所有待定更新。)SIP 尚未禁用(如果可以的话,在 M1 上)。
我们有一个程序用于测试正在移植的应用程序中的 mmap()
故障。我们像这样构建测试程序:
cc -v -arch arm64 -m64 -Wl,-no_adhoc_codesign -o mapfail mapfail.c
然后,我们签名。它似乎已正确签名:
@macarm[git:master]$ codesign -vvv mapfail
mapfail: valid on disk
mapfail: satisfies its Designated Requirement
@macarm[git:master]$
我们在系统上启用了开发者模式。我们还将我的用户添加到 _developer
组。我的用户不是管理员,但我作为一个用户尝试过并得到了同样的结果。
当我们运行程序时,它遇到了一个段错误 (SIGSEGV),所以我们想用 lldb
调试它,但发生了这种情况:
@macarm[git:master]$ lldb mapfail
(lldb) target create "mapfail"
Current executable set to '/Users/layer/mapfail' (arm64).
(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))
(lldb)
即使在 Apple 开发者论坛上搜索也没有找到任何信息。
mapfail.c
的代码:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <mach/mach.h>
#include <mach/machine/vm_param.h>
#define nat long
#define UseMAP_ANON
/* define UseDevZero */
#define FIROUNDUP(a, n) (((a) + ((n) - 1)) & ~((n) - 1))
#define FIROUNDDOWN(a, n) ((a) & ~((n) - 1))
int bucket_o_zeros = -1;
int ChunkSize;
# ifdef UseMAP_ANON
# define FIMAP_ANON MAP_ANON
# else
# define FIMAP_ANON 0
# endif
typedef struct {
char *base; /* lowest address -- 64k aligned */
char *pos; /* 1+ highest address allocated */
char *commit; /* 1+ highest address committed */
} heap_descriptor;
heap_descriptor test1, test2;
unsigned nat test1_base, test1_size;
int
ok_to_map(unsigned nat base, unsigned nat top)
{
/* check if the specified memory is free */
unsigned nat address = base;
vm_size_t size;
mach_port_t object_name;
task_t task = mach_task_self();
struct vm_region_basic_info_64 info;
mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64;
kern_return_t retval;
int res = 0;
retval = vm_region_64(task, &address, &size, VM_REGION_BASIC_INFO_64,
(vm_region_info_64_t)&info, &info_count, &object_name);
if (retval == KERN_NO_SPACE) {
res = 1;
} else if ((retval == KERN_SUCCESS) && (address > top)) {
res = 1;
}
if (object_name != MACH_PORT_NULL)
mach_port_deallocate(mach_task_self(), object_name);
printf("maping from 0x%lx to 0x%lx is %s\n", base, top, res ? "OK" : "BAD");
return res;
}
char *
setup_heap( heap_descriptor *hd, unsigned nat base, unsigned nat size)
{
/* allocate memory at the given address, and return the address
* which was allocated
*/
char *res = (char *)MAP_FAILED;
/* initial setup of heap when there is nothing to map in or commit */
base = FIROUNDDOWN(base, ChunkSize);
size = FIROUNDUP(size, ChunkSize);
/* we demand that OS puts memory at our base, so we can grow later */
if (base == 0 || ok_to_map(base, base+size)) {
res = (char *) mmap((void *) base, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | FIMAP_ANON | (base ? MAP_FIXED : 0),
bucket_o_zeros, 0);
}
if (res != (char *) MAP_FAILED) {
/* success - check alignment */
if (base == 0) {
nat diff;
base = (unsigned nat) res;
res = (char *) FIROUNDUP((nat) res, ChunkSize);
diff = ((unsigned nat)res - base);
if (diff > 0) {
/* this had been over-requested already */
size -= ChunkSize;
/* must munmap the two ends */
munmap((caddr_t) base, diff);
munmap((caddr_t) (res + size), diff);
}
}
/* initialize the heap descriptor */
hd->pos = hd->base = res;
hd->commit = (char *) (hd->base + size);
return hd->base;
} else {
return 0; /* failure */
}
}
int
try_setup_heap(char *kind, heap_descriptor *hd, unsigned nat base, unsigned nat size)
{
/* try to allocate where first requested, and then let the system decide.
* return true or false depending on whether it worked.
*/
char *result_base;
base = FIROUNDUP(base,ChunkSize);
size = FIROUNDUP(size,ChunkSize);
/* ask for a specific area */
if (setup_heap(hd, base, size)) return 1; /* success */
/* now ask for any location */
if ((result_base = setup_heap(hd, 0, size + ChunkSize)) == 0) {
fprintf(stderr,
"Unable to reserve at %ld (0x%lx) bytes of memory for the %s heap\n",
size, size, kind);
return 0;
} else {
fprintf(stderr,
"Unable to reserve 0x%lx for the %s heap,\n using 0x%lx instead\n",
base, kind, (unsigned nat) result_base);
return 1;
}
}
int main(int argc, char **argv, char**envp)
{
ChunkSize = getpagesize();
#if defined(UseDevZero)
if(bucket_o_zeros == -1){
bucket_o_zeros = open("/dev/zero", O_RDWR);
}
#endif
if (argc > 2) {
sscanf(argv[1], "%lx", &test1_base);
sscanf(argv[2], "%lx", &test1_size);
if (try_setup_heap("test1", &test1, test1_base, test1_size)) {
printf("test1 heap mapped from 0x%lx to 0x%lx\n",
(unsigned nat) test1.base, (unsigned nat)test1.commit);
} else {
printf("test1 not mapped\n");
}
} else {
unsigned nat addr = 0x100000000;
unsigned nat size = 0x100000;
int i, n, didit=0;;
sscanf(argv[1], "%d", &n);
for (i=0; i < n; i++) {
if (try_setup_heap("test2", &test2, addr, size)) {
printf("test1 heap mapped from 0x%lx to 0x%lx\n",
(unsigned nat) test2.base, (unsigned nat)test2.commit);
didit++;
}
addr += 0x100000000;
}
printf("Total mappings: %d\n", didit);
}
}
/*
* To compile on M1 with debugging:
* cc -v -arch arm64 -m64 -Wl,-no_adhoc_codesign -o mapfail mapfail.c
*/
最佳答案
二进制文件是否在调试器之外运行?我尝试了一个 int main(){return 0;}
什么都不做的程序,用你的命令行编译它,临时签名 codesign -s - a.out
我可以运行它并调试它。这应该可以帮助您找出问题所在——什么都不做的程序是否可以临时协同设计?用您的签名签名的无所事事的程序是否有效?您的应用程序临时代码是否有效?您在使用权利吗?
关于macos - lldb 在 macOS 11.1 上尝试 "attach failed"一个 arm64 二进制文件时给出 "run",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65331087/
我正在尝试使用 lldb 远程启动和调试新进程没有太大的成功。 通过运行以下命令附加到已启动的进程效果很好: process connect process attach -P gdb-remote
如果我针对给定主题调用 lldb 帮助,大部分内容都会从屏幕上消失。例子: (lldb) help expression 我可以退出调试器,并在 typescript 中收集帮助,但这很笨拙。 lld
在 lldb 中有没有办法继续直到循环结束?我正在寻找 finish 的类似物,但它不是跳出堆栈帧,而是跳出循环。 for (int i = 0; i < 10000000; i++) { .
我已阅读 this tutorial ,但我还没有发现任何有关反向调试的信息。 lldb 是否有一些功能,例如 target record在 gdb 中?如果是,我在哪里可以阅读它? 最佳答案 还没有
lldb 是否具有 gdb 的等效项 shell命令从提示符运行外部命令? (见 How can I execute external commands from the gdb command pr
LLDB 有 convenience variables ?如果是这样,我该如何使用它们?如果没有,我可以使用类似的东西吗? 引用:http://software.intel.com/sites/pr
有没有办法使用 lldb 调试器设置零标志? 类似 gdb 中的 set ($eflags)=似乎只有 register write rflags ... 来设置所有 最佳答案 这是在 lldb 中设
有没有办法使用 lldb 调试器设置零标志? 类似 gdb 中的 set ($eflags)=似乎只有 register write rflags ... 来设置所有 最佳答案 这是在 lldb 中设
我正在使用 lldb 来跟踪调用 CoreFoundation 函数(例如 CFRunLoopTimerCreate)的一些纯 C 或 C++ 代码(32 位)。 我在 CFRunLoopTimerC
我在 lldb 中为我在 MacOS 上安装的基于 C 语言的应用程序设置了很多断点。断点大多设置在应用程序的同一函数中。然而,第二天我回到应用程序继续工作,我又开始在同一个函数中设置断点,出现了一个
您最喜欢的打印 NSArray 内容的方式是什么?使用LLDB? 一个python脚本? 内联 for 循环? 一个Objective-C 方法调用? 我知道按索引打印对象很容易。我想一次打印所有对象
我想从脚本中运行类似以下命令的内容: lldb -f /path/to/my/file -o command1 -o command2 ... -o detach 有没有办法在执行后退出lldb而不进
众所周知,我们可以在 GDB 中使用命令“catch syscall”来中断每个系统函数。 LLDB 中是否有类似的命令? (gdb) catch syscall Catchpoint 1 (sysc
使用 Xcode 10,当我使用断点停止我的应用程序并尝试在控制台中打印对象的内容时,我获得: "Couldn't IRGen expression, no additional error" 但是,
由于这些天在 Mac 上使用 gdb 变得越来越困难(至少我觉得我正在与 Apple 进行艰苦的斗争),所以我开始尝试使用 lldb。 是否有与 gdb -tui 等效的模式,可以显示源代码的良好、持
使用 Xcode 10,当我使用断点停止我的应用程序并尝试在控制台中打印对象的内容时,我得到: "Couldn't IRGen expression, no additional error" 但是,
$cat testleak01.cpp #include int main() { int*p=new int[3]; return 0; } 用调试信息编译它 $g++ testle
如何检查LLDB中不同线程中运行和步进的线程数? GDB 有信息线程。 LLDB 有类似的命令吗? 最佳答案 跑过: (lldb) help thread 命令来看看你可以用 lldb 中的线程做什么
我正在运行 Xubuntu 16.04。从存储库安装 lldb 后,当我尝试使用它时,我得到以下输出: lldb foo (lldb) target create "foo" Current exec
我目前正在为 C++ 中的自定义对象开发绘图命令。我正在使用 Xcode v10.1。 我使用command script import test.py 导入我自己的命令,其中有一个函数如下: imp
我是一名优秀的程序员,十分优秀!