public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to check if .gdbinit macros have been loaded?
       [not found] <526939713.188425.1628429312671.ref@mail.yahoo.com>
@ 2021-08-08 13:28 ` Mahmood Naderan
  2021-08-09 14:31   ` Martin Simmons
  0 siblings, 1 reply; 5+ messages in thread
From: Mahmood Naderan @ 2021-08-08 13:28 UTC (permalink / raw)
  To: gdb


Hi

I use a .gdbinit [1] file which is supposed to print some debug information when the program is being run. 
When I run GDB, the first printf is written on the screen. So, that means the .gdbinit file has been loaded.
However, I don't see the rest of the information that must be printed on the screen. There are a lot of printf for this purpose.


How can I be sure that the rest of the macros are called? Maybe they hit errors and I am not able to see those errors.

$ gdb ~/accel-sim-framework/gpu-simulator/bin/debug/accel-sim.out
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"...
Reading symbols from /home/mnaderan/accel-sim-framework/gpu-simulator/bin/debug/accel-sim.out...

  ** loading GPGPU-Sim debugging macros... **

(gdb) run -config ./gpgpusim.config -trace ./traces/kernelslist.g
Starting program: /home/mnaderan/accel-sim-framework/gpu-simulator/bin/debug/accel-sim.out -config ./gpgpusim.config -trace ./traces/kernelslist.g
warning: the debug information found in "/lib64/ld-2.31.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Accel-Sim [build accelsim-commit-16c3068431c7bf46d425aac134947ceb3e6a8f42_modified_11.0]

        *** GPGPU-Sim Simulator Version 4.1.0  [build gpgpu-sim_git-commit-6ad461a95ac71e0597274c4f750ce03bb3a6871e_modified_3.0] ***






As you can see the "debugging macro" message shows that the .gdbinit file has been loaded.


Any idea about that?



[1] https://github.com/gpgpu-sim/gpgpu-sim_distribution/blob/master/.gdbinit



Regards,
Mahmood

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

* Re: How to check if .gdbinit macros have been loaded?
  2021-08-08 13:28 ` How to check if .gdbinit macros have been loaded? Mahmood Naderan
@ 2021-08-09 14:31   ` Martin Simmons
  2021-08-11 14:09     ` Mahmood Naderan
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Simmons @ 2021-08-09 14:31 UTC (permalink / raw)
  To: Mahmood Naderan; +Cc: gdb

>>>>> On Sun, 8 Aug 2021 13:28:32 +0000 (UTC), Mahmood Naderan via Gdb said:
> 
> Hi
> 
> I use a .gdbinit [1] file which is supposed to print some debug information when the program is being run. 
> When I run GDB, the first printf is written on the screen. So, that means the .gdbinit file has been loaded.
> However, I don't see the rest of the information that must be printed on the screen. There are a lot of printf for this purpose.

The other printfs are inside define ... end, so you will only see them
when the named command is used.

> How can I be sure that the rest of the macros are called? Maybe they hit errors and I am not able to see those errors.

What makes you think these commands (macros) will be called
automatically?  I think you have to call them yourself from the gdb
command line.

BTW, the "show user" command will tell you if a particular user defined
command exists.

__Martin

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

* Re: How to check if .gdbinit macros have been loaded?
  2021-08-09 14:31   ` Martin Simmons
@ 2021-08-11 14:09     ` Mahmood Naderan
  2021-08-12 15:03       ` Martin Simmons
  0 siblings, 1 reply; 5+ messages in thread
From: Mahmood Naderan @ 2021-08-11 14:09 UTC (permalink / raw)
  To: Martin Simmons; +Cc: gdb

>What makes you think these commands (macros) will be called
>automatically?  I think you have to call them yourself from the gdb
>command line. 
>BTW, the "show user" command will tell you if a particular user defined
command exists.

Hi Martin,
Yes if I run ''show user" I see the functions defined in the .gdbinit file.

I tried your suggestion by manually calling one of the functions which is 'dp 3' [1]. However, it fails with the following error:


accel-sim.out: shader.cc:1657: unsigned int shader_core_ctx::translate_local_memaddr(address_type, unsigned int, unsigned int, unsigned int, new_addr_type*): Assertion `localaddr % 4 == 0' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) dp 3
Dumping pipeline state...

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ba9468 in gpgpu_sim::dump_pipeline (this=0x0, mask=69, s=3, m=0) at gpu-sim.cc:2028
2028      for (unsigned i = 0; i < m_shader_config->n_simt_clusters; i++) {
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(gpgpu_sim::dump_pipeline(int, int, int) const) will be abandoned.



I don't know if the .gdbinit functions can be used after the program receives segmentation fault.
Any thoughts on that?



[1] https://github.com/gpgpu-sim/gpgpu-sim_distribution/blob/master/.gdbinit#L10


Regards,
Mahmood






On Monday, August 9, 2021, 4:31:34 PM GMT+2, Martin Simmons <qqxnjvamvxwx@dyxyl.com> wrote: 





>>>>> On Sun, 8 Aug 2021 13:28:32 +0000 (UTC), Mahmood Naderan via Gdb said:
> 
> Hi
> 
> I use a .gdbinit [1] file which is supposed to print some debug information when the program is being run. 
> When I run GDB, the first printf is written on the screen. So, that means the .gdbinit file has been loaded.
> However, I don't see the rest of the information that must be printed on the screen. There are a lot of printf for this purpose.

The other printfs are inside define ... end, so you will only see them
when the named command is used.


> How can I be sure that the rest of the macros are called? Maybe they hit errors and I am not able to see those errors.


What makes you think these commands (macros) will be called
automatically?  I think you have to call them yourself from the gdb
command line.

BTW, the "show user" command will tell you if a particular user defined
command exists.

__Martin


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

* Re: How to check if .gdbinit macros have been loaded?
  2021-08-11 14:09     ` Mahmood Naderan
