Dbx 1024 User's Guide Page 55

  • Download
  • Add to my manuals
  • Print
  • Page
    / 158
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 54
Displaying and Changing Program Variables
41
The leading dot is useful when a file and a procedure have the same name.
For instance, suppose mrx.c contains a function called mrx. Further, suppose
that mrx.c contains a global variable called mi and a local variable, also called
mi. To refer to the global variable, use the qualified form .mrx.mi, and to refer
to the local variable, use the qualified form mrx.mrx.mi.
Variable Scope
You can access the value of a variable only while it is in scope. The variable
is in scope only if the block or procedure with which it is associated is active.
After you start your program, whenever your program executes a block or
procedure that contains variables, your program allocates space for those
variables and they “come into scope.” You may access the values of those
variables as long as the block or procedure is active. Once the block or
procedure ends, the space for those variables is deallocated and you may no
longer access their values.
Displaying the Value of a Variable
You can display the value of a program variable using the print,printd,printf,
printo, and printx commands and the pd, po, and px aliases described in
“Printing Expressions” on page 37. For example, to print the value of the
program variable total, enter:
(dbx) print total
235
Theprint command also displays arrays, structures, and other complex data
structures. For example, if message is a character array (a string), dbx prints
the string:
(dbx) print message
"Press <Return> to continue."
As a more complex example, consider a simple linked list stored as an array
of elements, each element consisting of a pointer to the next element and an
integer value. If the array is named list, print the entire array by entering:
(dbx) print array
Page view 54
1 2 ... 50 51 52 53 54 55 56 57 58 59 60 ... 157 158

Comments to this Manuals

No comments