'Why did QEMU give me the (null) instead of a string?

I am learning OS recently, but I got a problem that QEMU outputs (null) instead of a string what I want when I was debugging the program.


The QEMU emulator version is 4.2.1 (Debian 1:4.2-3ubuntu6.18), and I use it in WSL(Windows Subsystem for Linux) that don't have GUI. I run the QEMU by command qemu-system-i386 -hda myprogram.img -nographic. After the commmand, what shows in QEMU interface is memory management: (null), but it should be memory management:default_pmm_manager. Then I debugged my program in QEMU for Ubuntu that has GUI and its version is 2.0.0. I really have the output memory management:default_pmm_manager . So it dues to QEMU vesion?
Here are some functions code in my program.

struct pmm_manager {
    const char *name;                                 // XXX_pmm_manager's name                      
    void (*init)(void);                               // initialize internal description&management data structure
                                                      // (free block list, number of free block) of XXX_pmm_manager 
    void (*init_memmap)(struct Page *base, size_t n); // setup description&management data structcure according to
                                                      // the initial free physical memory space 
    struct Page *(*alloc_pages)(size_t n);            // allocate >=n pages, depend on the allocation algorithm 
    void (*free_pages)(struct Page *base, size_t n);  // free >=n pages with "base" addr of Page descriptor structures(memlayout.h)
    size_t (*nr_free_pages)(void);                    // return the number of free pages 
    void (*check)(void);                              // check the correctness of XXX_pmm_manager 
};

const struct pmm_manager *pmm_manager;

const struct pmm_manager default_pmm_manager = {
    .name = "default_pmm_manager",
    .init = default_init,
    .init_memmap = default_init_memmap,
    .alloc_pages = default_alloc_pages,
    .free_pages = default_free_pages,
    .nr_free_pages = default_nr_free_pages,
    .check = default_check,
};

static void
init_pmm_manager(void) {
    pmm_manager = &default_pmm_manager;
    cprintf("memory management: %s\n", pmm_manager->name);
    pmm_manager->init();
}

I really want to have the right output in QEMU of WSL. Is there any solutions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source