如何在命令行应用程序中使用乐器并显示控制台 [英] How use Instruments and display the console in Command Lines applications

查看:91
本文介绍了如何在命令行应用程序中使用乐器并显示控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OSX上使用Xcode开发命令行C应用程序.我还想使用Instruments来分析和查找内存泄漏.

I'm using Xcode on OSX to develop command line C applications. I would also like to use Instruments to profile and find memory leaks.

但是,从Instruments内部启动应用程序时,我找不到找到控制台的方法.我也无法附加到正在运行的命令行进程(它退出并出现错误):

However, I couldn't find a way to display the console when launching the application from within Instruments. I'm also unable to attach to a running command line process (it exits with an error):

这是示例代码:

#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <setjmp.h>

static sigjmp_buf jmpbuf;

void handler(int sig) {
    char c[BUFSIZ];

    printf ("Got signal %d\n", sig);
    printf ("Deseja sair? (s/n) ");

    fgets(c, sizeof(c), stdin);

    if(c[0] == 's') {
        exit(0);
    } else {
        siglongjmp(jmpbuf, 1);
    }
}

int main(void) {
    char buf[BUFSIZ];

    signal(SIGINT, handler);

    sigsetjmp(jmpbuf, 1);

    while(1) {
        printf(">>>");
        fgets(buf, sizeof(buf), stdin);
        printf ("Introduziu: %s\n", buf);
    }

    return(0);
}

这是在启动Instruments并尝试附加到xcode中正在运行的进程后出现的错误:

Here's the error I got after launching Instruments, and trying to attach to the running process in xcode:

[Switching to process 1475]
[Switching to process 1475]
Error while running hook_stop:
sharedlibrary apply-load-rules all
Error while running hook_stop:
Invalid type combination in ordering comparison.
Error while running hook_stop:
Invalid type combination in ordering comparison.
Error while running hook_stop:
Error while running hook_stop:
Error while running hook_stop:
Error while running hook_stop:
Error while running hook_stop:
Error while running hook_stop:
Error while running hook_stop:

Unable to disassemble __CFInitialize.

有什么想法吗?

推荐答案

很简单.查看屏幕截图.

It's easy. See the screenshot.

这篇关于如何在命令行应用程序中使用乐器并显示控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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