将x86寄存器的NSString输出转换为NSArray的最佳方法

时间:2011-10-06 07:18:41

标签: objective-c nsstring nsmutablearray

我正在尝试在我的cocoa应用程序中显示gdb命令“info registers”的输出(在UITableView中)。为此,我需要将当前为字符串的输出转换为数组。目前,字符串输出如下所示:

"rax            0x10004005  268451845
    rbx            0x0  0
    rcx            0x7fff5fbfe948   140734799800648
    rdx            0x0  0
    rsi            0x7000006    117440518
    rdi            0x7fff5fbfea80   140734799800960
    rbp            0x7fff5fbfe9a0   0x7fff5fbfe9a0
    rsp            0x7fff5fbfe948   0x7fff5fbfe948
    r8             0x1e03   7683
    r9             0x0  0
    r10            0x800    2048
    r11            0x206    518
    r12            0x1e03   7683
    r13            0x800    2048
    r14            0x7fff5fbfea80   140734799800960
    r15            0x7000006    117440518
    rip            0x7fff823d8d7a   0x7fff823d8d7a <mach_msg_trap+10>
    eflags         0x206    518
    cs             0x2f 47
    ss             0x0  0
    ds             0x0  0
    es             0x0  0
    fs             0x10 16
    gs             0x48 72"

如何将此字符串转换为数组,使其看起来像这样?

   "rax            0x10004005   268451845,
    rbx            0x0  0,
    rcx            0x7fff5fbfe948   140734799800648,
    rdx            0x0  0,
    rsi            0x7000006    117440518,
    rdi            0x7fff5fbfea80   140734799800960,
    rbp            0x7fff5fbfe9a0   0x7fff5fbfe9a0,
    rsp            0x7fff5fbfe948   0x7fff5fbfe948,
    r8             0x1e03   7683,
    r9             0x0  0,
    r10            0x800    2048,
    r11            0x206    518,
    r12            0x1e03   7683,
    r13            0x800    2048,
    r14            0x7fff5fbfea80   140734799800960,
    r15            0x7000006    117440518,
    rip            0x7fff823d8d7a   0x7fff823d8d7a <mach_msg_trap+10>,
    eflags         0x206    518,
    cs             0x2f 47,
    ss             0x0  0,
    ds             0x0  0,
    es             0x0  0,
    fs             0x10 16,
    gs             0x48 72"

1 个答案:

答案 0 :(得分:2)

NSArray *myArray = [mysHexString componentsSeparatedByString:@"\n"];