Skip to contentSkip to conversation

dump: Make most of it target agnostic (build once)

PATCH Superseded Philippe Mathieu-Daudé 3 participants 22 messages Feb 23, 2023 – Feb 24, 2023 Arm/Amlogic Meson SoC support

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover dump: Make most of it target agnostic (build once)

Thanks to Richard help, we can now build dump.o once for all targets, keeping win_dump.o for x86* targets.

Philippe Mathieu-Daudé (7):
dump: Replace tswapN() -> cpu_to_dumpN()
dump: Replace TARGET_PAGE_SIZE -> qemu_target_page_size()
dump: Correct headers included
dump: Introduce win_dump_available()
dump: Introduce create_win_dump()
dump: Build once by adding stubs for non-x86 targets
dump: Rename x86-specific file as win_dump_x86.c

 dump/dump.c                         | 29 +++++++++++------------------
 dump/meson.build                    |  6 ++++--
 dump/win_dump-stub.c                | 23 +++++++++++++++++++++++
 dump/{win_dump.c => win_dump-x86.c} |  8 +++++++-
 dump/win_dump.h                     |  5 ++++-
 5 files changed, 49 insertions(+), 22 deletions(-)
 create mode 100644 dump/win_dump-stub.c
 rename dump/{win_dump.c => win_dump-x86.c} (99%)
Signature · 1 line
2.38.1
#1 lore raw

PATCH v4 1/7 dump: Replace tswapN() -> cpu_to_dumpN()

All uses of tswap in that file are wrong, and should be using cpu_to_dumpN, which correctly tests the endianness of the output.

---
 dump/dump.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
