Re: Debugging Wine thoughts

2008-09-11 Thread Chris Robinson
On Wednesday 10 September 2008 10:44:09 pm Damjan Jovanovic wrote:
 For example applications don't expect to see pointers into the upper
 1-2 GB of the 4 GB virtual memory address space because on Windows the
 kernel's memory is mapped there. But, ld-linux.so.2 could load
 libraries there, including libraries hosting Wine's DLLs, and pointers
 to memory in those would leak into the Windows code.

AFAIK, Wine doesn't load .dll.so files using the standard dl lib functions. At 
least, the dlopen/dlsym functions don't recognize the .dll.so files in a 
winelib app. What it does, again AFAIK, is mmap the lower 2-3GB range so it 
can put kernel32/etc where some apps expect it to be, and to mimick Windows' 
allocation algorithms.

However, because it's all premapped, further libc malloc calls can't use that 
same range, and will quickly run out of allocatable memory. This causes 
problems particularly with video cards that have 512MB VRAM or more, since 
there's not enough room to map and/or mirror the card resources.


An idea I had and mentioned on IRC a couple times is to have libwine expose 
functions that can be used by drivers and other native modules to 
allocate win32 memory instead of using the standard libc functions. It 
would be pretty easy for a driver or such to do:

void *hdl = dlopen(libwine.so, RTLD_NOLOAD);
void *(*mallocfunc)(size_t) = (hdl ? dlsym(hdl, wine_malloc) : NULL);
void (*freefunc)(void*) = (hdl ? dlsym(hdl, wine_free) : NULL);
if(!mallocfunc || !freefunc || dlerror() != NULL)
{
mallocfunc = malloc;
freefunc = free;
}
..use mallocfunc/freefunc for memory..

This will, of course, rely on drivers to be aware of Wine and handle it.

An alternative idea Alexandre had was to override libc's mmap, so anything 
loaded in the process would automatically use the new function (and thus not 
need any Wine-specific code). However, my attempts at doing that caused glibc 
to crash on init.




Re: Debugging Wine thoughts

2008-09-11 Thread Markus Hitter

Am 10.09.2008 um 17:32 schrieb Stefan Dösinger:

 You can attach any debugger to a Win32 process running in Wine. This
 includes Linux debuggers like gdb, [...]

As I didn't find hints on how to do this I tried myself:

** First, start gdb in the C: directory

[EMAIL PROTECTED]:/otherubuntu/home/mah/.wine/drive_c$ gdb
GNU gdb 6.8-debian
Copyright [...]
This GDB was configured as x86_64-linux-gnu.
(gdb) file wine
Reading symbols from /usr/local/bin/wine...done.
(gdb) directory /otherubuntu/home/mah/wine/
Source directories searched: /otherubuntu/home/mah/wine:$cdir:$cwd
(gdb)

** Then, run the app

(gdb) run windows/notepad.exe
Starting program: /usr/local/bin/wine windows/notepad.exe
[Thread debugging using libthread_db enabled]
[New Thread 0xf7c628c0 (LWP 793)]
[New Thread 0xf7c61b90 (LWP 796)]
[Thread 0xf7c61b90 (LWP 796) exited]
[New process 793]
Executing new program: /usr/local/bin/wine-preloader
warning: Cannot initialize thread debugging library: generic error
warning: Cannot initialize thread debugging library: generic error
[New process 793]
Fontconfig warning: /etc/fonts/conf.d/53-monospace-lcd-filter.conf,  
line 17: invalid constant used : lcdlegacy
Fontconfig warning: /etc/fonts/conf.d/53-monospace-lcd-filter.conf,  
line 17: invalid constant used : lcdlegacy
Fontconfig warning: /etc/fonts/conf.d/53-monospace-lcd-filter.conf,  
line 17: invalid constant used : lcdlegacy

** Notepad should be running here. Interrupt it from the command line  
to have a look:

