Release 950122
[wine] / debugger / dtest.c
1 #include <signal.h>
2 #include <stdio.h>
3
4 extern void wine_debug(unsigned int*);
5
6
7 #ifdef linux
8 #include <linux/sched.h>
9 #include <asm/system.h>
10 #endif
11
12 struct sigaction segv_act;
13
14 #ifdef linux
15
16 struct sigcontext_struct {
17         unsigned short sc_gs, __gsh;
18         unsigned short sc_fs, __fsh;
19         unsigned short sc_es, __esh;
20         unsigned short sc_ds, __dsh;
21         unsigned long sc_edi;
22         unsigned long sc_esi;
23         unsigned long sc_ebp;
24         unsigned long sc_esp;
25         unsigned long sc_ebx;
26         unsigned long sc_edx;
27         unsigned long sc_ecx;
28         unsigned long sc_eax;
29         unsigned long sc_trapno;
30         unsigned long sc_err;
31         unsigned long sc_eip;
32         unsigned short sc_cs, __csh;
33         unsigned long sc_eflags;
34         unsigned long esp_at_signal;
35         unsigned short sc_ss, __ssh;
36         unsigned long i387;
37         unsigned long oldmask;
38         unsigned long cr2;
39 };
40 #endif
41
42 #ifdef linux
43 static void win_fault(int signal, struct sigcontext_struct context){
44         struct sigcontext_struct *scp = &context;
45 #else
46 static void win_fault(int signal, int code, struct sigcontext *scp){
47 #endif
48
49         wine_debug((unsigned int *) scp);  /* Enter our debugger */
50 }
51
52 char realtext[] = "This is what should really be printed\n";
53
54 int 
55 main(){
56         char * pnt;
57 #ifdef linux
58         segv_act.sa_handler = (__sighandler_t) win_fault;
59         sigaction(SIGSEGV, &segv_act, NULL);
60 #endif
61 #if defined(__NetBSD__) || defined(__FreeBSD__)
62         sigset_t sig_mask;
63         
64         sigemptyset(&sig_mask);
65         segv_act.sa_handler = (__sighandler_t) win_fault;
66         segv_act.sa_flags = 0;
67         segv_act.sa_mask = sig_mask;
68         if (sigaction(SIGSEGV, &segv_act, NULL) < 0) {
69                 perror("sigaction");
70                 exit(1);
71         }
72 #endif
73
74         fprintf(stderr,"%x\n", realtext);
75
76         /* Now force a segmentation fault */
77         pnt = (char *) 0xc0000000;
78
79         fprintf(stderr,"%s", pnt);
80         return 0;
81
82 }
83
84
85 unsigned int * wine_files = NULL;
86
87 GetEntryPointFromOrdinal(int wpnt, int ordinal) {}