[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get the address of a variable in GDB?
From: |
Gaius Mulley |
Subject: |
Re: How to get the address of a variable in GDB? |
Date: |
Fri, 04 Oct 2024 01:37:04 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Mohammad-Reza Nabipoor <mnabipoor@gnu.org> writes:
> Hi.
>
> I hope this is the right place to ask this question.
>
> I have the following program:
>
> ```
> MODULE hello;
>
> FROM StrIO IMPORT WriteString, WriteLn;
> VAR foo : INTEGER;
>
> BEGIN
> foo := 24;
> WriteString ('hello world'); WriteLn
> END hello.
> ```
>
> And I compiled it using `gm2 -g -o hello hello.mod' command.
>
> How can I get the addres off `foo' while debugging this program in GDB?
>
> The `p &foo' GDB command gives syntax error:
> "A syntax error in expression, near `&foo'."
>
> I know that `&foo' is not a valid Modula-2 syntax, but in similar case in Ada
> prgoramming
> language, they've extended the language parser to accept `&foo' expression in
> GDB.
>
> `ADR' function is not also available (and I don't know how to import it from
> `SYSTEM' module inside GDB).
>
>
> Thanks.
Hi Mohammad-Reza,
sure this is the correct place to ask the question. This is a missing
feature, I've just written a patch (for the development gdb) - and will
post it to the gdb patch mailing list once I've rerun the testsuite.
many thanks for the bug report. In the meanwhile I guess an awful work
around would be to:
(gdb) break _M2_hello_init
(gdb) run
(gdb) set lang c
(gdb) print &foo
(The proposed patch will implement "print ADR(foo)")
regards,
Gaius
- Re: How to get the address of a variable in GDB?,
Gaius Mulley <=