grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* How to enable MM debugging?
@ 2016-11-29 13:52 Stanislav Kholmanskikh
  2016-11-29 14:17 ` Andrei Borzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Kholmanskikh @ 2016-11-29 13:52 UTC (permalink / raw)
  To: grub-devel

Hi!

Does anybody use MM debugging? If so, what is the recommended/working
way of enabling it?

These steps do not work:

1. Run ./configure with '--enable-mm-debug'. It reports:

With memory debugging: Yes

2. Then build and install the binaries, and install the boot loader

3. Then set 'grub_mm_debug=1' in the grub's prompt.

grub> set grub_mm_debug=1
grub> insmod ofnet
grub>

During initialization, ofnet calls grub_malloc(), so I expect some debug
messages to be printed on 'insmod ofnet'.

Am I missing something, or is it a bug?

Thanks.




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

* Re: How to enable MM debugging?
  2016-11-29 13:52 How to enable MM debugging? Stanislav Kholmanskikh
@ 2016-11-29 14:17 ` Andrei Borzenkov
  2016-11-29 14:38   ` Stanislav Kholmanskikh
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Borzenkov @ 2016-11-29 14:17 UTC (permalink / raw)
  To: The development of GNU GRUB

On Tue, Nov 29, 2016 at 4:52 PM, Stanislav Kholmanskikh
<stanislav.kholmanskikh@oracle.com> wrote:
> Hi!
>
> Does anybody use MM debugging? If so, what is the recommended/working
> way of enabling it?
>
> These steps do not work:
>
> 1. Run ./configure with '--enable-mm-debug'. It reports:
>
> With memory debugging: Yes
>
> 2. Then build and install the binaries, and install the boot loader
>
> 3. Then set 'grub_mm_debug=1' in the grub's prompt.
>

This environment variable is not used.

> grub> set grub_mm_debug=1
> grub> insmod ofnet
> grub>
>
> During initialization, ofnet calls grub_malloc(), so I expect some debug
> messages to be printed on 'insmod ofnet'.
>
> Am I missing something, or is it a bug?
>

Either patch grub to assign grub_mm_debug=1 in grub-core/kern/mm.c or
create simple command to do it at run-time. The latter may be
considered for inclusion, although honestly I am not sure how
particular useful mm debugging is.


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

* Re: How to enable MM debugging?
  2016-11-29 14:17 ` Andrei Borzenkov
@ 2016-11-29 14:38   ` Stanislav Kholmanskikh
  2016-11-29 17:11     ` Andrei Borzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Kholmanskikh @ 2016-11-29 14:38 UTC (permalink / raw)
  To: The development of GNU GRUB



On 11/29/2016 05:17 PM, Andrei Borzenkov wrote:
> On Tue, Nov 29, 2016 at 4:52 PM, Stanislav Kholmanskikh
> <stanislav.kholmanskikh@oracle.com> wrote:
>> Hi!
>>
>> Does anybody use MM debugging? If so, what is the recommended/working
>> way of enabling it?
>>
>> These steps do not work:
>>
>> 1. Run ./configure with '--enable-mm-debug'. It reports:
>>
>> With memory debugging: Yes
>>
>> 2. Then build and install the binaries, and install the boot loader
>>
>> 3. Then set 'grub_mm_debug=1' in the grub's prompt.
>>
> 
> This environment variable is not used.
> 
>> grub> set grub_mm_debug=1
>> grub> insmod ofnet
>> grub>
>>
>> During initialization, ofnet calls grub_malloc(), so I expect some debug
>> messages to be printed on 'insmod ofnet'.
>>
>> Am I missing something, or is it a bug?
>>
> 
> Either patch grub to assign grub_mm_debug=1 in grub-core/kern/mm.c or
> create simple command to do it at run-time. The latter may be
> considered for inclusion, although honestly I am not sure how
> particular useful mm debugging is.

No, it doesn't help. Look:

stas@skholman-m7 grub]$ git diff grub-core/hello/hello.c
diff --git a/grub-core/hello/hello.c b/grub-core/hello/hello.c
index 456b7c3..c61bab8 100644
--- a/grub-core/hello/hello.c
+++ b/grub-core/hello/hello.c
@@ -34,6 +34,9 @@ grub_cmd_hello (grub_extcmd_context_t ctxt
__attribute__ ((unused)),
                char **args __attribute__ ((unused)))
 {
   grub_printf ("%s\n", _("Hello World"));
+
+  grub_mm_debug = 0;
+
   return 0;
 }

