开发者

how to add an expression to see a range of memory using watch window in eclipse?

开发者 https://www.devze.com 2023-03-09 05:03 出处:网络
The mysql has the following code: table->file->ha_write_row(table->record[0])) where table->record[0] is a buffer whose size is determined by anoth开发者_如何转开发er variable reclength. Now I know t

The mysql has the following code:

table->file->ha_write_row(table->record[0]))

where table->record[0] is a buffer whose size is determined by anoth开发者_如何转开发er variable reclength. Now I know the reclength, see it's 203. And I want to see the value (table->record[0])[0..202], which means from the first byte to the last byte. If I just put (table->record[0]) in the watch, it only display several chars as there are many 0 inside table->record[0], say it could be like "xxx\\0\\0\\0yyy...", In this case, eclipse only show "xxx" in the watch window as it thinks "xxx\0" is the complete string terminated by "\\0", but actually I want to see more buffer value. So I used (table->record[0])[i] in the watch, i is 0 , 1, 2 .., but that's boring, is there any good way to see all of them?


Use the gdb syntax for printing array values, for array whose first element is pointed to by pointer p, use:

p@100

To see first 100 elements. In your case, edit your watch expression (left click -> Edit Watch Expression) to:

table->record@100

You didn't mention the type of table->record --- I am assuming it holds the pointer (and not the pointer-to-pointer).

And btw, you can cast your pointer to any data type, exactly as in a gdb console.

0

精彩评论

暂无评论...
验证码 换一张
取 消