How use Instruments and display the console in Command Lines applications
2014-06-09 16:01
411 查看
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
| |||
add comment |
3 Answers
activeoldestvotesup vote3down voteaccepted | 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? |
相关文章推荐
- How use Instruments and display the console in Command Lines applications
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- use noscript html tag when user disable the javascript in browser, guide user how to enable the js in different browser and retu
- How and Why to use the System.servicemodel.MessageParameterAttribute in WCF
- How to use the System Restore API to save and to restore system data in Visual C++
- Get the command parameters in Win app and Console app
- How to Access and Use the Windows Hosts File in Windows 7 and Vista
- Enabling the Oozie Web Console and use MySQL Database in Cloudera Manager 5.2
- the command 'vim' and how to use it
- Get and display the size of file and directory in Linux system using du command 获取和现实linux文件大小(三)
- Use Unicode and Hide the Console in Windows
- [Yii Framework] How to run cron job (or use command) in the server with yii framework
- How to use the Erase Data and Disable Handheld command
- How To Use the ODBC .NET Managed Provider in Visual C# .NET and Connection Strings
- how to config the tftpd-hpa server in the ubuntu using for remote tftp client '-p' and '-r' command
- How to enable Apache, OC4J and OPMN logging in Oracle Applications R12
- How to solve problem caused when the CRT library and MFC libraries are linked in the wrong order
- How to add the cracked dlls in GAC and How to release
- How to use plugin audio codecs in OpenH323 and OPAL