Skip to contentSkip to conversation

Qemu user-mode MacOS

Qemu-devel Toni 2 participants 2 messages Aug 21, 2009 – Aug 22, 2009

lore
Share & tools
lore

Toni

author
#0 lore raw

Hi,I have a problem: I'm trying to install on Mac OS qemu user-mode, I need it, and so I find out that the only way is correct the wrong part of the source code of qemu darwin_user, I correct some errors, but now I found out something that I don't undestand:

CC i386-darwin-user/cpu-exec.o
/Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c: In function ‘cpu_x86_signal_handler’:
/Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1182: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1183: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1186: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1187: error: dereferencing pointer to incomplete type
make[1]: *** [cpu-exec.o] Error 1
make: *** [subdir-i386-darwin-user] Error 2

that is this part of code:

#1154# include <sys/ucontext.h>

#1168int cpu_signal_handler(int host_signum, void *pinfo,

#1169 void *puc)

#1170{

#1171 siginfo_t *info = pinfo;

#1172 struct ucontext *uc = puc;

#1173 unsigned long pc;

#1174 int trapno;

#1175

#1176#ifndef REG_EIP

#1177/* for glibc 2.1 */

#1178#define REG_EIP EIP

#1179#define REG_ERR ERR

#1180#define REG_TRAPNO TRAPNO

#1181#endif

#1182 pc = EIP_sig(uc);

#1183 trapno = TRAP_sig(uc);

#1184 return handle_cpu_signal(pc, (unsigned long)info->si_addr,

#1185 trapno == 0xe ?

#1186 (ERROR_sig(uc) >> 1) & 1 : 0,

#1187 &uc->uc_sigmask, puc);

the problem may be the ucontext definition of the uc variable, that is defined in sys/ucontext.h, that call _structs.h where finally we found the struct:

#ifdef __need_struct_ucontext

#undef __need_struct_ucontext

#ifndef _STRUCT_UCONTEXT

#if __DARWIN_UNIX03

#define _STRUCT_UCONTEXT struct __darwin_ucontext

#else /* !__DARWIN_UNIX03 */

#define _STRUCT_UCONTEXT struct ucontext

#endif /* __DARWIN_UNIX03 */

_STRUCT_UCONTEXT

{

int uc_onstack;

__darwin_sigset_t uc_sigmask; /* signal mask used by this
context */

_STRUCT_SIGALTSTACK uc_stack; /* stack used by this
context */

_STRUCT_UCONTEXT *uc_link; /* pointer to resuming
context */

__darwin_size_t uc_mcsize; /* size of the machine
context passed in */

_STRUCT_MCONTEXT *uc_mcontext; /* pointer to machine
specific context */

#ifdef _XOPEN_SOURCE

        _STRUCT_MCONTEXT        __mcontext_data;

#endif /* _XOPEN_SOURCE */

};

#endif /* _STRUCT_UCONTEXT */

#endif /* __need_struct_ucontext */

here I found _STRUCT_SIGALTSTACK that gave me the same error in another part, in that case I resolved the error simply with the declaration of the struct inside the code... but I think that is better now to understand why it gives error.

The _STRUCT_SIGALTSTACK is also declared inside _structs.h:

#ifdef __need_struct_sigaltstack

#undef __need_struct_sigaltstack

/* Structure used in sigaltstack call. */

#ifndef _STRUCT_SIGALTSTACK

#if __DARWIN_UNIX03

#define _STRUCT_SIGALTSTACK struct __darwin_sigaltstack

#else /* !__DARWIN_UNIX03 */

#define _STRUCT_SIGALTSTACK struct sigaltstack

#endif /* __DARWIN_UNIX03 */

_STRUCT_SIGALTSTACK

{

void *ss_sp; /* signal stack base */

__darwin_size_t ss_size; /* signal stack length */

int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */

};

#endif /* _STRUCT_SIGALTSTACK */

#endif /* __need_struct_sigaltstack */

#1 lore raw
Quoted 17 lines · Toni

Hi,
I have a problem: I'm trying to install on Mac OS qemu user-mode, I need it, and so I find out that the only way is correct the wrong part of the source code of qemu darwin_user, I correct some errors, but now I found out something that I don't undestand:
  CC    i386-darwin-user/cpu-exec.o /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c: In function ‘cpu_x86_signal_handler’:
/Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1182: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1183: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1186: error: dereferencing pointer to incomplete type /Users/ToNy/Desktop/qemu-0.10.5_prova/cpu-exec.c:1187: error: dereferencing pointer to incomplete type

Quoted 3 lines

the problem may be the ucontext definition of the uc variable, that is defined in sys/ucontext.h, that call _structs.h where finally we found the struct:

Maybe struct mcontext is not defined? You could try splitting the code to pieces, each trying one step in the pointer reference chain:

Instead of

# define EIP_sig(context)  (*((unsigned long*)&(context)->uc_mcontext->ss.eip))
you could try something like
struct mcontext *mc;
struct sigaltstack *ss;

mc = uc->uc_mcontext;
ss = mc->ss;
pc = ss->eip;