dump/dump.c +4 -4
index 279b07f09b..7101169ecb 100644
@@ -907,13 +907,13 @@ static void get_note_sizes(DumpState *s, const void *note,
     if (dump_is_64bit(s)) {
         const Elf64_Nhdr *hdr = note;
         note_head_sz = sizeof(Elf64_Nhdr);
-        name_sz = tswap64(hdr->n_namesz);
-        desc_sz = tswap64(hdr->n_descsz);
+        name_sz = cpu_to_dump64(s, hdr->n_namesz);
+        desc_sz = cpu_to_dump64(s, hdr->n_descsz);
     } else {
         const Elf32_Nhdr *hdr = note;
         note_head_sz = sizeof(Elf32_Nhdr);
-        name_sz = tswap32(hdr->n_namesz);
-        desc_sz = tswap32(hdr->n_descsz);
+        name_sz = cpu_to_dump32(s, hdr->n_namesz);
+        desc_sz = cpu_to_dump32(s, hdr->n_descsz);
     }
 
     if (note_head_size) {
Signature · 1 line
2.38.1
Reviewed-by on v4 1/7
#2 lore raw

Re: [PATCH v4 1/7] dump: Replace tswapN() -> cpu_to_dumpN()

Quoted 8 lines · Philippe Mathieu-Daudé

All uses of tswap in that file are wrong, and should be using cpu_to_dumpN, which correctly tests the endianness of the output.

---
  dump/dump.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

r~

Reviewed-by on v4 1/7
#3 lore raw

Re: [PATCH v4 1/7] dump: Replace tswapN() -> cpu_to_dumpN()

In reply to Philippe Mathieu-Daudé
Quoted 19 lines · Philippe Mathieu-Daudé

All uses of tswap in that file are wrong, and should be using cpu_to_dumpN, which correctly tests the endianness of the output.

---
  dump/dump.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
dump/dump.c +0 -2
index 279b07f09b..7101169ecb 100644
@@ -907,13 +907,13 @@ static void get_note_sizes(DumpState *s, const void *note,
      if (dump_is_64bit(s)) {
          const Elf64_Nhdr *hdr = note;
          note_head_sz = sizeof(Elf64_Nhdr);
-        name_sz = tswap64(hdr->n_namesz);
-        desc_sz = tswap64(hdr->n_descsz);

dump/dump.c static void get_note_sizes(DumpState *s, const void *note, · line 917

Quoted 10 lines
dump/dump.c +4 -2
+        name_sz = cpu_to_dump64(s, hdr->n_namesz);
+        desc_sz = cpu_to_dump64(s, hdr->n_descsz);
      } else {
          const Elf32_Nhdr *hdr = note;
          note_head_sz = sizeof(Elf32_Nhdr);
-        name_sz = tswap32(hdr->n_namesz);
-        desc_sz = tswap32(hdr->n_descsz);
+        name_sz = cpu_to_dump32(s, hdr->n_namesz);
+        desc_sz = cpu_to_dump32(s, hdr->n_descsz);
      }

Those tswaps looked suspiciuous indeed.

#4 lore raw

PATCH v4 2/7 dump: Replace TARGET_PAGE_SIZE -> qemu_target_page_size()

In reply to Philippe Mathieu-Daudé

TARGET_PAGE_SIZE is target specific. In preparation of making dump.c target-agnostic, replace the compile-time TARGET_PAGE_SIZE definition by runtime qemu_target_page_size().

---
 dump/dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dump/dump.c +2 -1
index 7101169ecb..3784a9054d 100644
@@ -15,6 +15,7 @@
 #include "qemu/cutils.h"
 #include "elf.h"
 #include "exec/hwaddr.h"
+#include "exec/target_page.h"
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
@@ -1859,7 +1860,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
     }
 
     if (!s->dump_info.page_size) {
-        s->dump_info.page_size = TARGET_PAGE_SIZE;
+        s->dump_info.page_size = qemu_target_page_size();
     }
 
     s->note_size = cpu_get_note_size(s->dump_info.d_class,
Signature · 1 line
2.38.1
Reviewed-by on v4 2/7
#5 lore raw

Re: [PATCH v4 2/7] dump: Replace TARGET_PAGE_SIZE -> qemu_target_page_size()

Quoted 8 lines · Philippe Mathieu-Daudé

TARGET_PAGE_SIZE is target specific. In preparation of making dump.c target-agnostic, replace the compile-time TARGET_PAGE_SIZE definition by runtime qemu_target_page_size().

---
  dump/dump.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

r~

Reviewed-by on v4 2/7
#6 lore raw

Re: [PATCH v4 2/7] dump: Replace TARGET_PAGE_SIZE -> qemu_target_page_size()

In reply to Philippe Mathieu-Daudé
Quoted 22 lines · Philippe Mathieu-Daudé

TARGET_PAGE_SIZE is target specific. In preparation of making dump.c target-agnostic, replace the compile-time TARGET_PAGE_SIZE definition by runtime qemu_target_page_size().

---
  dump/dump.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
dump/dump.c +1 -0
index 7101169ecb..3784a9054d 100644
@@ -15,6 +15,7 @@
  #include "qemu/cutils.h"
  #include "elf.h"
  #include "exec/hwaddr.h"
+#include "exec/target_page.h"
  #include "monitor/monitor.h"
  #include "sysemu/kvm.h"
  #include "sysemu/dump.h"

dump/dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1866

Quoted 8 lines
dump/dump.c +1 -1
@@ -1859,7 +1860,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
      }
 
      if (!s->dump_info.page_size) {
-        s->dump_info.page_size = TARGET_PAGE_SIZE;
+        s->dump_info.page_size = qemu_target_page_size();
      }
 
      s->note_size = cpu_get_note_size(s->dump_info.d_class,
#7 lore raw

PATCH v4 3/7 dump: Correct headers included

In reply to Philippe Mathieu-Daudé

"qemu/win_dump_defs.h" is only required by win_dump.c, but win_dump.h requires "sysemu/dump.h" which declares the DumpState type.

---
 dump/win_dump.c | 1 +
 dump/win_dump.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
dump/win_dump.c +1 -0
index f20b6051b6..12b7da5da0 100644
@@ -21,6 +21,7 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "hw/misc/vmcoreinfo.h"
+#include "qemu/win_dump_defs.h"
 #include "win_dump.h"
 
 static size_t win_dump_ptr_size(bool x64)
dump/win_dump.h +1 -1
index b8c25348f4..56f63683c3 100644
@@ -11,7 +11,7 @@
 #ifndef WIN_DUMP_H
 #define WIN_DUMP_H
 
-#include "qemu/win_dump_defs.h"
+#include "sysemu/dump.h"
 
 void create_win_dump(DumpState *s, Error **errp);
 
Signature · 1 line
2.38.1
Reviewed-by on v4 3/7
#8 lore raw

Re: [PATCH v4 3/7] dump: Correct headers included

Quoted 9 lines · Philippe Mathieu-Daudé

"qemu/win_dump_defs.h" is only required by win_dump.c, but win_dump.h requires "sysemu/dump.h" which declares the DumpState type.

---
  dump/win_dump.c | 1 +
  dump/win_dump.h | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)

r~

Reviewed-by on v4 3/7
#9 lore raw

Re: [PATCH v4 3/7] dump: Correct headers included

In reply to Philippe Mathieu-Daudé
Quoted 27 lines · Philippe Mathieu-Daudé

"qemu/win_dump_defs.h" is only required by win_dump.c, but win_dump.h requires "sysemu/dump.h" which declares the DumpState type.

---
  dump/win_dump.c | 1 +
  dump/win_dump.h | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)
dump/win_dump.c +1 -0
index f20b6051b6..12b7da5da0 100644
@@ -21,6 +21,7 @@
  #include "qapi/qmp/qerror.h"
  #include "qemu/error-report.h"
  #include "hw/misc/vmcoreinfo.h"
+#include "qemu/win_dump_defs.h"
  #include "win_dump.h"
 
  static size_t win_dump_ptr_size(bool x64)
dump/win_dump.h +0 -0
index b8c25348f4..56f63683c3 100644

dump/win_dump.h line 17

Quoted 8 lines
dump/win_dump.h +1 -1
@@ -11,7 +11,7 @@
  #ifndef WIN_DUMP_H
  #define WIN_DUMP_H
 
-#include "qemu/win_dump_defs.h"
+#include "sysemu/dump.h"
 
  void create_win_dump(DumpState *s, Error **errp);
 
#10 lore raw

PATCH v4 4/7 dump: Introduce win_dump_available()

In reply to Philippe Mathieu-Daudé

Remove a pair of TARGET_X86_64 #ifdef'ry by introducing the win_dump_available() method. We'll soon extract it to a stub file for non-x86 targets.

---
 dump/dump.c     | 23 +++++++++++++----------
 dump/win_dump.c |  5 +++++
 dump/win_dump.h |  3 +++
 3 files changed, 21 insertions(+), 10 deletions(-)
dump/dump.c +13 -10
index 3784a9054d..c356a88be1 100644
@@ -30,9 +30,15 @@
 #include "qemu/main-loop.h"
 #include "hw/misc/vmcoreinfo.h"
 #include "migration/blocker.h"
-
-#ifdef TARGET_X86_64
 #include "win_dump.h"
+
+#ifndef TARGET_X86_64
+bool win_dump_available(Error **errp)
+{
+    error_setg(errp, "Windows dump is only available for x86-64");
+
+    return false;
+}
 #endif
 
 #include <zlib.h>
@@ -2130,12 +2136,10 @@ void qmp_dump_guest_memory(bool paging, const char *file,
     }
 #endif
 
-#ifndef TARGET_X86_64
-    if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) {
-        error_setg(errp, "Windows dump is only available for x86-64");
+    if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP
+            && !win_dump_available(errp)) {
         return;
     }
-#endif
 
 #if !defined(WIN32)
     if (strstart(file, "fd:", &p)) {
@@ -2217,10 +2221,9 @@ DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
     QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY);
 #endif
 
-    /* Windows dump is available only if target is x86_64 */
-#ifdef TARGET_X86_64
-    QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_WIN_DMP);
-#endif
+    if (win_dump_available(NULL)) {
+        QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_WIN_DMP);
+    }
 
     return cap;
 }