@ 2021-08-12 15:03       ` Martin Simmons
  2021-08-12 17:32         ` Mahmood Naderan
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Simmons @ 2021-08-12 15:03 UTC (permalink / raw)
  To: Mahmood Naderan; +Cc: gdb

>>>>> On Wed, 11 Aug 2021 14:09:06 +0000 (UTC), Mahmood Naderan said:
> 
> >What makes you think these commands (macros) will be called
> >automatically?  I think you have to call them yourself from the gdb
> >command line. 
> >BTW, the "show user" command will tell you if a particular user defined
> command exists.
> 
> Hi Martin,
> Yes if I run ''show user" I see the functions defined in the .gdbinit file.
> 
> I tried your suggestion by manually calling one of the functions which is 'dp 3' [1]. However, it fails with the following error:
> 
> 
> accel-sim.out: shader.cc:1657: unsigned int shader_core_ctx::translate_local_memaddr(address_type, unsigned int, unsigned int, unsigned int, new_addr_type*): Assertion `localaddr % 4 == 0' failed.
> 
> Program received signal SIGABRT, Aborted.
> __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> 50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> (gdb) dp 3
> Dumping pipeline state...
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7ba9468 in gpgpu_sim::dump_pipeline (this=0x0, mask=69, s=3, m=0) at gpu-sim.cc:2028
> 2028      for (unsigned i = 0; i < m_shader_config->n_simt_clusters; i++) {
> The program being debugged was signaled while in a function called from GDB.
> GDB has restored the context to what it was before the call.
> To change this behavior use "set unwindonsignal off".
> Evaluation of the expression containing the function
> (gpgpu_sim::dump_pipeline(int, int, int) const) will be abandoned.
> 
> 
> 
> I don't know if the .gdbinit functions can be used after the program receives segmentation fault.

Was it actually SIGABRT that stopped the program initially, rather than
segmentation fault?

> Any thoughts on that?

The segmentation fault message says this=0x0, which probably causes it.
The value of "this" comes from gdb's evaluation of
GPGPU_Context()->the_gpgpusim->g_the_gpu so maybe that is NULL at that
point in the program?

__Martin


> 
> 
> 
> [1] https://github.com/gpgpu-sim/gpgpu-sim_distribution/blob/master/.gdbinit#L10
> 
> 
> Regards,
> Mahmood
> 
> 
> 
> 
> 
> 
> On Monday, August 9, 2021, 4:31:34 PM GMT+2, Martin Simmons <qqxnjvamvxwx@dyxyl.com> wrote: 
> 
> 
> 
> 
> 
>>>>> On Sun, 8 Aug 2021 13:28:32 +0000 (UTC), Mahmood Naderan via Gdb said:
> > 
> > Hi
> > 
> > I use a .gdbinit [1] file which is supposed to print some debug information when the program is being run. 
> > When I run GDB, the first printf is written on the screen. So, that means the .gdbinit file has been loaded.
> > However, I don't see the rest of the information that must be printed on the screen. There are a lot of printf for this purpose.
> 
> The other printfs are inside define ... end, so you will only see them
> when the named command is used.
> 
> 
> > How can I be sure that the rest of the macros are called? Maybe they hit errors and I am not able to see those errors.
> 
> 
> What makes you think these commands (macros) will be called
> automatically?  I think you have to call them yourself from the gdb
> command line.
> 
> BTW, the "show user" command will tell you if a particular user defined
> command exists.
> 
> __Martin
> 

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

* Re: How to check if .gdbinit macros have been loaded?
  2021-08-12 15:03       ` Martin Simmons
@ 2021-08-12 17:32         ` Mahmood Naderan
  0 siblings, 0 replies; 5+ messages in thread
From: Mahmood Naderan @ 2021-08-12 17:32 UTC (permalink / raw)
  To: Martin Simmons; +Cc: gdb

>
>Was it actually SIGABRT that stopped the program initially, rather than
>segmentation fault?

Yes that is SIGABRT rather than segmentation fault because the program hits an assertion error. I mistakenly wrote that as segfault.


>The segmentation fault message says this=0x0, which probably causes it.
>The value of "this" comes from gdb's evaluation of
>GPGPU_Context()->the_gpgpusim->g_the_gpu so maybe that is NULL at that
>point in the program?

Is there any way to debug more. 
In fact I want to use the .gdbinit macro to debug my program. Now I have to find a way to debug the .gdbinit itself :)




Regards,
Mahmood


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

end of thread, other threads:[~2021-08-12 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <526939713.188425.1628429312671.ref@mail.yahoo.com>
2021-08-08 13:28 ` How to check if .gdbinit macros have been loaded? Mahmood Naderan
2021-08-09 14:31   ` Martin Simmons
2021-08-11 14:09     ` Mahmood Naderan
2021-08-12 15:03       ` Martin Simmons
2021-08-12 17:32         ` Mahmood Naderan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).