From 27648f269f318b48897163735a0254f3b799fbff Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 17 Feb 1995 23:24:22 +0000 Subject: [PATCH] * gdb.texinfo (Artificial arrays): Note use of coerce-to-array-type. --- gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 055395e07ba..79f5b0c83d7 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 17 15:24:35 1995 Per Bothner + + * gdb.texinfo (Artificial arrays): Note use of coerce-to-array-type. + Wed Feb 15 11:59:18 1995 J.T. Conklin * all-cfg.texi: New flag, GDBSERVE, for NetWare's gdbserve.nlm. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 8138efaa62b..7e445aada92 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4078,6 +4078,22 @@ subscripting, and are coerced to pointers when used in expressions. Artificial arrays most often appear in expressions via the value history (@pxref{Value History, ,Value history}), after printing one out. +Another way to create an artificial array is to use a cast. +This re-interprets a value as if it were an array. +The value need not be in memory: +@example +(@value{GDBP}) p/x (short[2])0x12345678 +$1 = @{0x1234, 0x5678@} +@end example + +As a convenience, if you leave the array length out (as in +@samp{(@var{type})[])@var{value}}) gdb calculates the size to fill +the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}: +@example +(@value{GDBP}) p/x (short[])0x12345678 +$2 = @{0x1234, 0x5678@} +@end example + Sometimes the artificial array mechanism is not quite enough; in moderately complex data structures, the elements of interest may not actually be adjacent---for example, if you are interested in the values -- 2.30.2