30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Changing the Address of Variables<br />

Displaying Declared Arrays<br />

<strong>TotalView</strong> displays arrays the same way it displays local and global variables.<br />

In the Stack Frame or Source Pane, dive on the declared array. A Variable<br />

Window displays the elements of the array.<br />

CLI: dprint array-name<br />

Displaying Allocated Arrays<br />

The C Language uses pointers for dynamically allocated arrays; for example:<br />

int *p = malloc(sizeof(int) * 20);<br />

Since <strong>TotalView</strong> doesn’t know that p actually points to an array of integers,<br />

you need to do several things to display the array:<br />

1 Dive on the variable p of type int*.<br />

2 Change its type to int[20]*.<br />

3 Dive on the value of the pointer to display the array of 20 integers.<br />

Displaying the argv Array<br />

Typically, argv is the second argument passed to main(), and it is either a<br />

char **argv or char *argv[ ]. Suppose argv points to an array of three pointers<br />

to character strings. Here is how you can edit its type to display an<br />

array of three pointers, as follows:<br />

1 Select the type string for argv.<br />

CLI: dprint argv<br />

2 Edit the type string by using the field editor commands. Change it to:<br />

$string*[3]*<br />

CLI: dprint {($string*[3]*)argv}<br />

3 To display the array, dive on the value field for argv. (See Figure 203 on<br />

page 322.))<br />

Changing the Address of Variables<br />

You can edit the address of a variable in a Variable Window by editing the<br />

value shown in the Address field. When you edit this address, the Variable<br />

Window shows the contents of the new location.<br />

You can also enter an address expression such as 0x10b8 – 0x80 in this area.<br />

<strong>TotalView</strong> <strong>Users</strong> <strong>Guide</strong>: version 8.7 321

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!