2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / handles / hps.c
index 5bd7b3eb132e804274cdaf7f8d078ff714653cb9..4b704ade0feb46321485bd230d7e233fdc780c6d 100644 (file)
@@ -56,22 +56,32 @@ static const guchar * (*details[])(struct _WapiHandleShared *)=
 
 int main (int argc, char **argv)
 {
-       guint32 idx;
+       guint32 handle_idx;
        gboolean success;
-       int shm_id;
        
-       _wapi_shared_data=_wapi_shm_attach (FALSE, &success, &shm_id);
+       _wapi_shared_data=g_new0 (struct _WapiHandleShared_list *, 1);
+       _wapi_shared_scratch=g_new0 (struct _WapiHandleScratch, 1);
+       
+       success=_wapi_shm_attach (&_wapi_shared_data[0],
+                                 &_wapi_shared_scratch);
        if(success==FALSE) {
-               g_error ("Failed to attach shared memory! (tried shared memory ID 0x%x)", shm_id);
+               g_error ("Failed to attach shared memory!");
                exit (-1);
        }
        
        /* Make sure index 0 is actually unused */
-       for(idx=0; idx<_WAPI_MAX_HANDLES; idx++) {
-               struct _WapiHandleShared *shared=&_wapi_shared_data->handles[idx];
+       for(handle_idx=0; handle_idx<_wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT; handle_idx++) {
+               guint32 segment, idx;
+               struct _WapiHandleShared *shared;
+
+               _wapi_handle_segment (GUINT_TO_POINTER (handle_idx), &segment,
+                                     &idx);
+               _wapi_handle_ensure_mapped (segment);
+               
+               shared=&_wapi_shared_data[segment]->handles[idx];
                
                if(shared->type!=WAPI_HANDLE_UNUSED) {
-                       g_print ("%4x [%7s] %4u %s (%s)\n", idx,
+                       g_print ("%6x [%7s] %4u %s (%s)\n", handle_idx,
                                 typename[shared->type], shared->ref,
                                 shared->signalled?"Sg":"Un",
                                 details[shared->type](shared));
@@ -92,7 +102,7 @@ static const guchar *file_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_file *file=&handle->u.file;
        
-       name=_wapi_handle_scratch_lookup_as_string (file->filename);
+       name=_wapi_handle_scratch_lookup (file->filename);
        
        g_snprintf (buf, sizeof(buf),
                    "[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u",
@@ -146,7 +156,7 @@ static const guchar *mutex_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_mutex *mut=&handle->u.mutex;
        
-       name=_wapi_handle_scratch_lookup_as_string (mut->name);
+       name=_wapi_handle_scratch_lookup (mut->sharedns.name);
        
        g_snprintf (buf, sizeof(buf), "[%20s] own: %5d:%5ld, count: %5u",
                    name==NULL?(guchar *)"":name, mut->pid, mut->tid,
@@ -178,13 +188,8 @@ static const guchar *socket_details (struct _WapiHandleShared *handle)
 
 static const guchar *find_details (struct _WapiHandleShared *handle)
 {
-       static guchar buf[80];
-       struct _WapiHandle_find *find=&handle->u.find;
-       
-       g_snprintf (buf, sizeof(buf), "count: %5d",
-                   find->count);
-       
-       return(buf);
+       /* Nothing to see here either */
+       return("");
 }
 
 static const guchar *process_details (struct _WapiHandleShared *handle)
@@ -193,7 +198,7 @@ static const guchar *process_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_process *proc=&handle->u.process;
        
-       name=_wapi_handle_scratch_lookup_as_string (proc->proc_name);
+       name=_wapi_handle_scratch_lookup (proc->proc_name);
        
        g_snprintf (buf, sizeof(buf), "[%20s] pid: %5u",
                    name==NULL?(guchar *)"":name, proc->id);