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 2007/10/28 10:30:08 UTC
svn commit: r589313 - in /harmony/enhanced/drlvm/trunk/vm:
port/src/misc/linux/sysinfo.c vmcore/src/init/vm_properties.cpp
vmcore/src/util/linux/crash_handler.cpp
Author: hindessm
Date: Sun Oct 28 02:30:07 2007
New Revision: 589313
URL: http://svn.apache.org/viewvc?rev=589313&view=rev
Log:
More executable name hacks to get FreeBSD to work. (There is another in
vm/jitrino/src/codegenerator/ipf/IpfEmitter.cpp but I don't need this
one right now.) We really should have this code in *one* place.
Modified:
harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c
harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c?rev=589313&r1=589312&r2=589313&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c Sun Oct 28 02:30:07 2007
@@ -26,17 +26,28 @@
#include <errno.h>
#include "port_sysinfo.h"
#include <apr_strings.h>
+#if defined(FREEBSD)
+#include <dlfcn.h>
+extern int main (int argc, char **argv, char **envp);
+#endif
APR_DECLARE(apr_status_t) port_executable_name(char** self_name,
apr_pool_t* pool) {
-
+#if defined(FREEBSD)
+ Dl_info info;
+ if (dladdr( (const void*)&main, &info) == 0) {
+ return APR_ENOENT;
+ }
+ char* buf = apr_pstrdup(pool, info.dli_fname);
+#else
char* buf = apr_palloc(pool, PATH_MAX + 1);
int n = readlink("/proc/self/exe", buf, PATH_MAX);
if (n == -1) {
return apr_get_os_error();
}
buf[n] = '\0';
+#endif
*self_name = buf;
return APR_SUCCESS;
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp?rev=589313&r1=589312&r2=589313&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp Sun Oct 28 02:30:07 2007
@@ -28,6 +28,9 @@
#include "vm_properties.h"
#include "init.h"
#include "native_modules.h"
+#if defined(FREEBSD)
+#include <dlfcn.h>
+#endif
inline char* unquote(char *str)
{
@@ -110,6 +113,13 @@
void **ptr = (void**)code_ptr;
code_ptr = ptr[0];
#endif
+#if defined(FREEBSD)
+ Dl_info info;
+ if (dladdr( (const void*)code_ptr, &info) == 0) {
+ return NULL;
+ }
+ return apr_pstrdup(prop_pool, info.dli_fname);
+#else
if (! get_all_native_modules(&modules, &modules_count))
return NULL;
@@ -124,6 +134,7 @@
clear_native_modules(&modules);
return filename;
+#endif
}
static void init_java_properties(Properties & properties)
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp?rev=589313&r1=589312&r2=589313&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp Sun Oct 28 02:30:07 2007
@@ -27,6 +27,10 @@
#include "environment.h"
#include "crash_handler.h"
+#if defined(FREEBSD)
+#include <dlfcn.h>
+extern int main (int argc, char **argv, char **envp);
+#endif
static char g_executable[1024]; // Executable file name
static char g_strpid[128]; // Current pid as a string
@@ -81,6 +85,15 @@
#endif
int get_executable_name(char executable[], int len) {
+#if defined(FREEBSD)
+ Dl_info info;
+ if (dladdr( (const void*)&main, &info) == 0) {
+ return -1;
+ }
+ strncpy(executable, info.dli_fname, len);
+ executable[len] = '\0';
+ return 0;
+#else
int n = readlink("/proc/self/exe", executable, len);
if (n == -1) {
perror("Can't determine executable name");
@@ -88,6 +101,7 @@
}
executable[n] = '\0';
return 0;
+#endif
}