[PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c

Warner Losh posted 49 patches 4 years, 4 months ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>
There is a newer version of this series
[PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c
Posted by Warner Losh 4 years, 4 months ago
From: Warner Losh <imp@FreeBSD.org>

Update the debugging code for new features and different targets.

Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com>
Signed-off-by: Sean Bruno <sbruno@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/mmap.c | 49 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index 03119b1f20..99563d61aa 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -68,8 +68,8 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)
     int prot1, ret;
 
 #ifdef DEBUG_MMAP
-    printf("mprotect: start=0x" TARGET_FMT_lx
-           " len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
+    printf("mprotect: start=0x" TARGET_ABI_FMT_lx
+           "len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c\n", start, len,
            prot & PROT_READ ? 'r' : '-',
            prot & PROT_WRITE ? 'w' : '-',
            prot & PROT_EXEC ? 'x' : '-');
@@ -250,28 +250,37 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     mmap_lock();
 #ifdef DEBUG_MMAP
     {
-        printf("mmap: start=0x" TARGET_FMT_lx
-               " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
+        printf("mmap: start=0x" TARGET_ABI_FMT_lx
+               " len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c flags=",
                start, len,
                prot & PROT_READ ? 'r' : '-',
                prot & PROT_WRITE ? 'w' : '-',
                prot & PROT_EXEC ? 'x' : '-');
+        if (flags & MAP_ALIGNMENT_MASK)
+            printf ("MAP_ALIGNED(%u) ", (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT);
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200035
+        if (flags & MAP_GUARD)
+            printf("MAP_GUARD ");
+#endif
         if (flags & MAP_FIXED)
             printf("MAP_FIXED ");
-        if (flags & MAP_ANON)
+        if (flags & MAP_ANONYMOUS)
             printf("MAP_ANON ");
-        switch (flags & TARGET_BSD_MAP_FLAGMASK) {
-        case MAP_PRIVATE:
-            printf("MAP_PRIVATE ");
-            break;
-        case MAP_SHARED:
-            printf("MAP_SHARED ");
-            break;
-        default:
-            printf("[MAP_FLAGMASK=0x%x] ", flags & TARGET_BSD_MAP_FLAGMASK);
-            break;
-        }
-        printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset);
+#ifdef MAP_EXCL
+        if (flags & MAP_EXCL)
+            printf("MAP_EXCL ");
+#endif
+	if (flags & MAP_PRIVATE)
+	    printf("MAP_PRIVATE ");
+	if (flags & MAP_SHARED)
+	    printf("MAP_SHARED ");
+	if (flags & MAP_NOCORE)
+	    printf("MAP_NOCORE ");
+#ifdef MAP_STACK
+	if (flags & MAP_STACK)
+	    printf("MAP_STACK ");
+#endif
+        printf("fd=%d offset=0x%llx\n", fd, offset);
     }
 #endif
 
@@ -399,7 +408,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     page_set_flags(start, start + len, prot | PAGE_VALID);
  the_end:
 #ifdef DEBUG_MMAP
-    printf("ret=0x" TARGET_FMT_lx "\n", start);
+    printf("ret=0x" TARGET_ABI_FMT_lx "\n", start);
     page_dump(stdout);
     printf("\n");
 #endif
@@ -416,7 +425,9 @@ int target_munmap(abi_ulong start, abi_ulong len)
     int prot, ret;
 
 #ifdef DEBUG_MMAP
-    printf("munmap: start=0x%lx len=0x%lx\n", start, len);
+    printf("munmap: start=0x" TARGET_ABI_FMT_lx " len=0x"
+           TARGET_ABI_FMT_lx "\n",
+           start, len);
 #endif
     if (start & ~TARGET_PAGE_MASK)
         return -EINVAL;
-- 
2.32.0


Re: [PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c
Posted by Richard Henderson 4 years, 4 months ago
On 8/7/21 11:42 AM, Warner Losh wrote:
> From: Warner Losh<imp@FreeBSD.org>
> 
> Update the debugging code for new features and different targets.
> 
> Signed-off-by: Mikaël Urankar<mikael.urankar@gmail.com>
> Signed-off-by: Sean Bruno<sbruno@FreeBSD.org>
> Signed-off-by: Kyle Evans<kevans@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/mmap.c | 49 ++++++++++++++++++++++++++++++-------------------
>   1 file changed, 30 insertions(+), 19 deletions(-)

Acked-by: Richard Henderson <richard.henderson@linaro.org>

For the to-do list: convert to qemu_log_mask or tracepoints.


r~

Re: [PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c
Posted by Warner Losh 4 years, 4 months ago
On Tue, Aug 10, 2021 at 10:19 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 8/7/21 11:42 AM, Warner Losh wrote:
> > From: Warner Losh<imp@FreeBSD.org>
> >
> > Update the debugging code for new features and different targets.
> >
> > Signed-off-by: Mikaël Urankar<mikael.urankar@gmail.com>
> > Signed-off-by: Sean Bruno<sbruno@FreeBSD.org>
> > Signed-off-by: Kyle Evans<kevans@FreeBSD.org>
> > Signed-off-by: Warner Losh<imp@bsdimp.com>
> > ---
> >   bsd-user/mmap.c | 49 ++++++++++++++++++++++++++++++-------------------
> >   1 file changed, 30 insertions(+), 19 deletions(-)
>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
>

Thanks


> For the to-do list: convert to qemu_log_mask or tracepoints.
>

Will do. Should I create a bsd-user/TODO file with all these in it (or
rather, should I
upstream the one I've already created)?

Warner
Re: [PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c
Posted by Richard Henderson 4 years, 4 months ago
On 8/10/21 12:34 PM, Warner Losh wrote:
>     For the to-do list: convert to qemu_log_mask or tracepoints.
> 
> 
> Will do. Should I create a bsd-user/TODO file with all these in it (or rather, should I
> upstream the one I've already created)?

Could do.  Dunno if its easier or not, but we also have a set of Issues with the "Bite 
Sized" tag for small cleanups like this.


r~