nicer errors loading executables

Josh DuBois duboisj at codeweavers.com
Mon Feb 12 13:25:42 CST 2001


Hi - 

  Making a .spec file with the wrong 'init' function lead to
uninformative error (generic "your .so file is no good" message), so
this retains the info from dlerror() and passes it back to the user, who
can see what went wrong.	
  
       Josh.
       
       ChangeLog: 
       library/loader.c
            new error message buffer param. for wine_dll_load_main_exe,
so error messages from wine_dlopen are preserved.     	
       include/wine/library.h
            changed prorotype of wine_dll_load_main_exe to take error
msg. buffer
       scheduler/process.c
            more verbose error messages when application load fails
-------------- next part --------------
Index: library/loader.c
===================================================================
RCS file: /home/cvs/wine/wine/library/loader.c,v
retrieving revision 1.7
diff -u -r1.7 loader.c
--- library/loader.c	2000/12/19 23:31:52	1.7
+++ library/loader.c	2001/02/12 18:49:17
@@ -349,7 +349,8 @@
  *
  * Try to load the .so for the main exe, optionally searching for it in PATH.
  */
-void *wine_dll_load_main_exe( const char *name, int search_path )
+void *wine_dll_load_main_exe( const char *name, int search_path,
+			      char *errStr, int eStrLen)
 {
     void *ret = NULL;
     const char *path = NULL;
@@ -358,7 +359,7 @@
     if (!path)
     {
         /* no path, try only the specified name */
-        ret = wine_dlopen( name, RTLD_NOW, NULL, 0 );
+        ret = wine_dlopen( name, RTLD_NOW, errStr, eStrLen );
     }
     else
     {
@@ -380,7 +381,7 @@
                 if ((len = p - path) > 0)
                 {
                     memcpy( basename - len, path, len );
-                    if ((ret = wine_dlopen( basename - len, RTLD_NOW, NULL, 0 ))) break;
+                    if ((ret = wine_dlopen( basename - len, RTLD_NOW, errStr, eStrLen ))) break;
                 }
                 if (!*p) break;
                 path = p + 1;
Index: include/wine/library.h
===================================================================
RCS file: /home/cvs/wine/wine/include/wine/library.h,v
retrieving revision 1.6
diff -u -r1.6 library.h
--- include/wine/library.h	2001/01/17 20:22:24	1.6
+++ include/wine/library.h	2001/02/12 18:49:17
@@ -16,7 +16,8 @@
 
 extern void wine_dll_set_callback( load_dll_callback_t load );
 extern void *wine_dll_load( const char *filename, char *error, int errorsize );
-extern void *wine_dll_load_main_exe( const char *name, int search_path );
+extern void *wine_dll_load_main_exe( const char *name, int search_path,
+				     char *errStr, int eStrLen);
 extern void wine_dll_unload( void *handle );
 
 /* debugging */
Index: scheduler/process.c
===================================================================
RCS file: /home/cvs/wine/wine/scheduler/process.c,v
retrieving revision 1.141
diff -u -r1.141 process.c
--- scheduler/process.c	2001/01/26 00:22:26	1.141
+++ scheduler/process.c	2001/02/12 18:49:18
@@ -389,13 +389,16 @@
     void *ret = NULL;
     char *tmp;
     const char *name;
+    char errStr[100];
 
     if ((name = getenv( "WINEPRELOAD" )))
     {
-        if (!(ret = wine_dll_load_main_exe( name, 0 )))
+        if (!(ret = wine_dll_load_main_exe( name, 0, errStr, 100 )))
         {
-            MESSAGE( "%s: could not load '%s' as specified in the WINEPRELOAD environment variable\n",
-                     argv[0], name );
+            MESSAGE( "%s: could not load '%s' as specified in the WINEPRELOAD environment variable:%s\n",
+                     argv[0],
+		     name,
+		     errStr);
             ExitProcess(1);
         }
     }
@@ -417,12 +420,14 @@
             strcpy( tmp, argv0 );
             strcat( tmp, ".so" );
             /* search in PATH only if there was no '/' in argv[0] */
-            ret = wine_dll_load_main_exe( tmp, (name == argv0) );
+            ret = wine_dll_load_main_exe( tmp, (name == argv0), errStr, 100 );
             if (!ret && !argv[1])
             {
                 /* if no argv[1], this will be better than displaying usage */
-                MESSAGE( "%s: could not load library '%s' as Winelib application\n",
-                         argv[0], tmp );
+                MESSAGE( "%s: could not load library '%s' as Winelib application:%s\n",
+                         argv[0],
+			 tmp,
+			 errStr);
                 ExitProcess(1);
             }
             HeapFree( GetProcessHeap(), 0, tmp );


More information about the wine-patches mailing list