[stas@skholman-m7 grub]$

fails to build with:

hello/hello.c: In function ‘grub_cmd_hello’:
hello/hello.c:38: error: ‘grub_mm_debug’ undeclared (first use in this
function)
hello/hello.c:38: error: (Each undeclared identifier is reported only once
hello/hello.c:38: error: for each function it appears in.)

whereas include/grub/mm.h is included.

As for why I need this. I'm working on

http://lists.gnu.org/archive/html/grub-devel/2016-11/msg00124.html

in particular on that piece of code which is to free card memory on
module unload. And I'm considering enabling MM debugging as an
additional option to verify that I call grub_free() for all the required
buffers.




> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 


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

* Re: How to enable MM debugging?
  2016-11-29 14:38   ` Stanislav Kholmanskikh
@ 2016-11-29 17:11     ` Andrei Borzenkov
  0 siblings, 0 replies; 4+ messages in thread
From: Andrei Borzenkov @ 2016-11-29 17:11 UTC (permalink / raw)
  To: The development of GNU GRUB

29.11.2016 17:38, Stanislav Kholmanskikh пишет:
> 
> 
> On 11/29/2016 05:17 PM, Andrei Borzenkov wrote:
>> On Tue, Nov 29, 2016 at 4:52 PM, Stanislav Kholmanskikh
>> <stanislav.kholmanskikh@oracle.com> wrote:
>>> Hi!
>>>
>>> Does anybody use MM debugging? If so, what is the recommended/working
>>> way of enabling it?
>>>
>>> These steps do not work:
>>>
>>> 1. Run ./configure with '--enable-mm-debug'. It reports:
>>>
>>> With memory debugging: Yes
>>>
>>> 2. Then build and install the binaries, and install the boot loader
>>>
>>> 3. Then set 'grub_mm_debug=1' in the grub's prompt.
>>>
>>
>> This environment variable is not used.
>>
>>> grub> set grub_mm_debug=1
>>> grub> insmod ofnet
>>> grub>
>>>
>>> During initialization, ofnet calls grub_malloc(), so I expect some debug
>>> messages to be printed on 'insmod ofnet'.
>>>
>>> Am I missing something, or is it a bug?
>>>
>>
>> Either patch grub to assign grub_mm_debug=1 in grub-core/kern/mm.c or
>> create simple command to do it at run-time. The latter may be
>> considered for inclusion, although honestly I am not sure how
>> particular useful mm debugging is.
> 
> No, it doesn't help. Look:
> 
> stas@skholman-m7 grub]$ git diff grub-core/hello/hello.c
> diff --git a/grub-core/hello/hello.c b/grub-core/hello/hello.c
> index 456b7c3..c61bab8 100644
> --- a/grub-core/hello/hello.c
> +++ b/grub-core/hello/hello.c
> @@ -34,6 +34,9 @@ grub_cmd_hello (grub_extcmd_context_t ctxt
> __attribute__ ((unused)),
>                 char **args __attribute__ ((unused)))
>  {
>    grub_printf ("%s\n", _("Hello World"));
> +
> +  grub_mm_debug = 0;
> +
>    return 0;
>  }
> 
> [stas@skholman-m7 grub]$
> 
> fails to build with:
> 
> hello/hello.c: In function ‘grub_cmd_hello’:
> hello/hello.c:38: error: ‘grub_mm_debug’ undeclared (first use in this
> function)
> hello/hello.c:38: error: (Each undeclared identifier is reported only once
> hello/hello.c:38: error: for each function it appears in.)
> 
> whereas include/grub/mm.h is included.
> 

You need to guard use of grub_mm_debug using the same #ifdef as in
include/grub/mm.h or simply include your command under #ifdef MM_DEBUG
in grub-core/kern/mm.c.

> As for why I need this. I'm working on
> 
> http://lists.gnu.org/archive/html/grub-devel/2016-11/msg00124.html
> 
> in particular on that piece of code which is to free card memory on
> module unload. And I'm considering enabling MM debugging as an
> additional option to verify that I call grub_free() for all the required
> buffers.
> 



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

end of thread, other threads:[~2016-11-29 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 13:52 How to enable MM debugging? Stanislav Kholmanskikh
2016-11-29 14:17 ` Andrei Borzenkov
2016-11-29 14:38   ` Stanislav Kholmanskikh
2016-11-29 17:11     ` Andrei Borzenkov

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 NNTP newsgroup(s).