dump/win_dump.c +5 -0
index 12b7da5da0..ffeef4b738 100644
@@ -24,6 +24,11 @@
 #include "qemu/win_dump_defs.h"
 #include "win_dump.h"
 
+bool win_dump_available(Error **errp)
+{
+    return true;
+}
+
 static size_t win_dump_ptr_size(bool x64)
 {
     return x64 ? sizeof(uint64_t) : sizeof(uint32_t);
dump/win_dump.h +3 -0
index 56f63683c3..9abce289ac 100644
@@ -13,6 +13,9 @@
 
 #include "sysemu/dump.h"
 
+/* Windows dump is available only if target is x86_64 */
+bool win_dump_available(Error **errp);
+
 void create_win_dump(DumpState *s, Error **errp);
 
 #endif /* WIN_DUMP_H */
Signature · 1 line
2.38.1
Reviewed-by on v4 4/7
#11 lore raw

Re: [PATCH v4 4/7] dump: Introduce win_dump_available()

dump/dump.c void qmp_dump_guest_memory(bool paging, const char *file, · line 2140

Quoted 9 lines · Philippe Mathieu-Daudé
dump/dump.c +2 -3
@@ -2130,12 +2136,10 @@ void qmp_dump_guest_memory(bool paging, const char *file,
      }
  #endif
 
-#ifndef TARGET_X86_64
-    if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) {
-        error_setg(errp, "Windows dump is only available for x86-64");
+    if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP
+            && !win_dump_available(errp)) {

Indentation is off.

Otherwise looks plausible as an intermediate step before more targets.

r~

Reviewed-by on v4 4/7
#12 lore raw

Re: [PATCH v4 4/7] dump: Introduce win_dump_available()

In reply to Philippe Mathieu-Daudé
Quoted 21 lines · Philippe Mathieu-Daudé

Remove a pair of TARGET_X86_64 #ifdef'ry by introducing the win_dump_available() method. We'll soon extract it to a stub file for non-x86 targets.

---
  dump/dump.c     | 23 +++++++++++++----------
  dump/win_dump.c |  5 +++++
  dump/win_dump.h |  3 +++
  3 files changed, 21 insertions(+), 10 deletions(-)
dump/dump.c +0 -2
index 3784a9054d..c356a88be1 100644
@@ -30,9 +30,15 @@
  #include "qemu/main-loop.h"
  #include "hw/misc/vmcoreinfo.h"
  #include "migration/blocker.h"
-
-#ifdef TARGET_X86_64

dump/dump.c line 42

Quoted 10 lines
dump/dump.c +8 -0
  #include "win_dump.h"
+
+#ifndef TARGET_X86_64
+bool win_dump_available(Error **errp)
+{
+    error_setg(errp, "Windows dump is only available for x86-64");
+
+    return false;
+}
  #endif

I think I'd prefer to introduce the stub file immediately here already, but it's just a matter of taste.

So with the indentation fixed (that Richard mentioned):

#13 lore raw

PATCH v4 5/7 dump: Introduce create_win_dump()

In reply to Philippe Mathieu-Daudé

Remove another TARGET_X86_64 #ifdef'ry by introducing a create_win_dump() stub. We'll extract it to a stub file for non-x86 targets in the next commit.

---
 dump/dump.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
dump/dump.c +5 -2
index c356a88be1..b33a613d45 100644
@@ -39,6 +39,11 @@ bool win_dump_available(Error **errp)
 
     return false;
 }
+
+void create_win_dump(DumpState *s, Error **errp)
+{
+    win_dump_available(errp);
+}
 #endif
 
 #include <zlib.h>
@@ -2031,9 +2036,7 @@ static void dump_process(DumpState *s, Error **errp)
     DumpQueryResult *result = NULL;
 
     if (s->has_format && s->format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) {
-#ifdef TARGET_X86_64
         create_win_dump(s, errp);
-#endif
     } else if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
         create_kdump_vmcore(s, errp);
     } else {
Signature · 1 line
2.38.1
Reviewed-by on v4 5/7
#14 lore raw

Re: [PATCH v4 5/7] dump: Introduce create_win_dump()

Quoted 8 lines · Philippe Mathieu-Daudé

Remove another TARGET_X86_64 #ifdef'ry by introducing a create_win_dump() stub. We'll extract it to a stub file for non-x86 targets in the next commit.

---
  dump/dump.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

r~

Reviewed-by on v4 5/7
#15 lore raw

Re: [PATCH v4 5/7] dump: Introduce create_win_dump()

In reply to Philippe Mathieu-Daudé
Quoted 26 lines · Philippe Mathieu-Daudé

Remove another TARGET_X86_64 #ifdef'ry by introducing a create_win_dump() stub. We'll extract it to a stub file for non-x86 targets in the next commit.

---
  dump/dump.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
dump/dump.c +5 -0
index c356a88be1..b33a613d45 100644
@@ -39,6 +39,11 @@ bool win_dump_available(Error **errp)
 
      return false;
  }
