You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2006/12/06 00:20:33 UTC
svn commit: r482826 - in
/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86:
./ hysignal_context.c hysignal_context.h
Author: hindessm
Date: Tue Dec 5 15:20:32 2006
New Revision: 482826
URL: http://svn.apache.org/viewvc?view=rev&rev=482826
Log:
Attempt at signal handler from FreeBSD/x86.
Added:
harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/
harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.c
harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.h
Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.c?view=auto&rev=482826
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.c Tue Dec 5 15:20:32 2006
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hyport.h"
+#include <unistd.h>
+#include <string.h>
+#include "hysignal_context.h"
+
+void
+fillInUnixSignalInfo (struct HyPortLibrary *portLibrary, void *contextInfo,
+ struct HyUnixSignalInfo *hyInfo)
+{
+ mcontext_t *mContext;
+ ucontext_t *uContext;
+
+ uContext = (ucontext_t *) contextInfo;
+ mContext = (mcontext_t *) &uContext->uc_mcontext;
+
+ hyInfo->platformSignalInfo.mContext = mContext;
+ /* module info is filled on demand */
+}
+
+
+U_32
+infoForSignal (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value)
+{
+ *name = "";
+
+ switch (index)
+ {
+
+ case HYPORT_SIG_SIGNAL_TYPE:
+ case 0:
+ *name = "HyGeneric_Signal_Number";
+ *value = &info->portLibrarySignalType;
+ return HYPORT_SIG_VALUE_32;
+
+ case HYPORT_SIG_SIGNAL_PLATFORM_SIGNAL_TYPE:
+ case 1:
+ *name = "Signal_Number";
+ *value = &info->sigInfo->si_signo;
+ return HYPORT_SIG_VALUE_32;
+
+ case HYPORT_SIG_SIGNAL_ERROR_VALUE:
+ case 2:
+ *name = "Error_Value";
+ *value = &info->sigInfo->si_errno;
+ return HYPORT_SIG_VALUE_32;
+
+ case HYPORT_SIG_SIGNAL_CODE:
+ case 3:
+ *name = "Signal_Code";
+ *value = &info->sigInfo->si_code;
+ return HYPORT_SIG_VALUE_32;
+
+ case HYPORT_SIG_SIGNAL_HANDLER:
+ case 4:
+ *name = "Handler1";
+ *value = &info->handlerAddress;
+ return HYPORT_SIG_VALUE_ADDRESS;
+
+ case 5:
+ *name = "Handler2";
+ *value = &info->handlerAddress2;
+ return HYPORT_SIG_VALUE_ADDRESS;
+
+ case HYPORT_SIG_SIGNAL_INACCESSIBLE_ADDRESS:
+ case 6:
+ /* si_code > 0 indicates that the signal was generated by the kernel */
+ if (info->sigInfo->si_code > 0)
+ {
+ if ((info->sigInfo->si_signo == SIGBUS)
+ || (info->sigInfo->si_signo == SIGSEGV))
+ {
+ *name = "InaccessibleAddress";
+ *value = &info->sigInfo->si_addr;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ }
+ }
+ return HYPORT_SIG_VALUE_UNDEFINED;
+
+ default:
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ }
+}
+
+
+U_32
+infoForFPR (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index, const char **name,
+ void **value)
+{
+ return HYPORT_SIG_VALUE_UNDEFINED;
+}
+
+
+U_32
+infoForGPR (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index, const char **name,
+ void **value)
+{
+ *name = "";
+
+ switch (index)
+ {
+ case HYPORT_SIG_GPR_X86_EDI:
+ case 0:
+ *name = "EDI";
+ *value = &info->platformSignalInfo.mContext->mc_edi;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_GPR_X86_ESI:
+ case 1:
+ *name = "ESI";
+ *value = &info->platformSignalInfo.mContext->mc_esi;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_GPR_X86_EAX:
+ case 2:
+ *name = "EAX";
+ *value = &info->platformSignalInfo.mContext->mc_eax;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_GPR_X86_EBX:
+ case 3:
+ *name = "EBX";
+ *value = &info->platformSignalInfo.mContext->mc_ebx;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_GPR_X86_ECX:
+ case 4:
+ *name = "ECX";
+ *value = &info->platformSignalInfo.mContext->mc_ecx;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_GPR_X86_EDX:
+ case 5:
+ *name = "EDX";
+ *value = &info->platformSignalInfo.mContext->mc_edx;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ default:
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ }
+
+}
+
+
+U_32
+infoForControl (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value)
+{
+ *name = "";
+ U_8 *eip;
+
+ switch (index)
+ {
+ case HYPORT_SIG_CONTROL_PC:
+ case 0:
+ *name = "EIP";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_eip);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case 1:
+ *name = "ES";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_es);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case 2:
+ *name = "DS";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_ds);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_CONTROL_SP:
+ case 3:
+ *name = "ESP";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_esp);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case 4:
+ *name = "EFlags";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_eflags);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case 5:
+ *name = "CS";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_cs);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case 6:
+ *name = "SS";
+ *value = (void *) &(info->platformSignalInfo.mContext->mc_ss);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ case HYPORT_SIG_CONTROL_BP:
+ case 7:
+ *name = "EBP";
+ *value = &info->platformSignalInfo.mContext->mc_ebp;
+ return HYPORT_SIG_VALUE_ADDRESS;
+ default:
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ }
+}
+
+
+U_32
+infoForModule (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value)
+{
+ void *address;
+ Dl_info *dl_info = &(info->platformSignalInfo.dl_info);
+ *name = "";
+
+ address = (void *) info->platformSignalInfo.mContext->mc_eip;
+ int dl_result =
+ dladdr ((void *) info->platformSignalInfo.mContext->mc_eip, dl_info);
+
+ switch (index)
+ {
+ case HYPORT_SIG_MODULE_NAME:
+ case 0:
+ *name = "Module";
+ if (dl_result)
+ {
+ *value = (void *) (dl_info->dli_fname);
+ return HYPORT_SIG_VALUE_STRING;
+ }
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ case 1:
+ *name = "Module_base_address";
+ if (dl_result)
+ {
+ *value = (void *) &(dl_info->dli_fbase);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ }
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ case 2:
+ *name = "Symbol";
+ if (dl_result)
+ {
+ if (dl_info->dli_sname != NULL)
+ {
+ *value = (void *) (dl_info->dli_sname);
+ return HYPORT_SIG_VALUE_STRING;
+ }
+ }
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ case 3:
+ *name = "Symbol_address";
+ if (dl_result)
+ {
+ *value = (void *) &(dl_info->dli_saddr);
+ return HYPORT_SIG_VALUE_ADDRESS;
+ }
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ default:
+ return HYPORT_SIG_VALUE_UNDEFINED;
+ }
+}
Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.h?view=auto&rev=482826
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.h (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/freebsd.x86/hysignal_context.h Tue Dec 5 15:20:32 2006
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hyport.h"
+#include <sys/ucontext.h>
+
+#define MAX_UNIX_SIGNAL_TYPES NSIG
+
+#define __USE_GNU
+#include <dlfcn.h>
+#undef __USE_GNU
+
+typedef struct HyPlatformSignalInfo
+{
+ mcontext_t *mContext;
+ Dl_info dl_info;
+} HyPlatformSignalInfo;
+
+typedef struct HyUnixSignalInfo
+{
+ U_32 portLibrarySignalType;
+ void *handlerAddress;
+ void *handlerAddress2;
+ siginfo_t *sigInfo;
+ struct HyPlatformSignalInfo platformSignalInfo;
+} HyUnixSignalInfo;
+
+U_32 infoForFPR (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value);
+
+U_32 infoForGPR (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value);
+
+U_32 infoForModule (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value);
+
+U_32 infoForControl (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value);
+
+U_32 infoForSignal (struct HyPortLibrary *portLibrary,
+ struct HyUnixSignalInfo *info, I_32 index,
+ const char **name, void **value);
+
+void fillInUnixSignalInfo (struct HyPortLibrary *portLibrary,
+ void *contextInfo,
+ struct HyUnixSignalInfo *hyInfo);