The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 ТемаНаборКатегория 
 
 [Cписок руководств | Печать]

ctrace (1)
  • >> ctrace (1) ( Solaris man: Команды и прикладные программы пользовательского уровня )
  • 
    NAME
         ctrace - C program debugger
    
    SYNOPSIS
         ccttrraaccee [options] [file]
    
    DESCRIPTION
         The ccttrraaccee command allows the user to monitor the sequential
         execution of a C program as each program statement executes.
         The effect is similar to executing a  shell  procedure  with
         the  --xx option.  ccttrraaccee reads the C program in file (or from
         standard input if the user does not specify  file),  inserts
         statements  to  print  the text of each executable statement
         and the values of all variables referenced or modified,  and
         writes  the  modified  program  to the standard output.  The
         output of ccttrraaccee  must  be  placed  into  a  temporary  file
         because  the  cc(1) commands do not allow the use of a pipe.
         This file can then be compiled and executed.
    
         As each statement in the program executes, it will be listed
         at the terminal, followed by the name and value of any vari-
         ables referenced or modified in the statement;  these  vari-
         able  names  and  values will be followed by any output from
         the statement.  Loops in the trace output are  detected  and
         tracing  is  stopped until the loop is exited or a different
         sequence of statements within the loop is executed.  A warn-
         ing  message  is printed after each 1000 loop cycles to help
         the user detect infinite loops.  The trace  output  goes  to
         the  standard  output so the user can put it into a file for
         examination with an editor or the tail(1) command.
    
         The options commonly used are:
    
         --ff functions  Trace only these functions.
         --vv functions  Trace all but these functions.
    
         The user may want to add to the default formats for printing
         variables.  Long and pointer variables are always printed as
         signed integers.  Pointers  to  character  arrays  are  also
         printed  as  strings  if  appropriate.  cchhaarr, sshhoorrtt, and iinntt
         variables are  also  printed  as  signed  integers  and,  if
         appropriate, as characters.  ddoouubbllee variables are printed as
         floating point numbers in scientific notation.  The user can
         request  that variables be printed in additional formats, if
         appropriate, with these options:
    
         --oo     Octal
         --xx     Hexadecimal
         --uu     Unsigned
         --ee     Floating point
    
    
         These options are used only in special circumstances:
    
         --ll n   Check n consecutively executed statements for looping
                trace output, instead of the default of 20.  Use 0 to
                get all the trace output from loops.
         --ss     Suppress redundant trace output from  simple  assign-
                ment statements and string copy function calls.  This
                option can hide a bug caused by use of the = operator
                in place of the == operator.
         --tt n   Trace  n  variables  per  statement  instead  of  the
                default  of 10 (the maximum number is 20).  The diag-
                nostics section explains when to use this option.
         --PP     Preprocess the input before tracing it.  The user can
                also use the --DD, --II, and --UU cc(1) options.
         --pp string
                Change the trace print function from the  default  of
                pprriinnttff.   For example, ffpprriinnttff((ssttddeerrrr, would send the
                trace to the standard error output.
         --rr f   Use file f in place of the rruunnttiimmee..cc  trace  function
                package.   This  replacement lets the user change the
                entire print function, instead of just the  name  and
                leading arguments (see the --pp option).
         --VV     Prints version information on the standard error.
         --QQarg  If arg is yy, identification information about  ccttrraaccee
                will  be added to the output files.  This can be use-
                ful for software administration.  Giving  nn  for  arg
                exlicitly  asks for no such information, which is the
                default behavior.
    
    EXAMPLE
         If the file llcc..cc contains this C program:
    
               11 ##iinncclluuddee <<ssttddiioo..hh>>
               22 mmaaiinn(()) //** ccoouunntt lliinneess iinn iinnppuutt **//
               33 {{
               44   iinntt cc,, nnll;;
               55
               66   nnll == 00;;
               77   wwhhiillee ((((cc == ggeettcchhaarr(()))) !!== EEOOFF))
               88        iiff ((cc == ''\\nn''))
               99             ++++nnll;;
              1100   pprriinnttff((""%%dd\\nn"",, nnll));;
              1111 }}
    
         these commands and test data are entered:
    
              cccc llcc..cc
              aa..oouutt
              11
              ((ccnnttll--dd))
    
    
         the program will be compiled and executed.   The  output  of
         the program will be the number 22, which is incorrect because
         there is only one line in the test data.  The error in  this
         program  is  common, but subtle.  If the user invokes ccttrraaccee
         with these commands:
    
              ccttrraaccee llcc..cc >>tteemmpp..cc
              cccc tteemmpp..cc
              aa..oouutt
    
         the output will be:
    
               22 mmaaiinn(())
               66   nnll == 00;;
                   //** nnll ==== 00 **//
               77   wwhhiillee ((((cc == ggeettcchhaarr(()))) !!== EEOOFF))
    
         The program is now waiting for input.  If  the  user  enters
         the same test data as before, the output will be:
    
                   //** cc ==== 4499 oorr ''11'' **//
               88        iiff ((cc == ''\\nn''))
                        //** cc ==== 1100 oorr ''\\nn'' **//
               99             ++++nnll;;
                             //** nnll ==== 11 **//
               77   wwhhiillee ((((cc == ggeettcchhaarr(()))) !!== EEOOFF))
                   //** cc ==== 1100 oorr ''\\nn'' **//
               88        iiff ((cc == ''\\nn''))
                        //** cc ==== 1100 oorr ''\\nn'' **//
               99             ++++nnll;;
                             //** nnll ==== 22 **//
               77   wwhhiillee ((((cc == ggeettcchhaarr(()))) !!== EEOOFF))
    
         If an end-of-file character (cntl-d) is entered,  the  final
         output will be:
    
                   //** cc ==== --11 **//
              1100   pprriinnttff((""%%dd\\nn"",, nnll));;
                   //** nnll ==== 22 **//22
                    rreettuurrnn
    
         Note the information printed out at the  end  of  the  trace
         line  for  the nnll variable following line 10.  Also note the
         rreettuurrnn comment added by ccttrraaccee at the end of the trace  out-
         put.   This  shows  the  implicit  return at the terminating
         brace in the function.
    
         The trace output shows that variable cc is assigned the value
         '11'  in  line  7, but in line 8 it has the value '\\nn'.  Once
         user attention is drawn to this iiff statement, he or she will
         probably  realize  that the assignment operator (==) was used
         in place of the equality  operator  (====).   This  error  can
         easily be missed during code reading.
    
    EXECUTION-TIME TRACE CONTROL
         The default operation for ccttrraaccee is to trace the entire pro-
         gram  file,  unless  the  --ff or --vv options are used to trace
         specific functions.  The default operation does not give the
         user statement-by-statement control of the tracing, nor does
         it let the user turn the tracing off and on  when  executing
         the traced program.
    
         The user can do both of these by adding ctroff() and ctron()
         function  calls  to  the program to turn the tracing off and
         on, respectively, at execution time.  Thus, complex criteria
         can  be  arbitrarily  coded for trace control with iiff state-
         ments, and this code  can  even  be  conditionally  included
         because  ccttrraaccee  defines  the  CCTTRRAACCEE preprocessor variable.
         For example:
    
              ##iiffddeeff CCTTRRAACCEE
                   iiff ((cc ==== ''!!'' &&&& ii >> 11000000))
                        ccttrroonn(());;
              ##eennddiiff
    
         These functions can also be called from dbx(1) if  they  are
         compiled  with the --gg option.  For example, to trace all but
         lines 7 to 10 in the main function, enter:
    
              ddbbxx aa..oouutt
              wwhheenn aatt 77 {{ccaallll ccttrrooffff(());;}}
              wwhheenn aatt 77 {{ccaallll ccttrroonn(());;}}
              rruunn
    
         The trace can be turned off and on by setting  static  vari-
         able ttrr_cctt_ to 00 and 11, respectively.  This on/off option is
         useful if a user is using a debugger that can not call these
         functions directly.
    
    FILES
         rruunnttiimmee..cc      run-time trace package
    
    SEE ALSO
         bfs(1), dbx(1), tail(1), ctype(3C), fclose(3S),  printf(3S),
         string(3C)
    
    DIAGNOSTICS
         This section contains diagnostic messages from  both  ccttrraaccee
         and  cc(1), since the traced code often gets some cccc warning
         messages.  The user can get cccc error messages in  some  rare
         cases, all of which can be avoided.
    
      ctrace Diagnostics
         wwaarrnniinngg:: ssoommee vvaarriiaabblleess aarree nnoott ttrraacceedd iinn tthhiiss ssttaatteemmeenntt
              Only 10 variables are traced in a statement to  prevent
              the C compiler "out of tree space; simplify expression"
              error.  Use the --tt option to increase this number.
    
         wwaarrnniinngg:: ssttaatteemmeenntt ttoooo lloonngg ttoo ttrraaccee
              This statement is over 400 characters long.  Make  sure
              that tabs are used to indent the code, not spaces.
    
         ccaannnnoott hhaannddllee pprreepprroocceessssoorr ccooddee,, uussee --PP ooppttiioonn
              This is usually caused  by  ##iiffddeeff/##eennddiiff  preprocessor
              statements  in  the  middle  of  a C statement, or by a
              semicolon at the end of a ##ddeeffiinnee  preprocessor  state-
              ment.
    
              Split the sequence by removing an eellssee from the middle.
    
         ppoossssiibbllee ssyynnttaaxx eerrrroorr,, ttrryy --PP ooppttiioonn
              Use the --PP option to preprocess the ccttrraaccee input, along
              with  any  appropriate  --DD,  --II,  and  --UU  preprocessor
              options.
    
    
    NOTES
         Defining a function with the same name as a system  function
         may  cause  a  syntax  error  if  the number of arguments is
         changed.  Just use a different name.
    
         ccttrraaccee assumes that BBAADDMMAAGG is a preprocessor macro, and that
         EEOOFF and NNUULLLL are #defined constants.  Declaring any of these
         to be variables, e.g.,  "iinntt  EEOOFF;",  will  cause  a  syntax
         error.
    
         Pointer values are always treated as pointers  to  character
         strings.
    
         ccttrraaccee does not know about the components of aggregates like
         structures,  unions,  and arrays.  It cannot choose a format
         to print all the components of an aggregate when an  assign-
         ment  is made to the entire aggregate.  ccttrraaccee may choose to
         print the address of an aggregate or use  the  wrong  format
         (e.g.,  33..114499005500ee--331111  for  a  structure  with  two  integer
         members) when printing the value of an aggregate.
    
         The loop trace output elimination  is  done  separately  for
         each file of a multi-file program.  Separate output elimina-
         tion can result in functions called from a loop still  being
         traced, or the elimination of trace output from one function
         in a file until another in the same file is called.
    
    
    
    


    Поиск по тексту MAN-ов: 




    Партнёры:
    PostgresPro
    Inferno Solutions
    Hosting by Hoster.ru
    Хостинг:

    Закладки на сайте
    Проследить за страницей
    Created 1996-2024 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру