How use Instruments and display the console in Command Lines applications

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.

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):

Here‘s an example code:

#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);
}

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.

Any thoughts?

c xcode debugging osx instruments


share|improve
this question

edited Nov
14 ‘09 at 18:11

asked Nov 14 ‘09 at 17:47



s=32&d=identicon&r=PG" style="margin:0px auto; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; height:32px">

Hugo S Ferreira

2,22031947

  add
comment

3 Answers

activeoldestvotes


up
vote
3down
vote
accepted

See this question for
your answer.

From Brad Larson therein:

Run your application from within Xcode to have the console output piped there. While your application is running, start Instruments and choose an appropriate instrument. Under Default Target in the menu bar, select iPhone or Computer (whichever is appropriate
for what you‘re testing), and under Attach to Process find the name of your executable.

When you click the record button, your application should start being profiled under Instruments while having its console output directed to Xcode. Unfortunately, this attachment process will need to come after the application has started, so you may have to
profile the startup of your application separately.

Edit: If that didn‘t work, you may just need to restart your computer. Have you done that yet?

时间: 2024-10-19 17:52:38

How use Instruments and display the console in Command Lines applications的相关文章

Instruments User Guide编程指南2-Common Tasks

Launch Instruments  Instruments app在Xcode app的内部,所以最直接的方式启动Instruments就是从Xcode中启动,当然也可以间接通过 Dock, Launchpad,  command line等工具启动. Launch Instruments from Xcode 1:Open Xcode. 2:Choose Xcode > Open Developer Tool > Instruments. 建议:也能够使用该方式启动更多有用的开发工具 T

xcode instruments和ibook在Nvidia WebDriver窗口透明的问题

在macos sierra上使用nvidia webdriver后,xcode instruments和ibook的窗口都变成了透明,特别是hackintosh上面(我的hackintosh上ibook问题没遇到,显示正常). 大概是这个样子,这是xcode instruments,窗口完全透明,什么也没有显示. 解决方法: 对instruments重新签名. sudo codesign -f -s - /Applications/Xcode.app/Contents/Applications/

Display controller

Field of the Invention The present invention relates to a display controller. Background to the invention Display controllers are known. One such display controller 10 is shown in the display system, generally 5, illustrated by figure 1. A display 40

u-boot串口和stdio、console初始化及相关操作详解&lt;三&gt;

console是构建在stdio之上的,console的初始化是board_r中最后收尾的操作. console的初始化函数console_init_r在common/console.c中实现: int console_init_r(void) { char *stdinname, *stdoutname, *stderrname; struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL; #ifdef CONFI

Linux下安装oracle数据库提示DISPLAY not set. Please set the DISPLAY and try again。

错误如下: Ignoring required pre-requisite failures. Continuing... Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-01-29_03-14-51AM. Please wait ... DISPLAY not set. Please set the DISPLAY and try again. Depending on the Unix Shell

Launch Instruments

Launch Instruments 该仪器应用在Xcode应用程序,所以推出是在Xcode的最直接的方式.你也可以启动它间接地通过码头,启动,或命令行.The Instruments app lives inside the Xcode app, so the most direct way to launch it is from within Xcode. You can also launch it indirectly via the Dock, Launchpad, or the c

斯坦福大学科研软件

常见的一些科研分析软件都找到了,排名第一的赫然是Abaqus...这名字取得好,中国六七十年代的小孩名字多以丁.乙之类短笔画为主. COMSOL.NI Labview差不多全了,奇怪的是居然没找到ANSYS和MSC... Provider: Software Licensing Click on a product name to view a detailed page. ABAQUS by Simulia Corporation (formerly Abaqus Inc)Software f

【转】 Xcode基本操作 -- 不错

原文网址:http://blog.csdn.net/phunxm/article/details/17044337 1.Xcode IDE概览 说明:从左到右,依次是“导航窗格(Navigator)->边列(Gutter)->焦点列(Ribbon)->代码编辑窗口(Standard/Primary Editor)”. 边列(Gutter):显示行号和断点. 焦点列(Ribbon):灰色深度与代码嵌套深度相关:鼠标悬停可突出显示右侧相应代码块(Focus code blocks on ho

为PhoneGap写一个android插件

为PhoneGap写一个android插件,要怎么做? 其实这句话应该反过来说,为android写一个PhoneGap插件,要怎么做? 这里以最简单的Hello World!为例,做个说明: 1.第一步,要先建立一个支持PhoneGap(Cordova)的android工程 因为这个插件本质上是安卓插件,用于PhoneGap,因此,要二者支持才行,所以我们要建立一个支持PhoneGap(Cordova)的android工程,插件在这个工程里面编写. 扫盲:PhoneGap现在已经出售给了Apac