+
+void create_win_dump(DumpState *s, Error **errp)
+{
+    win_dump_available(errp);
+}
  #endif
 
  #include <zlib.h>

dump/dump.c static void dump_process(DumpState *s, Error **errp) · line 2042

Quoted 9 lines
dump/dump.c +0 -2
@@ -2031,9 +2036,7 @@ static void dump_process(DumpState *s, Error **errp)
      DumpQueryResult *result = NULL;
 
      if (s->has_format && s->format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) {
-#ifdef TARGET_X86_64
          create_win_dump(s, errp);
-#endif
      } else if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
          create_kdump_vmcore(s, errp);
      } else {
#16 lore raw

PATCH v4 6/7 dump: Build once by adding stubs for non-x86 targets

In reply to Philippe Mathieu-Daudé

Extract non-x86 stubs to win_dump-stub.c. We can now build dump.o once for system emulation. Update meson.

---
 dump/dump.c          | 14 --------------
 dump/meson.build     |  6 ++++--
 dump/win_dump-stub.c | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+), 16 deletions(-)
 create mode 100644 dump/win_dump-stub.c
dump/dump.c +0 -14
index b33a613d45..7cde3e326e 100644
@@ -32,20 +32,6 @@
 #include "migration/blocker.h"
 #include "win_dump.h"
 
