grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 17/19] [not for merge] print more debug info in mm


From: Daniel Axtens
Subject: [PATCH 17/19] [not for merge] print more debug info in mm
Date: Tue, 12 Oct 2021 18:30:06 +1100

This is handy for debugging - I'm including it in case anyone else hacking
on this area finds it helpful.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 grub-core/kern/mm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
index 58d5b89e8860..811df1ab5ebb 100644
--- a/grub-core/kern/mm.c
+++ b/grub-core/kern/mm.c
@@ -135,6 +135,9 @@ grub_mm_init_region (void *addr, grub_size_t size)
   for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p)
     {
       /* Does this region come _before_ an existing region? */
+      grub_printf ("Extending w/ before %p + %" PRIxGRUB_SIZE " + %" 
PRIxGRUB_SIZE " = %p ? %s\n",
+                (grub_uint8_t *)addr, size, q->pre_size, (grub_uint8_t *)q,
+                (grub_uint8_t *)addr + size + q->pre_size == (grub_uint8_t *) 
q ? "yes" : "no");
       if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q)
        {
          r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
@@ -143,6 +146,7 @@ grub_mm_init_region (void *addr, grub_size_t size)
 
          if (r->pre_size >> GRUB_MM_ALIGN_LOG2)
            {
+             grub_printf ("extending a region\n");
              h = (grub_mm_header_t) (r + 1);
              h->size = (r->pre_size >> GRUB_MM_ALIGN_LOG2);
              h->magic = GRUB_MM_ALLOC_MAGIC;
@@ -156,9 +160,13 @@ grub_mm_init_region (void *addr, grub_size_t size)
        }
 
       /* Does this region come _after_ an existing region? */
+      grub_printf ("Extending w/ after %p + %" PRIxGRUB_SIZE " + %" 
PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " = %p ? %s\n",
+                (grub_uint8_t *)q, sizeof(*q), q->size, q->post_size, 
(grub_uint8_t *)addr,
+                (grub_uint8_t *)q + sizeof(*q) + q->size + q->post_size == 
(grub_uint8_t *) addr ? "yes" : "no");
       if ((grub_uint8_t *)q + sizeof(*q) + q->size + q->post_size ==
          (grub_uint8_t *) addr)
        {
+         grub_printf ("extending a region\n");
          h = (grub_mm_header_t) ((grub_uint8_t *)addr - q->post_size);
          h->size = (size + q->post_size) >> GRUB_MM_ALIGN_LOG2;
          h->magic = GRUB_MM_ALLOC_MAGIC;
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]