dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / mdb / common / kmdb / kmdb_stubs.c
blob39d9ffd40cff965d19dc40d299a9c0b466032e6e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Stubs for basic system services otherwise unavailable to the debugger.
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <libproc.h>
33 #include <sys/time.h>
35 #include <kmdb/kmdb_dpi.h>
36 #include <kmdb/kmdb_promif.h>
37 #include <kmdb/kmdb_io.h>
38 #include <mdb/mdb_debug.h>
39 #include <mdb/mdb_signal.h>
40 #include <mdb/mdb_io_impl.h>
41 #include <mdb/mdb.h>
43 /*ARGSUSED*/
44 char *
45 getenv(const char *name)
47 /* There aren't any environment variables here */
48 return (NULL);
51 char *
52 strerror(int errnum)
54 static char errnostr[16];
56 (void) mdb_snprintf(errnostr, sizeof (errnostr), "Error %d", errnum);
58 return (errnostr);
61 pid_t
62 getpid(void)
64 return (1);
68 * We're trying to isolate ourselves from the rest of the world as much as
69 * possible, so we can't rely on the time in the kernel proper. For now, we
70 * just bump a counter whenever time is requested, thus guaranteeing that
71 * things with timestamps can be compared according to order of occurrance.
73 hrtime_t
74 gethrtime(void)
76 static hrtime_t kmdb_timestamp;
78 return (++kmdb_timestamp);
82 * Signal handling
85 /*ARGSUSED*/
86 int
87 sigemptyset(sigset_t *set)
89 return (0);
92 /*ARGSUSED*/
93 int
94 sigaddset(sigset_t *set, int signo)
96 return (0);
99 /*ARGSUSED*/
101 sigfillset(sigset_t *set)
103 return (0);
106 /*ARGSUSED*/
108 sigprocmask(int how, const sigset_t *set, sigset_t *oset)
110 return (0);
113 /*ARGSUSED*/
115 sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
117 return (0);
120 /*ARGSUSED*/
122 kill(pid_t pid, int sig)
124 if (sig == SIGABRT) {
125 mdb_printf("Debugger aborted\n");
126 exit(1);
129 return (0);
132 /*ARGSUSED*/
134 proc_str2flt(const char *buf, int *ptr)
136 return (-1);
139 /*ARGSUSED*/
141 proc_str2sig(const char *buf, int *ptr)
143 return (-1);
146 /*ARGSUSED*/
148 proc_str2sys(const char *buf, int *ptr)
150 return (-1);
153 /*ARGSUSED*/
154 void
155 exit(int status)
157 extern void kmdb_dpi_reboot(void) __NORETURN;
158 static int recurse = 0;
160 if (!recurse) {
162 recurse = 1;
164 mdb_iob_printf(mdb.m_out, "Press any key to reboot\n");
165 mdb_iob_flush(mdb.m_out);
166 mdb_iob_clearlines(mdb.m_out);
168 (void) kmdb_getchar();
171 kmdb_dpi_reboot();