DWARF and GDB Algol 68 support - notes
Jose E. Marchesi
jemarch@gnu.org
Sat May 9 10:58:48 GMT 2026
> Hi Cuper.
>
> These are the notes from the discussion we have just had over jitsi
> about adding support for Algol 68 to GDB.
>
> begin int x := 20; (*)
> prio > = 4;
> real i = (x_1>10 | 10 | x_2);
> { Without -g: real(x) }
> { With -g: (real x_2 = real(x); x) }
> puts (fixed(1) + "'n")
> end
I just noticed that creating var_decls for the applied identifiers x_1,
x_2, etc, doesn't mean that the var_decl for the defining identifier x
goes away: it is still there.
This is very good, because it means that, given a listing:
10 begin int x := 20;
11 prio > = 4;
12 real i = (x_1>10 | 10 | x_2);
13 puts (fixed(1) + "'n")
14 end
When we breakpoint at line 13, we have:
(gdb) print x
x = 20
(gdb) print x_1
x_1 = 20
(gdb) print x_2
x_2 = 20.0
Therefore, we can document that using a non-subscripted identifier
refers to the defining identifier, i.e. the object x, whereas using a
subscripted version of x refers to some particular applied identifier,
in its role as coercee.
This is looking good :)
>
> unit
> |
> widen
> |
> deref deref
> | |
> x x
>
> (gdb) print x_2 + 10
>
> For unit_is_applied_identifier (p)
>
> Skip zero or more nodes:
>
> WIDENING
> VOIDING
> ROWING
> UNITING
> DEREFERENCING
> DEPROCEDURING
>
> If next node is IDENTIFIER, return TREE_DECL (TAX (node))
> Otherwise, return NULL_TREE
>
> Code sketch:
>
> diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc
> index 3cbf131112b..831fd509c2f 100644
> --- a/gcc/algol68/a68-low-units.cc
> +++ b/gcc/algol68/a68-low-units.cc
> @@ -1371,5 +1371,27 @@ a68_lower_formal_hole (NODE_T *p, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
> tree
> a68_lower_unit (NODE_T *p, LOW_CTX_T ctx)
> {
> - return a68_lower_tree (SUB (p), ctx);
> + tree unit = a68_lower_tree (SUB (p), ctx);
> +
> + if (debug_info)
> + {
> + tree *id_decl = unit_is_applied_identifier (p);
> +
> + /* If the unit is an applied identifier after zero or more coercions. */
> + if (id_decl != NULL_TREE)
> + {
> + /* Return a compound_stmt
> +
> + (var_decl for an object named ID_N, and value UNIT,
> + ID_N)
> + */
> + unit = save_expr (unit);
> + return fold_build2 (COMPOUND_EXPR, TREE_TYPE (unit),
> + build_decl (LOC (unit),
> + VAR_DECL,
> + DECL_NAME (id_decl) + "_" + ++(NAMECNT (TAX (id_decl))),
> + unit),
> + unit);
> + }
> + }
> }
> diff --git a/gcc/algol68/a68-types.h b/gcc/algol68/a68-types.h
> index 9dc3d006e9f..6736c51ca18 100644
> --- a/gcc/algol68/a68-types.h
> +++ b/gcc/algol68/a68-types.h
> @@ -638,6 +638,7 @@ struct GTY((chain_next ("%h.next"))) TAG_T
> LOWERER_T lowerer;
> TAG_T *next, *body;
> const char *extern_symbol;
> + int name_counter;
> };
> #define NO_TAG ((TAG_T *) 0)
>
> @@ -1021,6 +1022,7 @@ struct GTY(()) A68_T
> #define MULTIPLE(p) ((p)->multiple_mode)
> #define MULTIPLE_MODE(p) ((p)->multiple_mode)
> #define NAME(p) ((p)->name)
> +#define NAMECNT(p) ((p)->name_counter)
> #define NEST(p) ((p)->nest)
> #define NEST_PROC(p) ((p)->nest_proc)
> #define NEXT(p) ((p)->next)
>
More information about the Algol68
mailing list