all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Debug Fortran 90 code in Emacs with arguments.
@ 2022-04-05  2:27 Hongyi Zhao
  2022-04-05 11:18 ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05  2:27 UTC (permalink / raw
  To: help-gnu-emacs

I've the following Fortran 90 code snippet adapted from here [1]:

```
program echo_command_line
  integer i, cnt, len, status
  character c*100, b*100

  call get_command (b, len, status)
  if (status .ne. 0) then
     write (*,*) 'get_command failed with status = ', status
     stop
  end if
  write (*,*) 'command line = ', b (1:len)

  call get_command_argument (0, c, len, status)
  if (status .ne. 0) then
     write (*,*) 'Getting command name failed with status = ', status
     stop
  end if
  write (*,*) 'command name = ', c (1:len)

  cnt = command_argument_count ()
  write (*,*) 'number of command arguments = ', cnt

  do i = 1, cnt
     call get_command_argument (i, c, len, status)
     if (status .ne. 0) then
       write (*,*) 'get_command_argument failed: status = ', status, '
arg = ', i
       stop
     end if
     write (*,*) 'command arg ', i, ' = ', c (1:len)
  end do

  write (*,*) 'command line processed'
  end
```

The above code snippet must be run and debug with some arguments, say,
as follows:

-o 42 -a hello b

So, I want to know how to debug Fortran 90 code in Emacs with arguments.

[1] https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/c-to-d/command-argument-count.html#command-argument-count

Regards
-- 
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05  2:27 Debug Fortran 90 code in Emacs with arguments Hongyi Zhao
@ 2022-04-05 11:18 ` Eli Zaretskii
  2022-04-05 12:57   ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-05 11:18 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Tue, 5 Apr 2022 10:27:41 +0800
> 
> The above code snippet must be run and debug with some arguments, say,
> as follows:
> 
> -o 42 -a hello b
> 
> So, I want to know how to debug Fortran 90 code in Emacs with arguments.

Use GDB via the "M-x gdb" Emacs front-end.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 11:18 ` Eli Zaretskii
@ 2022-04-05 12:57   ` Hongyi Zhao
  2022-04-05 13:00     ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05 12:57 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 7:18 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Tue, 5 Apr 2022 10:27:41 +0800
> >
> > The above code snippet must be run and debug with some arguments, say,
> > as follows:
> >
> > -o 42 -a hello b
> >
> > So, I want to know how to debug Fortran 90 code in Emacs with arguments.
>
> Use GDB via the "M-x gdb" Emacs front-end.

I tried with the following steps, but still failed to figure it out:

1. $ emacs the_fortran_example.f90
2. In Emacs, issue the command `M-x gdb RET`.

At this point, I see the following information:

```
Current directory is ~/temp/FortranProject/bilbao_read/
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
gfotran: No such file or directory.
(gdb) exec-file get_command_argument.f90
"/home/werner/temp/FortranProject/bilbao_read/get_command_argument.f90":
not in executable format: file format not recognized
exit
Undefined command: "exit".  Try "help".
(gdb) q

Debugger finished
Current directory is ~/temp/FortranProject/bilbao_read/
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
gfotran: No such file or directory.
(gdb) q

Debugger finished
Current directory is ~/temp/FortranProject/bilbao_read/
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
gfotran: No such file or directory.
(gdb)
```

How to do next?

Regards
-- 
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 12:57   ` Hongyi Zhao
@ 2022-04-05 13:00     ` Hongyi Zhao
  2022-04-05 13:19       ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05 13:00 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 8:57 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Tue, Apr 5, 2022 at 7:18 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > > Date: Tue, 5 Apr 2022 10:27:41 +0800
> > >
> > > The above code snippet must be run and debug with some arguments, say,
> > > as follows:
> > >
> > > -o 42 -a hello b
> > >
> > > So, I want to know how to debug Fortran 90 code in Emacs with arguments.
> >
> > Use GDB via the "M-x gdb" Emacs front-end.
>
> I tried with the following steps, but still failed to figure it out:
>
> 1. $ emacs the_fortran_example.f90
> 2. In Emacs, issue the command `M-x gdb RET`.

Then I see the following setting in minibuffer, and I just hit RET to use it:

gdb -i=mi gfotran

>
> At this point, I see the following information:
>
> ```
> Current directory is ~/temp/FortranProject/bilbao_read/
> GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
> Copyright (C) 2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
>     <http://www.gnu.org/software/gdb/documentation/>.
>
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> gfotran: No such file or directory.
> (gdb) exec-file get_command_argument.f90
> "/home/werner/temp/FortranProject/bilbao_read/get_command_argument.f90":
> not in executable format: file format not recognized
> exit
> Undefined command: "exit".  Try "help".
> (gdb) q
>
> Debugger finished
> Current directory is ~/temp/FortranProject/bilbao_read/
> GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
> Copyright (C) 2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
>     <http://www.gnu.org/software/gdb/documentation/>.
>
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> gfotran: No such file or directory.
> (gdb) q
>
> Debugger finished
> Current directory is ~/temp/FortranProject/bilbao_read/
> GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
> Copyright (C) 2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
>     <http://www.gnu.org/software/gdb/documentation/>.
>
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> gfotran: No such file or directory.
> (gdb)
> ```
>
> How to do next?
>
> Regards
> --
> Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
> Theory and Simulation of Materials
> Hebei Vocational University of Technology and Engineering
> No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 13:00     ` Hongyi Zhao
@ 2022-04-05 13:19       ` Eli Zaretskii
  2022-04-05 13:23         ` Eli Zaretskii
  2022-04-05 14:19         ` Hongyi Zhao
  0 siblings, 2 replies; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-05 13:19 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Tue, 5 Apr 2022 21:00:31 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> > > Use GDB via the "M-x gdb" Emacs front-end.
> >
> > I tried with the following steps, but still failed to figure it out:
> >
> > 1. $ emacs the_fortran_example.f90
> > 2. In Emacs, issue the command `M-x gdb RET`.
> 
> Then I see the following setting in minibuffer, and I just hit RET to use it:
> 
> gdb -i=mi gfotran

Is 'gfortran' the name of your program's executable file?  If not,
edit the command to replace "gfortran" with the name of your program's
executable file.

If you never used a "M-x gdb" in Emacs, I suggest to read the section
"GDB Graphical Interface" (and its sub-sections) in the Emacs manual.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 13:19       ` Eli Zaretskii
@ 2022-04-05 13:23         ` Eli Zaretskii
  2022-04-05 13:52           ` Hongyi Zhao
  2022-04-05 14:19         ` Hongyi Zhao
  1 sibling, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-05 13:23 UTC (permalink / raw
  To: help-gnu-emacs

> Date: Tue, 05 Apr 2022 16:19:09 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> If you never used a "M-x gdb" in Emacs, I suggest to read the section
> "GDB Graphical Interface" (and its sub-sections) in the Emacs manual.

Another suggested reading is the "Sample Session" section in the GDB
manual.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 13:23         ` Eli Zaretskii
@ 2022-04-05 13:52           ` Hongyi Zhao
  2022-04-05 14:02             ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05 13:52 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 9:23 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Date: Tue, 05 Apr 2022 16:19:09 +0300
> > From: Eli Zaretskii <eliz@gnu.org>
> >
> > If you never used a "M-x gdb" in Emacs, I suggest to read the section
> > "GDB Graphical Interface" (and its sub-sections) in the Emacs manual.
>
> Another suggested reading is the "Sample Session" section in the GDB
> manual.

Do you mean this one?

https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_4.html#SEC5

Yours,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 13:52           ` Hongyi Zhao
@ 2022-04-05 14:02             ` Eli Zaretskii
  2022-04-05 14:14               ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-05 14:02 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Tue, 5 Apr 2022 21:52:36 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> > Another suggested reading is the "Sample Session" section in the GDB
> > manual.
> 
> Do you mean this one?
> 
> https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_4.html#SEC5

If you have GDB installed, you should have the manual on your system,
in Info format, suitable for reading in Emacs.  Try

  C-h i
  m gdb RET

But if you for some reason must read the HTML version with your
browser, it is better to read the latest version:

  https://sourceware.org/gdb/current/onlinedocs/gdb/Sample-Session.html#Sample-Session



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 14:02             ` Eli Zaretskii
@ 2022-04-05 14:14               ` Hongyi Zhao
  0 siblings, 0 replies; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05 14:14 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 10:02 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Tue, 5 Apr 2022 21:52:36 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > Another suggested reading is the "Sample Session" section in the GDB
> > > manual.
> >
> > Do you mean this one?
> >
> > https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_4.html#SEC5
>
> If you have GDB installed, you should have the manual on your system,
> in Info format, suitable for reading in Emacs.  Try
>
>   C-h i
>   m gdb RET

Thank you for your tip. Supplementary note: The following package
needs to be installed first on Debian derivative distributions:

$ sudo apt install gdb-doc

> But if you for some reason must read the HTML version with your
> browser, it is better to read the latest version:
>
>   https://sourceware.org/gdb/current/onlinedocs/gdb/Sample-Session.html#Sample-Session

I am grateful for your information.

Regards,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 13:19       ` Eli Zaretskii
  2022-04-05 13:23         ` Eli Zaretskii
@ 2022-04-05 14:19         ` Hongyi Zhao
  2022-04-05 15:52           ` Eli Zaretskii
  1 sibling, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-05 14:19 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 9:19 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Tue, 5 Apr 2022 21:00:31 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > > Use GDB via the "M-x gdb" Emacs front-end.
> > >
> > > I tried with the following steps, but still failed to figure it out:
> > >
> > > 1. $ emacs the_fortran_example.f90
> > > 2. In Emacs, issue the command `M-x gdb RET`.
> >
> > Then I see the following setting in minibuffer, and I just hit RET to use it:
> >
> > gdb -i=mi gfotran
>
> Is 'gfortran' the name of your program's executable file?  If not,
> edit the command to replace "gfortran" with the name of your program's
> executable file.

I tried as follows, but still failed:

M-x gdb RET
# 1 2 are arguments passed to the program:
Run gdb (like this): gdb -i=mi ./bin/Debug/bilbao_read 1 2

Then I encounter the following rather messy information:

```
Current directory is /home/werner/temp/FortranProject/bilbao_read/bin/Debug/
Error: Either -i=mi wasn’t specified on the GDB command line, or the
extra socket couldn’t be established.  Consider using M-x gud-gdb
instead.
Excess command line arguments ignored. (2)
=thread-group-added,id="i1"
~"GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2\n"
~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\nThis is free software: you are
free to change and redistribute it.\nThere is NO WARRANTY, to the
extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n
 <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
~"Reading symbols from
/home/werner/temp/FortranProject/bilbao_read/bin/Debug/bilbao_read...\n"
~"Attaching to program:
/home/werner/temp/FortranProject/bilbao_read/bin/Debug/bilbao_read,
process 1\n"
&"Could not attach to process.  If your uid matches the uid of the
target\nprocess, check the setting of
/proc/sys/kernel/yama/ptrace_scope, or try\nagain as the root user.
For more details, see /etc/sysctl.d/10-ptrace.conf\n"
&"ptrace: Operation not permitted.\n"
&"/home/werner/temp/FortranProject/bilbao_read/bin/Debug/1: No such
file or directory.\n"
(gdb)
1^done
(gdb)
2^done
(gdb)
3^done
(gdb)
4^done
(gdb)
5^done
(gdb)
6^done,files=[{file="get_command_argument.f90",fullname="/home/werner/temp/FortranProject/bilbao_read/get_command_argument.f90"}]
(gdb)
7^done,line="24",file="get_command_argument.f90",fullname="/home/werner/temp/FortranProject/bilbao_read/get_command_argument.f90",macro-info="0"
(gdb)
8^done,value="(gdb) "
(gdb)
9^error,msg="No registers."
(gdb)
10^done,threads=[]
(gdb)
11^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
12^done,threads=[]
(gdb)
13^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
```

Yours,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 14:19         ` Hongyi Zhao
@ 2022-04-05 15:52           ` Eli Zaretskii
  2022-04-06  1:46             ` Hongyi Zhao
  2022-04-06  2:26             ` Hongyi Zhao
  0 siblings, 2 replies; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-05 15:52 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Tue, 5 Apr 2022 22:19:54 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> > > gdb -i=mi gfotran
> >
> > Is 'gfortran' the name of your program's executable file?  If not,
> > edit the command to replace "gfortran" with the name of your program's
> > executable file.
> 
> I tried as follows, but still failed:
> 
> M-x gdb RET
> # 1 2 are arguments passed to the program:
> Run gdb (like this): gdb -i=mi ./bin/Debug/bilbao_read 1 2
> 
> Then I encounter the following rather messy information:

You use a non-trivial tool for the first time, so you should at least
study its --help screen.  That's not how you pass command-line
arguments to a program being debugged.  You need to use --args:

   gdb -i=mi --args ./bin/Debug/bilbao_read 1 2



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 15:52           ` Eli Zaretskii
@ 2022-04-06  1:46             ` Hongyi Zhao
  2022-04-06  2:32               ` Eli Zaretskii
  2022-04-06  2:26             ` Hongyi Zhao
  1 sibling, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-06  1:46 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 11:52 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Tue, 5 Apr 2022 22:19:54 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > > gdb -i=mi gfotran
> > >
> > > Is 'gfortran' the name of your program's executable file?  If not,
> > > edit the command to replace "gfortran" with the name of your program's
> > > executable file.
> >
> > I tried as follows, but still failed:
> >
> > M-x gdb RET
> > # 1 2 are arguments passed to the program:
> > Run gdb (like this): gdb -i=mi ./bin/Debug/bilbao_read 1 2
> >
> > Then I encounter the following rather messy information:
>
> You use a non-trivial tool for the first time, so you should at least
> study its --help screen.  That's not how you pass command-line
> arguments to a program being debugged.  You need to use --args:
>
>    gdb -i=mi --args ./bin/Debug/bilbao_read 1 2

This works, but I noticed the following information:

Target doesn’t support non-stop mode.  Turning it off.

Some additional remarks:

1. GDB itself is quite complex to use. Not to mention using it in
Emacs. Therefore, it is indeed an extraordinary tool for users who use
it for the first time.
2. I figured out the meaning of the above-mentioned options used in
the example here, as shown below, found from the info manual:


$ info gdb


'-interpreter INTERP'
     Use the interpreter INTERP for interface with the controlling
     program or device.  This option is meant to be set by programs
     which communicate with GDB using it as a back end.  *Note Command
     Interpreters: Interpreters.

     '--interpreter=mi' (or '--interpreter=mi3') causes GDB to use the
     "GDB/MI interface" version 3 (*note The GDB/MI Interface: GDB/MI.)
     included since GDB version 9.1.  GDB/MI version 2 ('mi2'), included
     in GDB 6.0 and version 1 ('mi1'), included in GDB 5.3, are also
     available.  Earlier GDB/MI interfaces are no longer supported.


'--args'
     Change interpretation of command line so that arguments following
     the executable file are passed as command line arguments to the
     inferior.  This option stops option processing.


But I can't find any explanation that the `-interpreter' can be
abbreviated as `-i'.

Regards,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-05 15:52           ` Eli Zaretskii
  2022-04-06  1:46             ` Hongyi Zhao
@ 2022-04-06  2:26             ` Hongyi Zhao
  2022-04-06 10:50               ` Eli Zaretskii
  1 sibling, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-06  2:26 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Tue, Apr 5, 2022 at 11:52 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Tue, 5 Apr 2022 22:19:54 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > > gdb -i=mi gfotran
> > >
> > > Is 'gfortran' the name of your program's executable file?  If not,
> > > edit the command to replace "gfortran" with the name of your program's
> > > executable file.
> >
> > I tried as follows, but still failed:
> >
> > M-x gdb RET
> > # 1 2 are arguments passed to the program:
> > Run gdb (like this): gdb -i=mi ./bin/Debug/bilbao_read 1 2
> >
> > Then I encounter the following rather messy information:
>
> You use a non-trivial tool for the first time, so you should at least
> study its --help screen.  That's not how you pass command-line
> arguments to a program being debugged.  You need to use --args:
>
>    gdb -i=mi --args ./bin/Debug/bilbao_read 1 2

I have understood by and large the usage of GDB within Emacs, based on
a brief introduction here [1].

BTW, the above introduction says the following:

```
Set a breakpoint by going to the source line of the program you're
debugging, and typing:

C-x [space]

(That's the space bar.) GDB will tell you that you've just set a breakpoint.
```

But I noticed the following key binding by running `C-h k C-x [space]
RET` on my machine:

```
rectangle-mark-mode is an autoloaded, interactive and compiled
function defined in rect.el.gz.

Signature
(rectangle-mark-mode &optional ARG)

Documentation
Toggle the region as rectangular.

This is a minor mode.  If called interactively, toggle the
Rectangle-Mark mode mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate rectangle-mark-mode.

The mode's hook is called both when the mode is enabled and when it is
disabled.

Activates the region if needed.  Only lasts until the region is deactivated.

View in manual

Key Bindings
ctl-x-map SPC
global-map C-x SPC
```

[1] https://courses.cs.washington.edu/courses/cse378/97au/help/gdb-emacs.html

Regards,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06  1:46             ` Hongyi Zhao
@ 2022-04-06  2:32               ` Eli Zaretskii
  2022-04-06  3:02                 ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-06  2:32 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 6 Apr 2022 09:46:27 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> >    gdb -i=mi --args ./bin/Debug/bilbao_read 1 2
> 
> This works, but I noticed the following information:
> 
> Target doesn’t support non-stop mode.  Turning it off.

This depends on your system, and is generally not a problem.

> But I can't find any explanation that the `-interpreter' can be
> abbreviated as `-i'.

From the manual:

     Many options have both long and short forms; both are shown in the
  following list.  GDB also recognizes the long forms if you truncate
  them, so long as enough of the option is present to be unambiguous.
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06  2:32               ` Eli Zaretskii
@ 2022-04-06  3:02                 ` Hongyi Zhao
  0 siblings, 0 replies; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-06  3:02 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Wed, Apr 6, 2022 at 10:32 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 6 Apr 2022 09:46:27 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > >    gdb -i=mi --args ./bin/Debug/bilbao_read 1 2
> >
> > This works, but I noticed the following information:
> >
> > Target doesn’t support non-stop mode.  Turning it off.
>
> This depends on your system, and is generally not a problem.

Here is a concise tutorial [1].

> > But I can't find any explanation that the `-interpreter' can be
> > abbreviated as `-i'.
>
> From the manual:
>
>      Many options have both long and short forms; both are shown in the
>   following list.  GDB also recognizes the long forms if you truncate
>   them, so long as enough of the option is present to be unambiguous.
>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thank you for pointing this out, and I have confirmed it as follows:

$ gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2

$ info gdb|grep -m1 -A2 -B2 'as enough of '
   Many options have both long and short forms; both are shown in the
following list.  GDB also recognizes the long forms if you truncate
them, so long as enough of the option is present to be unambiguous.  (If
you prefer, you can flag option arguments with '--' rather than '-',
though we illustrate the more usual convention.)

[1] http://c.biancheng.net/view/8270.html

Regards,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06  2:26             ` Hongyi Zhao
@ 2022-04-06 10:50               ` Eli Zaretskii
  2022-04-06 13:05                 ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-06 10:50 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 6 Apr 2022 10:26:11 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> BTW, the above introduction says the following:
> 
> ```
> Set a breakpoint by going to the source line of the program you're
> debugging, and typing:
> 
> C-x [space]
> 
> (That's the space bar.) GDB will tell you that you've just set a breakpoint.

That description is outdated, please report a bug to the GDB
developers.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06 10:50               ` Eli Zaretskii
@ 2022-04-06 13:05                 ` Hongyi Zhao
  2022-04-06 14:12                   ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-06 13:05 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Wed, Apr 6, 2022 at 6:51 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 6 Apr 2022 10:26:11 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > BTW, the above introduction says the following:
> >
> > ```
> > Set a breakpoint by going to the source line of the program you're
> > debugging, and typing:
> >
> > C-x [space]
> >
> > (That's the space bar.) GDB will tell you that you've just set a breakpoint.
>
> That description is outdated, please report a bug to the GDB
> developers.

The above description is written before many years (fall 1997), and
the author may not bet GDB developers. So, why do you give the above
suggestion?

[1] https://courses.cs.washington.edu/courses/cse378/97au/help/gdb-emacs.html

Yours,
Hongyi



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06 13:05                 ` Hongyi Zhao
@ 2022-04-06 14:12                   ` Eli Zaretskii
  2022-04-06 14:42                     ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-06 14:12 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 6 Apr 2022 21:05:24 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> On Wed, Apr 6, 2022 at 6:51 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > > Set a breakpoint by going to the source line of the program you're
> > > debugging, and typing:
> > >
> > > C-x [space]
> > >
> > > (That's the space bar.) GDB will tell you that you've just set a breakpoint.
> >
> > That description is outdated, please report a bug to the GDB
> > developers.
> 
> The above description is written before many years (fall 1997), and
> the author may not bet GDB developers. So, why do you give the above
> suggestion?

Because most of it is still valid for first-time GDB users, and the
GDB manual is not supposed to be the canonical source of information
about Emacs, anyway.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06 14:12                   ` Eli Zaretskii
@ 2022-04-06 14:42                     ` Hongyi Zhao
  2022-04-06 15:42                       ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-06 14:42 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Wed, Apr 6, 2022 at 10:12 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 6 Apr 2022 21:05:24 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > On Wed, Apr 6, 2022 at 6:51 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > >
> > > > Set a breakpoint by going to the source line of the program you're
> > > > debugging, and typing:
> > > >
> > > > C-x [space]
> > > >
> > > > (That's the space bar.) GDB will tell you that you've just set a breakpoint.
> > >
> > > That description is outdated, please report a bug to the GDB
> > > developers.
> >
> > The above description is written before many years (fall 1997), and
> > the author may not bet GDB developers. So, why do you give the above
> > suggestion?
>
> Because most of it is still valid for first-time GDB users, and the
> GDB manual is not supposed to be the canonical source of information
> about Emacs, anyway.

1. If GDB manual is not supposed to be the canonical source of information
 about using GDB in Emacs, what should be?
2. According to your suggestion, what bug(s) should I report to GDB developers?

Regards,
HZ



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06 14:42                     ` Hongyi Zhao
@ 2022-04-06 15:42                       ` Eli Zaretskii
  2022-04-07  2:02                         ` Hongyi Zhao
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-04-06 15:42 UTC (permalink / raw
  To: help-gnu-emacs

> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 6 Apr 2022 22:42:02 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> > > The above description is written before many years (fall 1997), and
> > > the author may not bet GDB developers. So, why do you give the above
> > > suggestion?
> >
> > Because most of it is still valid for first-time GDB users, and the
> > GDB manual is not supposed to be the canonical source of information
> > about Emacs, anyway.
> 
> 1. If GDB manual is not supposed to be the canonical source of information
>  about using GDB in Emacs, what should be?

The section in the Emacs manual to which I pointed earlier in this
thread.  And also the built-in documentation (doc strings) of the
related variables and commands.  See

  M-x customize-group RET gdb RET

> 2. According to your suggestion, what bug(s) should I report to GDB developers?

That the Emacs keybindings they describe are outdated.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Debug Fortran 90 code in Emacs with arguments.
  2022-04-06 15:42                       ` Eli Zaretskii
@ 2022-04-07  2:02                         ` Hongyi Zhao
  0 siblings, 0 replies; 21+ messages in thread
From: Hongyi Zhao @ 2022-04-07  2:02 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Wed, Apr 6, 2022 at 11:43 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 6 Apr 2022 22:42:02 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > > The above description is written before many years (fall 1997), and
> > > > the author may not bet GDB developers. So, why do you give the above
> > > > suggestion?
> > >
> > > Because most of it is still valid for first-time GDB users, and the
> > > GDB manual is not supposed to be the canonical source of information
> > > about Emacs, anyway.
> >
> > 1. If GDB manual is not supposed to be the canonical source of information
> >  about using GDB in Emacs, what should be?
>
> The section in the Emacs manual to which I pointed earlier in this
> thread.  And also the built-in documentation (doc strings) of the
> related variables and commands.  See
>
>   M-x customize-group RET gdb RET

Thank you for pointing this out.

> > 2. According to your suggestion, what bug(s) should I report to GDB developers?
>
> That the Emacs keybindings they describe are outdated.

Done. See the following information:

from:Hongyi Zhao <hongyi.zhao@gmail.com>
to:gdb@sourceware.org
date:Apr 7, 2022, 9:59 AM
subject:The Emacs keybindings of "C-x [space]" described in a maybe
still widely referred tutorial are outdated.

Regards,
HZ



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-04-07  2:02 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05  2:27 Debug Fortran 90 code in Emacs with arguments Hongyi Zhao
2022-04-05 11:18 ` Eli Zaretskii
2022-04-05 12:57   ` Hongyi Zhao
2022-04-05 13:00     ` Hongyi Zhao
2022-04-05 13:19       ` Eli Zaretskii
2022-04-05 13:23         ` Eli Zaretskii
2022-04-05 13:52           ` Hongyi Zhao
2022-04-05 14:02             ` Eli Zaretskii
2022-04-05 14:14               ` Hongyi Zhao
2022-04-05 14:19         ` Hongyi Zhao
2022-04-05 15:52           ` Eli Zaretskii
2022-04-06  1:46             ` Hongyi Zhao
2022-04-06  2:32               ` Eli Zaretskii
2022-04-06  3:02                 ` Hongyi Zhao
2022-04-06  2:26             ` Hongyi Zhao
2022-04-06 10:50               ` Eli Zaretskii
2022-04-06 13:05                 ` Hongyi Zhao
2022-04-06 14:12                   ` Eli Zaretskii
2022-04-06 14:42                     ` Hongyi Zhao
2022-04-06 15:42                       ` Eli Zaretskii
2022-04-07  2:02                         ` Hongyi Zhao

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.