aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorGaius Mulley <gaius@glam.ac.uk>2006-05-13 15:46:38 +0000
committerGaius Mulley <gaius@glam.ac.uk>2006-05-13 15:46:38 +0000
commit72019c9cbc1405cb0ecfab5d57a66279a45c19c5 (patch)
tree3a0de2f116ae273c53484e3d28af93cd339e2b95 /gdb/doc
parent34addd0f72d6ef37bf70f8772509495cd2d733a8 (diff)
downloadgdb-72019c9cbc1405cb0ecfab5d57a66279a45c19c5.zip
gdb-72019c9cbc1405cb0ecfab5d57a66279a45c19c5.tar.gz
gdb-72019c9cbc1405cb0ecfab5d57a66279a45c19c5.tar.bz2
2006-05-13 Gaius Mulley <gaius@glam.ac.uk>
* gdb/m2-lang.h: added function extern prototypes for m2_is_long_set and get_long_set_bounds. * gm2/m2-typeprint.c: This file has been completely replaced to reflect the Modula-2 syntax rather than call the c_print_type function. (m2_print_type): walk the Modula-2 type tree. (m2_type_name): added. (m2_range): added. (m2_typedef): added. (m2_array): added. (m2_pointer): added. (m2_ref): added. (m2_unknown): added. (m2_union): added. (m2_procedure): added. (m2_print_bounds): added. (m2_short_set): added. (m2_is_long_set): added. (m2_get_discrete_bounds): added. (m2_is_long_set_of_type): added. (m2_long_set): added. (m2_record_fields): added. (m2_enum): added. * gdb/dwarf2read.c: added ability to detect the language Modula-2 and handle SET and CHAR types. (read_set_type): added. (process_die): call read_set_type. (read_base_type): modifed signed/unsigned char handling for Modula-2. (set_cu_language): added Modula-2 case clause. * gdb/m2-valprint.c: complete replacement so that Modula-2 values are printed rather than call the C language routines. (print_function_pointer_address): added. (get_long_set_bounds): added. (m2_print_long_set): added. (print_unpacked_pointer): added. (print_variable_at_address): added. (m2_val_print): replaced.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo167
2 files changed, 170 insertions, 1 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index f759123..0dc8b24 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2006-05-13 Gaius Mulley <gaius@glam.ac.uk>
+
+ * gdb/doc/gdb.texinfo: added a section on Modula-2 Types.
+
2006-05-10 Daniel Jacobowitz <dan@codesourcery.com>
* agentexpr.texi: Add a copyright and license notice.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e2b986a..74617c7 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -9471,6 +9471,7 @@ table.
* M2 Operators:: Built-in operators
* Built-In Func/Proc:: Built-in functions and procedures
* M2 Constants:: Modula-2 constants
+* M2 Types:: Modula-2 types
* M2 Defaults:: Default settings for Modula-2
* Deviations:: Deviations from standard Modula-2
* M2 Checks:: Modula-2 type and range checks
@@ -9595,7 +9596,7 @@ as @code{^}.
@end table
@quotation
-@emph{Warning:} Sets and their operations are not yet supported, so @value{GDBN}
+@emph{Warning:} Set expressions and their operations are not yet supported, so @value{GDBN}
treats the use of the operator @code{IN}, or the use of operators
@code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
@code{<=}, and @code{>=} on sets as an error.
@@ -9764,6 +9765,170 @@ Pointer constants consist of integral values only.
Set constants are not yet supported.
@end itemize
+@node M2 Types
+@subsubsection Modula-2 Types
+@cindex Modula-2 types
+
+Currently @value{GDBN} can print the following data types in Modula-2
+syntax: array types, record types, set types, pointer types, procedure
+types, enumerated types, subrange types and base types. You can also
+print the contents of variables declared using these type.
+This section gives a number of simple source code examples together with
+sample @value{GDBN} sessions.
+
+The first example contains the following section of code:
+
+@smallexample
+VAR
+ s: SET OF CHAR ;
+ r: [20..40] ;
+@end smallexample
+
+@noindent
+and you can request @value{GDBN} to interrogate the type and value of
+@code{r} and @code{s}.
+
+@smallexample
+(@value{GDBP}) print s
+@{'A'..'C', 'Z'@}
+(@value{GDBP}) ptype s
+SET OF CHAR
+(@value{GDBP}) print r
+21
+(@value{GDBP}) ptype r
+[20..40]
+@end smallexample
+
+@noindent
+Likewise if your source code declares @code{s} as:
+
+@smallexample
+VAR
+ s: SET ['A'..'Z'] ;
+@end smallexample
+
+@noindent
+then you may query the type of @code{s} by:
+
+@smallexample
+(@value{GDBP}) ptype s
+type = SET ['A'..'Z']
+@end smallexample
+
+@noindent
+Note that at present you cannot interactively manipulate set
+expressions using the debugger.
+
+The following example shows how you might declare an array in Modula-2
+and how you can interact with @value{GDBN} to print its type and contents:
+
+@smallexample
+VAR
+ s: ARRAY [-10..10] OF CHAR ;
+@end smallexample
+
+@smallexample
+(@value{GDBP}) ptype s
+ARRAY [-10..10] OF CHAR
+@end smallexample
+
+Note that the array handling is not yet complete and although the type
+is printed correctly, expression handling still assumes that all
+arrays have a lower bound of zero and not @code{-10} as in the example
+above. Unbounded arrays are also not yet recognized in @value{GDBN}.
+
+Here are some more type related Modula-2 examples:
+
+@smallexample
+TYPE
+ colour = (blue, red, yellow, green) ;
+ t = [blue..yellow] ;
+VAR
+ s: t ;
+BEGIN
+ s := blue ;
+@end smallexample
+
+@noindent
+The @value{GDBN} interaction shows how you can query the data type
+and value of a variable.
+
+@smallexample
+(@value{GDBP}) print s
+$1 = blue
+(@value{GDBP}) ptype t
+type = [blue..yellow]
+@end smallexample
+
+@noindent
+In this example a Modula-2 array is declared and its contents
+displayed. Observe that the contents are written in the same way as
+their @code{C} counterparts.
+
+@smallexample
+VAR
+ s: ARRAY [1..5] OF CARDINAL ;
+BEGIN
+ s[1] := 1 ;
+@end smallexample
+
+@smallexample
+(@value{GDBP}) print s
+$1 = @{1, 0, 0, 0, 0@}
+(@value{GDBP}) ptype s
+type = ARRAY [1..5] OF CARDINAL
+@end smallexample
+
+The Modula-2 language interface to @value{GDBN} also understands
+pointer types as shown in this example:
+
+@smallexample
+VAR
+ s: POINTER TO ARRAY [1..5] OF CARDINAL ;
+BEGIN
+ NEW(s) ;
+ s^[1] := 1 ;
+@end smallexample
+
+@noindent
+and you can request that @value{GDBN} describes the type of @code{s}.
+
+@smallexample
+(@value{GDBP}) ptype s
+type = POINTER TO ARRAY [1..5] OF CARDINAL
+@end smallexample
+
+@value{GDBN} handles compound types as we can see in this example.
+Here we combine array types, record types, pointer types and subrange
+types:
+
+@smallexample
+TYPE
+ foo = RECORD
+ f1: CARDINAL ;
+ f2: CHAR ;
+ f3: myarray ;
+ END ;
+
+ myarray = ARRAY myrange OF CARDINAL ;
+ myrange = [-2..2] ;
+VAR
+ s: POINTER TO ARRAY myrange OF foo ;
+@end smallexample
+
+@noindent
+and you can ask @value{GDBN} to describe the type of @code{s} as shown
+below.
+
+@smallexample
+(@value{GDBP}) ptype s
+type = POINTER TO ARRAY [-2..2] OF foo = RECORD
+ f1 : CARDINAL;
+ f2 : CHAR;
+ f3 : ARRAY [-2..2] OF CARDINAL;
+END
+@end smallexample
+
@node M2 Defaults
@subsubsection Modula-2 defaults
@cindex Modula-2 defaults