Sun ONE Studio Dev Tools: ------------------------- Debug Size of hello.c: -> Source: 69b -> Default: 5.1k -> -xO2: 5.2k -> -pg: 11.0k -> -g: 11.0k ------------------------------------------------------------------------ INDENT: /opt/SUNWspro/bin/indent -> Fixes line indentation in your code -> Default indent levels are in tabs of 8. Options to change (to be like gindent): -> -i2 (default 8) -> -di4 (default 16) -> You can put these in ~/.indent.pro, just "-i -di8" by itself will do. Example, Before Indent: #include int main(){ printf("hello\n"); return(0); } Example, After Intent: $ indent hello.c #include int main() { printf("hello\n"); return (0); } ------------------------------------------------------------------------ LINT: /opt/SUNWspro/bin/lint -> Source analysis. Example: lint -I/usr/local/include eeh.c Example2: $ lint -I/usr/local/include test.c name used but not defined ecore_ipc_init test.c(6) name declared but never used or defined _ecore_ipc_swap_16 Ecore_Ipc.h(38) _ecore_ipc_swap_32 Ecore_Ipc.h(39) _ecore_ipc_swap_64 Ecore_Ipc.h(40) .... ------------------------------------------------------------------------ DBX: /opt/SUNWspro/bin/dbx -> Source Debugger NOTE: Edit /home/benr/.dbxrc to add dbxenv's -> dbxenv suppress_startup_message 7.4 Example: $ gcc -g -o hello hello.c Reading hello Reading ld.so.1 Reading libc.so.1 (dbx) (dbx) stop in main (2) stop in main (dbx) run Running: hello (process id 130767) stopped in main at line 6 in file "hello.c" 6 printf("hello\n"); (dbx) next hello stopped in main at line 7 in file "hello.c" 7 return (0); (dbx) step stopped in main at line 8 in file "hello.c" 8 } (dbx) step execution completed, exit code is 0 (dbx) quit Example2: (dbx) list 6 if (argc < 1) { 7 printf("Please supply an argument\n"); 8 return (1); 9 } 10 printf("You said: %s\n", argv[1]); 11 printf("Good night\n"); 12 return (0); 13 } (dbx) stop at 10 (2) stop at "hello.c":10 (dbx) run Running: hello (process id 130845) stopped in main at line 10 in file "hello.c" 10 printf("You said: %s\n", argv[1]); (dbx) where =>[1] main(argc = 1, argv = 0x8047a70), line 10 in "hello.c" (dbx) list 10 printf("You said: %s\n", argv[1]); 11 printf("Good night\n"); 12 return (0); 13 } Example3: (dbx) runargs john (dbx) trace argv (2) trace argv -in main (dbx) status (2) trace argv -in main (dbx) run Running: hello john (process id 130855) initially (at line "hello.c":6): argv = 0x8047a68 You said: john Good night execution completed, exit code is 0 (dbx) --------------- Mini Reference: Start the program run Restart the program rerun Define arguments runargs Define env vars setenv VAR value Clear The Screen clear Exit DBX quit Set Breakpoint stop at | View breakpoints, etc. status Delete a breakpoint delete Watch a variable trace Backtrace where Current Frame frame Next Function next Step into functions step Finish the function finish List code and position list Continue cont (to )||(in ) http://www.fortran-2000.com/ArnaudRecipes/CompGdbDbx.html http://www.mathcs.carleton.edu/courses/course_resources/cs317/debug/dbx.html ------------------------------------------------------------------------ LEX: generator of lexical analysis programs http://dinosaur.compilertools.net/ ------------------------------------------------------------------------ YACC: yet another compiler-compiler http://dinosaur.compilertools.net/ ------------------------------------------------------------------------ CSCOPE: /opt/SUNWspro/bin/cscope -> Source Browser, search through your own code. ------------------------------------------------------------------------ CFLOW: /opt/SUNWspro/bin/cflow -> Analyze the flow of a program Example: $ cflow -ix hello.c 1 main: int(), 2 printf: <> Example2: $ cflow -ix -I/usr/local/include eeh.c 1 main: int(), 2 evas_list_append: <> 3 file_list: struct*, 4 evas_list_count: <> .... ------------------------------------------------------------------------ PROF: /usr/ccs/bin/prof -> Profiler Example: $ cc hello.c -o hello -pg # Compile with profiling support (-pg) $ ./hello # On exit it will create a "mon.out" file. $ prof hello %Time Seconds Cumsecs #Calls msec/call Name 0.0 0.00 0.00 1 0. main ------------------------------------------------------------------------ GPROF: /usr/ccs/bin/gprof -> GNU Profiler Example: $ gcc hello.c -o hello -pg $ ./hello $ gprof hello % cumulative self self total time seconds seconds calls ms/call ms/call name 0.0 0.00 0.00 1 0.00 0.00 main [1] Index by function name [1] main Object modules 1: hello ------------------------------------------------------------------------ Valgrind: (No avalible on Solaris) -> Suite of tools for debugging and profiling -> Note: Valgrind 1.x used the syntax --skin=, 2.x uses --tool= Tools: (2.x) Addrcheck: a lightweight memory checker Memcheck: a heavyweight memory checker Helgrind: a data-race detector Cachegrind: a cache-miss profiler Massif: a heap profiler Lackey: example Valgrind skin Example: $ gcc -g hello.c -o hello $ valgrind hello --leak-check=yes ... ==8896== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0) ==8896== malloc/free: in use at exit: 0 bytes in 0 blocks. ==8896== malloc/free: 0 allocs, 1 frees, 0 bytes allocated. ==8896== For counts of detected errors, rerun with: -v ==8896== No malloc'd blocks -- no leaks are possible. Example2: $ valgrind --skin=cachegrind hello ==8987== I refs: 33,534 ==8987== I1 misses: 457 ==8987== L2i misses: 449 ==8987== I1 miss rate: 1.36% ==8987== L2i miss rate: 1.33% ==8987== ==8987== D refs: 18,917 (14,596 rd + 4,321 wr) ==8987== D1 misses: 873 ( 783 rd + 90 wr) ==8987== L2d misses: 783 ( 696 rd + 87 wr) ==8987== D1 miss rate: 4.6% ( 5.3% + 2.0% ) ==8987== L2d miss rate: 4.1% ( 4.7% + 2.0% ) ==8987== ==8987== L2 refs: 1,330 ( 1,240 rd + 90 wr) ==8987== L2 misses: 1,232 ( 1,145 rd + 87 wr) ==8987== L2 miss rate: 2.3% ( 2.3% + 2.0% ) ------------------------------------------------------------------------ DMAKE: /opt/SUNWspro/bin/dmake -> Distributed Make, to build targets concurrently where possible -> Works by rsh'ing to other hosts (build hosts) -> Pathing is, by default, assumed to be the same on local and build hosts. -> Configured by configuration file: $(HOME)/.dmakerc -> Also done by: -c option, DMAKE_RCFILE makefile macro, DMAKE)FCFILE env var. Example configuration file: earth { jobs = 2 } mars { jobs = 3 } group lab1 { host falcon { jobs = 3 } host hawk host eagle { jobs = 3 } } group sparc-cluster { host wren { jobs = 10 , path = "/export/SUNWspro/bin" } host stimpy { path = "/opt/SUNWspro/bin" } } http://docs.sun.com/app/docs/doc/819-0506 ------------------------------------------------------------------------ BCHECK: /opt/SUNWspro/bin/bcheck -> Batch utility for Runtime Checking (RTC) -> Can perform the following tests: -access Perform memory access checking. (SPARC only) -all Perform memory access and memory leak checking. (SPARC only) -leaks Perform memory leak checking only. (Default) -memuse Perform memory use checking, which includes memory leaks checking. [ Seems broken ] ------------------------------------------------------------------------ DUMPSTABS: /opt/SUNWspro/bin/dumpstabs -> Utility for dumping out debug information Example: $ dumpstabs hello Elf Header: Ident = "\x7fELF", Class = 1 (32), Data = 1 (2LSB), Id ver = 1 (CURRENT) Type = 2 (EXEC), Machine = 3 (386), Version = 1 (CURRENT) Start address = 0x08050598, Phdr offset = 0x00000034 Shdr offset = 0x00001d38, File flags = 0x00000000 Ehdr size = 52, Phdr size = 32, Num Phdrs = 5 Shdr size = 40, Num Shdrs = 26, Str Index = 23 Program Table @ 0x00000034 (5 entries, 32 bytes each): .... ------------------------------------------------------------------------ CXREF: /opt/SUNWspro/bin/cxref -> Generate C program cross-reference Example: $ cxref hello.c hello.c: NAME FILE FUNCTION LINE BUFSIZ stdio_iso.h --- 122* EOF stdio_iso.h --- 150* FILE stdio_iso.h --- 92- FILENAME_MAX stdio_iso.h --- 154* FOPEN_MAX stdio_iso.h --- 153* __func__ hello.c main 5* argc hello.c main 4* 6 argv hello.c main 4* 10 popen stdio.h --- 313- printf stdio_iso.h --- 224- hello.c --- 7 10 11 ......... ------------------------------------------------------------------------ CTRACE: /opt/SUNWspro/bin/ctrace -> C program debugger --> Ctrace simply rewrites your code so that it outputs each line of source AS it executes. Run it on the source, build that source, and run. $ ctrace hello.c > hello_t.c $ cc -o hello_t hello_t.c $ ./hello_t john 4 main(int argc, char *argv[]) 6 if (argc < 1) /* argc == 2 */ 10 printf("You said: %s\n", argv[1]); /* argv[1] == 134511618 or "john" */You said: john 11 printf("Good night\n");Good night 12 return (0); $ ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------------------ SOS GUI Tools: X-Designer /opt/SUNWspro/bin/xdesigner -> Interactive tool for creating robust Motif-based and Java[tm] graphical user interfaces Sun Studio IDE /opt/SUNWspro/bin/sunstudio -> Full Integrated Development Enviroment GUI GNU Visual VI-Improved Editor /opt/SUNWspro/bin/gvim X Emacs Editor /opt/SUNWspro/bin/xemacs Performance Analyzer -> A graphical performance analyzer. The "collect" utility collects data from "experiements" which are then analyzed by the Performance Analyzer ------------------------------------------------------------------------ Compilers & Other Tools: c89 C 89 Compiler c99 Compile standard C programs cc C compiler cc-5.0 (Link to cc) f77 FORTRAN 77 compiler f90 Fortran 95 compiler f95 Fortran 95 compiler ild Incremental Link Editor dwarfdump Dumps DWARF debug information of an ELF object etags, ctags - generate tag file for Emacs, vi -> http://www.softpanorama.org/Editors/ctags.shtml ========================================================================== ON Build Tools (OpenSolaris onbld package): Install.1 codereview.1 make_pkg_db.1 sccsrm.1 acr.1 cstyle.1 mkacr.1 webrev.1 bldenv.1 flg.flp.1 nightly.1 ws.1 check_rtime.1 get_depend_info.1 sccscp.1 wx.1 checkpaths.1 intf_check.1 sccsmv.1 xref.1 cstyle: Check for some common stylistic errors in C source -> cstyle -p source.c codereview: Diff list generator (NOT included in onbld, only the man page)