You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/08/10 16:00:25 UTC

svn commit: r564597 - in /harmony/enhanced/drlvm/trunk: build/make/components/vm/ vm/vmcore/src/init/ vm/vmcore/src/util/linux/

Author: gshimansky
Date: Fri Aug 10 07:00:23 2007
New Revision: 564597

URL: http://svn.apache.org/viewvc?view=rev&rev=564597
Log:
Fixed regression for IPF. Because native_modules support wasn't implemented for it, it couldn't
find the vmcore module. The code appears to be not architecture dependent, so all architecture
dependent modules were merged into one.


Removed:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules_ipf.cpp
Modified:
    harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules.cpp

Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml?view=diff&rev=564597&r1=564596&r2=564597
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml Fri Aug 10 07:00:23 2007
@@ -166,17 +166,14 @@
 
                     <select arch="ia32">
                         <include name="util/linux/signals_ia32.cpp" />
-                        <include name="util/linux/native_modules_ia32.cpp" />
                     </select>
 
                     <select arch="em64t">
                         <include name="util/linux/signals_em64t.cpp" />
-                        <include name="util/linux/native_modules_em64t.cpp" />
                     </select>
 
                     <select arch="ipf">
                         <include name="util/linux/signals_ipf.cpp" />
-                        <include name="util/linux/native_modules_ipf.cpp" />
                     </select>
                 </select>
             </fileset>

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?view=diff&rev=564597&r1=564596&r2=564597
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp Fri Aug 10 07:00:23 2007
@@ -99,6 +99,12 @@
     native_module_t* modules;
     int modules_count;
 
+#ifdef _IPF_
+    // On IPF function pointer is not a pointer to a function, it is a pointer
+    // to a table with first element of it the address of the funtion
+    void **ptr = (void**)code_ptr;
+    code_ptr = ptr[0];
+#endif
     if (! get_all_native_modules(&modules, &modules_count))
         return NULL;
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules.cpp?view=diff&rev=564597&r1=564596&r2=564597
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/native_modules.cpp Fri Aug 10 07:00:23 2007
@@ -19,6 +19,11 @@
  * @version $Revision: 1.1.2.1 $
  */
 
+#include <stdio.h>
+#include <memory.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "platform_lowlevel.h"
 #include "open/types.h"
 #include "port_malloc.h"
 #include "native_modules.h"
@@ -114,3 +119,117 @@
     return module;
 }
 
+bool get_all_native_modules(native_module_t** list_ptr, int* count_ptr)
+{
+    char buf[_MAX_PATH];
+
+    if (list_ptr == NULL || count_ptr == NULL)
+        return false;
+
+    pid_t pid = getpid();
+    sprintf(buf, "/proc/%d/maps", pid);
+
+    FILE* file = fopen(buf, "rt");
+    if (!file)
+        return false;
+
+    POINTER_SIZE_INT start, end;
+    char acc_r, acc_x;
+    char filename[_MAX_PATH];
+    raw_module module; // First raw module
+    raw_module* lastseg = &module; // Address of last filled segment
+    size_t segment_count = 0;
+    int module_count = 0;
+    native_module_t** cur_next_ptr = list_ptr;
+    module.name = NULL;
+    module.next = NULL;
+    *list_ptr = NULL;
+
+    while (!feof(file) && (fgets(buf, sizeof(buf), file)))
+    {
+        int res = sscanf(buf, "%" PI_FMT "x-%" PI_FMT "x %c%*c%c%*c %*" PI_FMT "x %*02x:%*02x %*u %s",
+            &start, &end, &acc_r, &acc_x, filename);
+
+        if (res < 5)
+            continue;
+
+        if (module.name == NULL || // First module, first record
+            strcmp(module.name, filename) != 0) // Next module
+        {
+            if (segment_count) // Add previous module
+            {
+                native_module_t* filled =
+                    native_fill_module(&module, segment_count);
+
+                if (!filled)
+                {
+                    native_clear_raw_list(&module);
+                    clear_native_modules(list_ptr);
+                    fclose(file);
+                    return false;
+                }
+
+                *cur_next_ptr = filled;
+                cur_next_ptr = &filled->next;
+            }
+
+            module.name = (char*)STD_MALLOC(strlen(filename) + 1);
+            if (module.name == NULL)
+            {
+                native_clear_raw_list(&module);
+                clear_native_modules(list_ptr);
+                fclose(file);
+                return false;
+            }
+
+            strcpy(module.name, filename);
+
+            // Store new module information
+            module.start = (void*)start;
+            module.end =  (void*)end;
+            module.acc_r = (acc_r == 'r');
+            module.acc_x = (acc_x == 'x');
+            module.next = NULL;
+            ++module_count;
+
+            lastseg = &module;
+            segment_count = 1; 
+        }
+        else
+        {
+            lastseg = native_add_raw_segment(lastseg,
+                                (void*)start, (void*)end, acc_r, acc_x);
+
+            if (lastseg == NULL)
+            {
+                native_clear_raw_list(&module);
+                clear_native_modules(list_ptr);
+                fclose(file);
+                return false;
+            }
+
+            ++segment_count;
+        }
+    }
+
+    if (segment_count) // To process the last module
+    {
+        native_module_t* filled = native_fill_module(&module, segment_count);
+
+        if (!filled)
+        {
+            native_clear_raw_list(&module);
+            clear_native_modules(list_ptr);
+            fclose(file);
+            return false;
+        }
+
+        *cur_next_ptr = filled;
+    }
+
+    native_clear_raw_list(&module);
+    fclose(file);
+
+    *count_ptr = module_count;
+    return true;
+}