debug.c: In function ‘dumpX86Calls’:
debug.c:1752:5: error: unknown type name ‘Dl_info’
 1752 |     Dl_info info;
      |     ^~~~~~~
debug.c:1762:13: warning: implicit declaration of function ‘dladdr’; did you mean ‘s_addr’? [-Wimplicit-function-declaration]
 1762 |         if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
      |             ^~~~~~
      |             s_addr
debug.c:1762:54: error: request for member ‘dli_sname’ in something not a structure or union
 1762 |         if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
      |                                                      ^
debug.c:1764:63: error: request for member ‘dli_sname’ in something not a structure or union
 1764 |                 printf("Function at 0x%lx is %s\n",target,info.dli_sname);
      |                                                               ^
debug.c: In function ‘dumpCodeAroundEIP’:
debug.c:1773:5: error: unknown type name ‘Dl_info’
 1773 |     Dl_info info;
      |     ^~~~~~~
debug.c:1782:17: error: request for member ‘dli_sname’ in something not a structure or union
 1782 |             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
      |                 ^
debug.c:1782:33: error: request for member ‘dli_saddr’ in something not a structure or union
 1782 |             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
      |                                 ^
debug.c:1782:49: error: request for member ‘dli_fname’ in something not a structure or union
 1782 |             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
      |                                                 ^
debug.c:1782:65: error: request for member ‘dli_fbase’ in something not a structure or union
 1782 |             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
      |                                                                 ^
debug.c:1783:17: error: request for member ‘dli_saddr’ in something not a structure or union
 1783 |             info.dli_saddr);
      |                 ^
debug.c:1784:44: error: request for member ‘dli_saddr’ in something not a structure or union
 1784 |         size_t len = (long)eip - (long)info.dli_saddr;
      |                                            ^
debug.c:1790:38: error: request for member ‘dli_saddr’ in something not a structure or union
 1790 |             void *base = (void *)info.dli_saddr;
      |                                      ^
make[1]: *** [Makefile:364: debug.o] Error 1
make[1]: Leaving directory '/home/chan/redis-6.2.1/src'
make: *** [Makefile:6: all] Error 2

Comment From: madolson

@kongjs2021 We don't officially support windows, which is what msys2 is a build system for. It looks like some of our C defines aren't quite lining up for your system. If you would like to help build out support for it we would consider, but I don't think we will actively work on this.

Comment From: chadels

I adding struct or union variable in debug. C to speculate dl_ Info is struct dl_ Info, which is compiled successfully in msys2. The source code version is redis-6.2.1. I hope the community can support it. All the above are translations. I'm very sorry for any mistakes.

typedef struct Dl_info{
    unsigned char *dli_sname;
    unsigned char *dli_saddr;
    unsigned char *dli_fname;
    unsigned char *dli_fbase;
}info;
/* Scans the (assumed) x86 code starting at addr, for a max of `len`
 * bytes, searching for E8 (callq) opcodes, and dumping the symbols
 * and the call offset if they appear to be valid. */
void dumpX86Calls(void *addr, size_t len) {
    size_t j;
    unsigned char *p = addr;
    struct Dl_info info;
    /* Hash table to best-effort avoid printing the same symbol
     * multiple times. */
    unsigned long ht[256] = {0};

    if (len < 5) return;
    for (j = 0; j < len-4; j++) {
        if (p[j] != 0xE8) continue; /* Not an E8 CALL opcode. */
        unsigned long target = (unsigned long)addr+j+5;
        target += *((int32_t*)(p+j+1));
        if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
            if (ht[target&0xff] != target) {
                printf("Function at 0x%lx is %s\n",target,info.dli_sname);
                ht[target&0xff] = target;
            }
            j += 4; /* Skip the 32 bit immediate. */
        }
    }
}

void dumpCodeAroundEIP(void *eip) {
    struct Dl_info info;
................................

Comment From: sundb

If you really want to compile on msys2, you can comment #if __GNU_VISIBLE before struct Dl_info in /usr/include/dlfcn.h.

Comment From: X-Lucifer

Thanks. That solved my problem!!

Comment From: FFFrankkkkk

I adding struct or union variable in debug. C to speculate dl_ Info is struct dl_ Info, which is compiled successfully in msys2. The source code version is redis-6.2.1. I hope the community can support it. All the above are translations. I'm very sorry for any mistakes.

`` typedef struct Dl_info{ unsigned char *dli_sname; unsigned char *dli_saddr; unsigned char *dli_fname; unsigned char *dli_fbase; }info; /* Scans the (assumed) x86 code starting at addr, for a max oflen` * bytes, searching for E8 (callq) opcodes, and dumping the symbols * and the call offset if they appear to be valid. / void dumpX86Calls(void addr, size_t len) { size_t j; unsigned char p = addr; struct Dl_info info; / Hash table to best-effort avoid printing the same symbol * multiple times. */ unsigned long ht[256] = {0};

if (len < 5) return;
for (j = 0; j < len-4; j++) {
    if (p[j] != 0xE8) continue; /* Not an E8 CALL opcode. */
    unsigned long target = (unsigned long)addr+j+5;
    target += *((int32_t*)(p+j+1));
    if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
        if (ht[target&0xff] != target) {
            printf("Function at 0x%lx is %s\n",target,info.dli_sname);
            ht[target&0xff] = target;
        }
        j += 4; /* Skip the 32 bit immediate. */
    }
}

}

void dumpCodeAroundEIP(void *eip) { struct Dl_info info; ................................ ```

it works,thanks!