如何在totalview中表示int *作为数组? [英] how to represent int * as array in totalview?

查看:168
本文介绍了如何在totalview中表示int *作为数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何'潜水'一个int *指向一个动态分配的整数数组,并将其表示为一个固定的int []数组?否则,如果我潜水一个int *它显示的地址和int指向,而是我想看到所有的整数的数组。

解决方案

我注意到这个问题的TotalView标签。你要问如何在totalview中查看数组中的值?如果是这样,那么答案很容易。



假设你有一个类型为int *的指针p,你目前指向一个有10个整数的数组。



步骤1.潜水指针。这是通过双击,单击鼠标中键或使用上下文菜单中的dive选项 - 将鼠标光标放置在源代码窗格或堆栈框架窗格中的变量后完成的。



这将打开一个新窗口,表示



表达式:p
地址:0xbfaa1234
类型: int *



在数据区域中会出现类似



0x08059199 - > 0x000001a5(412)



此窗口显示指针本身,列出的地址是指针的地址。值(上例中的0x08059199)是指针所具有的实际值。在箭头右边的一切只是一个提示告诉你想要它指向。



第2步。重复双击或中间鼠标按钮,这次对变量窗口中的数据值。 (所以你双击它说0x08059199)。



这将有效地解引用指针。现在窗口的重点不是指针本身,而是指针指向的东西。请注意,地址框现在包含0x08059199,它是之前的值。



表达式:*(((int *)p))
地址:0x08059199
类型:int


b $ b

,在数据区域中会出现



0x000001a5(412)



步骤3.将数据窗口转换为所需的类型。只需在类型字段中单击并将其更改为int [10]。然后命中返回。



这告诉调试器0x08059199是10个整数的数组的开始。



此窗口将增加两个新字段:切片和过滤器。你现在可以留下那些单独的,但它们可以在以后有用。



数据区现在将显示两列字段和值和10行。



字段列将是数组[0] - [9]中的索引,值列将告诉您在每个数组位置中有什么数据。



其他提示:





  • 您可以随时转换成不同的类型或长度,以查看不同的元素(也可能是指针,潜水会将它们解除引用)

    您可以通过点击值列并编辑您在那里找到的内容来编辑实际数据值。


  • 您随时可以使用<取消潜水作业,图标在变量窗口的右上角。




有些在线影片可能会对您有帮助。



http://www.roguewave.com/products/totalview/resources/ videos.aspx



特别是有一个标记为开始使用TotalView。



不要犹豫与Rogue Wave软件联系我们TotalView使用提示!



Chris Gottbrath
(roguewave dot com的Chris gottbrath)
Rogue Wave软件的TotalView产品经理


How do I 'dive' an int * which points to a dynamically allocated array of integers and represent it as a fixed int[] array? Put otherwise, if I dive an int * it shows the address and the int pointed to, but instead I would like to see the array of all of the integers.

解决方案

I noticed the TotalView tag on this question. Are you asking how to see the values in your array in totalview? If so then the answer is pretty easy.

Lets say you have a pointer p which is of type int * and you have it currently pointing towards an array with 10 integers.

Step 1. Dive on the pointer. That's accomplished by double clicking, clicking the middle mouse button, or using the dive option on the context menu -- all after having placed the mouse cursor on the variable int he source code pane or the stack frame pane.

This will bring up a new window that will say

Expression: p Address: 0xbfaa1234 Type: int *

and down in the data area will say something like

0x08059199 -> 0x000001a5 (412)

This window is showing you the pointer itself, the address listed is the address of the pointer. The value (0x08059199 in the example above) is the actual value that the pointer has. Everything to the right of the arrow is just a "hint" telling you want it points to.

Step 2. Dive on the pointer again. Repeat the double click or middle mouse button, this time on the data value in the variable window. (So you are double clicking where it says 0x08059199).

This will effectively "dereference" the pointer. Now the window is focused not on pointer itself but the thing that the pointer pointed to. Notice that the address box now contains 0x08059199 which was the value before.

expression: *(((int *) p)) Address: 0x08059199 Type: int

and down in the data area it will say something like

0x000001a5 (412)

Step 3. Cast the data window to the type you want. Just click in the type field and change it to say int[10]. Then hit return.

This tells the debugger that 0x08059199 is the beginning of an array of 10 integers.

The window will grow two new fields: Slice and Filter. You can leave those alone for now, but they can be useful later.

The data area will now show two columns "field" and "value" and 10 rows.

The field column will be the index in the array [0] - [9] and the value column will tell you what data you have in each array location.

Other tips:

  • In more complicated data structures you can may want to dive on individual elements (which might also be pointers, diving will dereference them as well)

  • You can always cast to different types or lengths to look at data "as if it was" whatever

  • You can edit the actual data values by clicking on the value column and editing what you find there. This is useful when you want to provoke specific mis-behavior from your application

  • You can always undo diving operations with the "<" icon in the upper right hand corner of the variable window.

There are some online videos that you might find helpful at

http://www.roguewave.com/products/totalview/resources/videos.aspx

in particular there is one labeled "getting started with TotalView".

Don't hesitate to contact us at Rogue Wave Software for TotalView usage tips! support at roguewave dot com is a good address for that.

Chris Gottbrath (Chris dot Gottbrath at roguewave dot com) TotalView Product Manager at Rogue Wave Software

这篇关于如何在totalview中表示int *作为数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