Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use Instruments and display the console in Command Lines applications

Tags:

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?

like image 520
Hugo Sereno Ferreira Avatar asked Nov 14 '09 17:11

Hugo Sereno Ferreira


1 Answers

It's easy. See the screenshot.

screenshot

like image 157
CommanderHK Avatar answered Sep 22 '22 17:09

CommanderHK