-#ifndef TARGET_X86_64
-bool win_dump_available(Error **errp)
-{
-    error_setg(errp, "Windows dump is only available for x86-64");
-
-    return false;
-}
-
-void create_win_dump(DumpState *s, Error **errp)
-{
-    win_dump_available(errp);
-}
-#endif
-
 #include <zlib.h>
 #ifdef CONFIG_LZO
 #include <lzo/lzo1x.h>
dump/meson.build +4 -2
index 2eff29c3ea..6ae07e6fed 100644
@@ -1,4 +1,6 @@
 softmmu_ss.add(files('dump-hmp-cmds.c'))
 
-specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
-specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'], if_true: files('win_dump.c'))
+softmmu_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
+specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'],
+                if_true: files('win_dump.c'),
+                if_false: files('win_dump-stub.c'))
dump/win_dump-stub.c new file +23 -0
new file mode 100644
index 0000000000..87cb699e3d
@@ -0,0 +1,23 @@
+/*
+ * Windows crashdump stubs for non-x86 targets
+ *
+ * Copyright (c) 2023 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "win_dump.h"
+
+bool win_dump_available(Error **errp)
+{
+    error_setg(errp, "Windows dump is only available for x86-64");
+
+    return false;
+}
+
+void create_win_dump(DumpState *s, Error **errp)
+{
+    win_dump_available(errp);
+}
Signature · 1 line
2.38.1
#17 lore raw

Re: [PATCH v4 6/7] dump: Build once by adding stubs for non-x86 targets

Quoted 41 lines · Philippe Mathieu-Daudé

Extract non-x86 stubs to win_dump-stub.c. We can now build dump.o once for system emulation. Update meson.

---
  dump/dump.c          | 14 --------------
  dump/meson.build     |  6 ++++--
  dump/win_dump-stub.c | 23 +++++++++++++++++++++++
  3 files changed, 27 insertions(+), 16 deletions(-)

create mode 100644 dump/win_dump-stub.c

dump/dump.c +0 -14
index b33a613d45..7cde3e326e 100644
@@ -32,20 +32,6 @@
  #include "migration/blocker.h"
  #include "win_dump.h"
 
-#ifndef TARGET_X86_64
-bool win_dump_available(Error **errp)
-{
-    error_setg(errp, "Windows dump is only available for x86-64");
-
-    return false;
-}
-
-void create_win_dump(DumpState *s, Error **errp)
-{
-    win_dump_available(errp);
-}
-#endif
-
  #include <zlib.h>
  #ifdef CONFIG_LZO
  #include <lzo/lzo1x.h>
dump/meson.build +0 -0
index 2eff29c3ea..6ae07e6fed 100644

dump/meson.build line 6

Quoted 8 lines
dump/meson.build +4 -2
@@ -1,4 +1,6 @@
  softmmu_ss.add(files('dump-hmp-cmds.c'))
 
-specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
-specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'], if_true: files('win_dump.c'))
+softmmu_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
+specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'],
+                if_true: files('win_dump.c'),
+                if_false: files('win_dump-stub.c'))

Doesn't this add win_dump-stub.c when !(SOFTMMU && X86_64), i.e. !SOFTMMU || !X86_64?

I trying to imagine how well this will scale with ARM64, for the ongoing Windows on ARM project. Would it just be easier have the stubs in win_dump.c, using ifdefs?

r~

#18 lore raw

Re: [PATCH v4 6/7] dump: Build once by adding stubs for non-x86 targets

Quoted 30 lines · Richard Henderson
Quoted 20 lines · Philippe Mathieu-Daudé

Extract non-x86 stubs to win_dump-stub.c. We can now build dump.o once for system emulation. Update meson.

---
  dump/dump.c          | 14 -------------- dump/meson.build     |  6 ++++-- dump/win_dump-stub.c | 23 +++++++++++++++++++++++

  3 files changed, 27 insertions(+), 16 deletions(-)

  create mode 100644 dump/win_dump-stub.c

dump/meson.build +0 -2
index 2eff29c3ea..6ae07e6fed 100644
@@ -1,4 +1,6 @@
   softmmu_ss.add(files('dump-hmp-cmds.c'))
-specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), 
 snappy, lzo])
-specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'], if_true: 
Quoted 6 lines

files('win_dump.c'))
+softmmu_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
+specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'], +                if_true: files('win_dump.c'),
+                if_false: files('win_dump-stub.c'))

Doesn't this add win_dump-stub.c when !(SOFTMMU && X86_64), i.e. !SOFTMMU || !X86_64?

Quoted 1 line

I trying to imagine how well this will scale with ARM64, for the ongoing Windows on ARM project.  Would it just be easier have the stubs in win_dump.c, using ifdefs?

Yeah I realized that later, keeping one single file with #ifdef'ry even simplifies meson rules. I over-engineered that :) Also various methods from win_dump.c could be reused.

#19 lore raw

PATCH v4 7/7 dump: Rename x86-specific file as win_dump_x86.c

In reply to Philippe Mathieu-Daudé

win_dump.c is x86 specific. Rename it as such in case someone is willing to add win_dump-aarch64 :)

---
 dump/meson.build                    | 2 +-
 dump/{win_dump.c => win_dump-x86.c} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename dump/{win_dump.c => win_dump-x86.c} (99%)
dump/meson.build +1 -1
index 6ae07e6fed..d899949a73 100644
@@ -2,5 +2,5 @@ softmmu_ss.add(files('dump-hmp-cmds.c'))
 
 softmmu_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
 specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'],
-                if_true: files('win_dump.c'),
+                if_true: files('win_dump-x86.c'),
                 if_false: files('win_dump-stub.c'))
dump/win_dump-x86.c renamed from dump/win_dump.c +1 -1
similarity index 99%
rename from dump/win_dump.c
rename to dump/win_dump-x86.c
index ffeef4b738..5ee9a1d764 100644
@@ -1,5 +1,5 @@
 /*
- * Windows crashdump
+ * Windows crashdump for x86 targets
  *
  * Copyright (c) 2018 Virtuozzo International GmbH
  *
Signature · 1 line
2.38.1
#20 lore raw

Re: [PATCH v4 7/7] dump: Rename x86-specific file as win_dump_x86.c

Oops, "win_dump-x86.c" in subject...

Quoted 35 lines · Philippe Mathieu-Daudé

win_dump.c is x86 specific. Rename it as such in case someone is willing to add win_dump-aarch64 :)

---
  dump/meson.build                    | 2 +-
  dump/{win_dump.c => win_dump-x86.c} | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

rename dump/{win_dump.c => win_dump-x86.c} (99%)

dump/meson.build +1 -1
index 6ae07e6fed..d899949a73 100644
@@ -2,5 +2,5 @@ softmmu_ss.add(files('dump-hmp-cmds.c'))
 
  softmmu_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files('dump.c'), snappy, lzo])
  specific_ss.add(when: ['CONFIG_SOFTMMU', 'TARGET_X86_64'],
-                if_true: files('win_dump.c'),
+                if_true: files('win_dump-x86.c'),
                  if_false: files('win_dump-stub.c'))
dump/win_dump-x86.c renamed from dump/win_dump.c +1 -1
similarity index 99%
rename from dump/win_dump.c
rename to dump/win_dump-x86.c
index ffeef4b738..5ee9a1d764 100644
@@ -1,5 +1,5 @@
  /*
- * Windows crashdump
+ * Windows crashdump for x86 targets
   *
   * Copyright (c) 2018 Virtuozzo International GmbH
   *
#21 lore raw

Re: [PATCH v4 7/7] dump: Rename x86-specific file as win_dump_x86.c

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

win_dump.c is x86 specific. Rename it as such in case someone is willing to add win_dump-aarch64 :)

I think this is premature. I would *hope* there's a lot in here that would be shared.

r~