^C
Program received signal SIGINT, Interrupt.
0xf7fec430 in ?? ()
(gdb) bt
#0  0xf7fec430 in ?? ()
#1  0x0008 in ?? ()
#2  0x7bc76516 in ?? ()
#3  [...]
(gdb) list
1   /*
2* Preloader for ld.so
3*
4* Copyright (C) [...]

As you see, listing appears to work in principle, while symbol lookup  
doesn't.

It's no secret Wine runs multiple processes and Windows applications  
run multiple threads, so you might want to look up how to handle this  
in gdb:

http://sources.redhat.com/gdb/current/onlinedocs/gdb_5.html

My tries to break not into the preloader, but the actual Windows  
application weren't successful so far, gdb's console appears to lock  
up somehow when setting follow-fork-mode  friends.


MarKus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/








RE: Debugging Wine thoughts

2008-09-10 Thread Stefan Dösinger
You can attach any debugger to a Win32 process running in Wine. This
includes Linux debuggers like gdb, or any graphical frontends, as well as
Windows debuggers like visual studio. If you built wine from source, the
Linux debuggers will see the Wine source. Probably they can also read the
Windows apps source if you have it. I'm not sure if Windows debuggers can
access the Wine source, but maybe dbghelp.dll can do that

 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, September 10, 2008 10:17 AM
To: [EMAIL PROTECTED]
Cc: wine-devel@winehq.org
Subject: Debugging Wine thoughts

 

Dan / All,
I think what the guy was asking on improving winedbg is to have some sort of
visual debugger much like VC/C++ , Eclipse, 
Borland C++ or the like... Where you can step through the code (seeing the
whole thing like any visual debugger).  
Then when looking at stacks you  click on a variable or stack and it either
winds it back or display's it.  

Below is my thoughts on what would be a nice to have in some form of
Debugger / Gui Debugger for Wine

So my wish list would be:
1) Some form of a Standard Gui Debugger
2) A way to select  the debug flags used with an explanation of what each is
for... +sed is for this +relay does that...etc   
3) When you do +relay you could open separate output windows for each thread

4) The ability to turn each of the +relay wine thread output on or off... 
4) Currently Wading through a relay log is a real pain and in some cases it
prevents the problem from occuring.
Time outs because of too much data being collected and then having to
wade through and determine what to and not to turn off.
So a note or best practice somewhere showing the heavy hitters in a
+relay log  and turn them off by default.  However, note 
somewhere saying  if +relay doesnt give enough information then turn on
just these flags and run. That way we are not managing 
flag lists when trying to figure out whats going wrong in an
application. IMHO +relay is too unweldly and turning each flag on 
individually is as well, so there needs to be some sort of happy medium
somewhere.
5) A window with a list of the important wine structures or resources that
can be watched as the application runs.
6) Source code debugging in the GUI with step through, break points, etc..(
not like now in winedbg but more like one of the GUI's mentioned before)
7) Loading of application from gui debugger and run it
8) Ability to look at a stack and backtrace in the GUI
9) Value Watches within the GUI.
10) Code Checking
  Some sort of bounds checking...
  Uninitialized variable checking
  Unreachable Code Checking
11) Use the GUI to help enforce the Wine Coding standard.. most modern GUI
environments let you specify a style of coding.
This would help the new people understand and follow the coding standards
set up... instead of guessing like they do now.
12) Online help / Context help...  point to the IC in the wiki... lots of
good stuff there... just hard to find sometimes
13) Integration with bugzilla... they find a bug... they create it in the
GUI.. dump out the screen, stack and the like... so some 
of the base information is collected instead of wasting time back and forth
and having so many invalid bugs. Again this format 
can be enforced through coding style templates... you want to submit a bug
here is what you do... check boxes to include things...
like I said screen shots... logs, traces, variables, hardware config, etc...
14) Integration with GIT... check and see if there is a new tree out there..
if so... flag it and git it...
15) Link to whats fixed in the new GIT tree... or a list of it...
16) Link to Dan's patchwatcher status... (kinda a workflow sort of thing) to
know whats good and bad...
17) Generation of the GIT patch and then mail it to the list through a
button...
18) GIT integration

You have to remember guy's alot of the new people coming in are not old
timers like some of us who grew up in a non-gui 
world.. Like it or not  they are used to doing things in certain ways and I
think we could get alot more people looking at 
bugs and helping fix them if we started thinking of something along these
lines. This of course is not a complete list... 
And I am sure this is going to start a flame war or something close to it..
But I think this might be a good next step for something
like the summer of code people to do.. or whomever maintains the wine
debugger to think seriously about.

Most of these things I think could be implemented using the current wine
debugger with some form of pipe between it and the GUI.
That way the 'purists' can still debug using winedebug like now and the new
people who choose to can use the GUI?

Thoughts


Problems I have noticed when debugging...
If I kill (press the X button or close it from the task bar) the wine
application, Wine does not clean up from itself... it leaves 

Re: Debugging Wine thoughts

2008-09-10 Thread celticht32

 Is there any documentation on the wine site how to set this up stefan???  It 
may be a start to what I am thinking. 

chris


 


 

-Original Message-
From: Stefan Dösinger [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: wine-devel@winehq.org
Sent: Wed, 10 Sep 2008 11:32 am
Subject: RE: Debugging Wine thoughts

























You can
attach any debugger to a Win32 process running in Wine. This includes Linux
debuggers like gdb, or any graphical frontends, as well as Windows debuggers
like visual studio. If you built wine from source, the Linux debuggers will see
the Wine source. Probably they can also read the Windows apps source if you
have it. I'm not sure if Windows debuggers can access the Wine source, but
maybe dbghelp.dll can do that



 



 












From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]

Sent: Wednesday, September 10,
2008 10:17 AM

To: [EMAIL PROTECTED]

Cc: wine-devel@winehq.org

Subject: Debugging Wine thoughts









 



Dan / All,

I think what the guy was asking on improving winedbg is to have some sort of
visual debugger much like VC/C++ , Eclipse, 

Borland C++ or the like... Where you can step through the code (seeing the
whole thing like any visual debugger).  

Then when looking at stacks you  click on a variable or stack and it
either winds it back or display's it.  



Below 
is my thoughts on what would be a nice to have in some form of Debugger /
Gui Debugger for Wine



So my wish list would be:

1) Some form of a Standard Gui Debugger

2) A way to select  the debug flags used with an explanation of what each
is for... +sed is for this +relay does that...etc   

3) When you do +relay you could open separate output windows for each thread 

4) The ability to turn each of the +relay wine thread output on or off... 

4) Currently Wading through a relay log is a real pain and in some cases it
prevents the problem from occuring.

    Time outs because of too much data being collected and then
having to wade through and determine what to and not to turn off.

    So a note or best practice somewhere showing the heavy
hitters in a +relay log  and turn them off by default.  However, note


    somewhere saying  if +relay doesnt give enough
information then turn on just these flags and run. That way we are not managing


    flag lists when trying to figure out whats going wrong in an
application. IMHO +relay is too unweldly and turning each flag on 

    individually is as well, so there needs to be some sort of
happy medium somewhere.

5) A window with a list of the important wine structures or resources that can
be watched as the application runs.

6) Source code debugging in the GUI with step through, break points, etc..( not
like no
w in winedbg but more like one of the GUI's mentioned before)

7) Loading of application from gui debugger and run it

8) Ability to look at a stack and backtrace in the GUI

9) Value Watches within the GUI.

10) Code Checking

  Some sort of bounds checking...

  Uninitialized variable checking

  Unreachable Code Checking

11) Use the GUI to help enforce the Wine Coding standard.. most modern GUI
environments let you specify a style of coding.

This would help the new people understand and follow the coding standards set
up... instead of guessing like they do now.

12) Online help / Context help...  point to the IC in the wiki... lots of
good stuff there... just hard to find sometimes

13) Integration with bugzilla... they find a bug... they create it in the GUI..
dump out the screen, stack and the like... so some 

of the base information is collected instead of wasting time back and forth and
having so many invalid bugs. Again this format 

can be enforced through coding style templates... you want to submit a bug here
is what you do... check boxes to include things...

like I said screen shots... logs, traces, variables, hardware config, etc...

14) Integration with GIT... check and see if there is a new tree out there.. if
so... flag it and git it...

15) Link to whats fixed in the new GIT tree... or a list of it...

16) Link to Dan's patchwatcher status... (kinda a workflow sort 
of thing) to
know whats good and bad...

17) Generation of the GIT patch and then mail it to the list through a
button...

18) GIT integration



You have to remember guy's alot of the new people coming in are not old timers
like some of us who grew up in a non-gui 

world.. Like it or not  they are used to doing things in certain ways and
I think we could get alot more people looking at 

bugs and helping fix them if we started thinking of something along these
lines. This of course is not a complete list... 

And I am sure this is going to start a flame war or something close to it.. But
I think this might be a good next step for something

like the summer of code people to do.. or whomever maintains the wine debugger
to think seriously about.



Most of these things I think could

Re: Debugging Wine thoughts

2008-09-10 Thread Eric Pouech
dbghelp supports both linux debug formats (stabs, dwarf) as well as 
microsoft's one
so any debugger using dbghelp as it's debug info provide should debug 
with all bells  whistles native  builtin applications
I had some success with windbg (with a an 'e' between n  d ;-)

unfortunately, http://www.winehq.org/site/docs/winedev-guide/dbg-others 
isn't fully uptodate
A+

-- 
Eric Pouech
The problem with designing something completely foolproof is to underestimate 
the ingenuity of a complete idiot. (Douglas Adams)






Re: Debugging Wine thoughts

2008-09-10 Thread Damjan Jovanovic
On Wed, Sep 10, 2008 at 8:17 PM,  [EMAIL PROTECTED] wrote:

 Question :
 Why does wine have to allocate all its memory at startup? re... the issue
 that is causing the ATI drivers to have such
 a fuss  why not just allocate as needed? or have the ability (if its not
 there already) to specify the total amount of memory
 which is available to the wine process and limit wine to just that ammount
 of memory (kind of like the way most VM machines
 have the option of setting the maximum amount of memory which is available).

Windows applications assume a certain memory layout, which sometimes
conflicts with what *nix does.

For example applications don't expect to see pointers into the upper
1-2 GB of the 4 GB virtual memory address space because on Windows the
kernel's memory is mapped there. But, ld-linux.so.2 could load
libraries there, including libraries hosting Wine's DLLs, and pointers
to memory in those would leak into the Windows code. So Wine prevents
the special areas of Windows memory from being used by *nix
libraries and functions like malloc() by mmap()ing that memory in
advance.

In my opinion, it would be better if we used a custom dynamic linker
(ie. an ld-wine.so) that could control where all libraries get loaded
so we wouldn't have to steal memory in advance and go through one of
the most elaborate startup processes in existence, where an assembly
_start routine in wine-preloader loads before ld-linux.so.2 and then
pretends to be the kernel.

Bye
Damjan Jovanovic