win32 output debugging

win32 output debugging

Postby Jim » Sun Sep 26, 2010 6:21 am

An alternative way for debugging on Windows machines using Win32API.so.

You need a system debug viewer running such as DebugView and output goes to the debugger window. Also,
If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.


This could also be used with Al's trace ruby messages technique so instead of output going to files ,it goes to the debugger.

Come to think of it, something like this should be part of the api.

Code: Select all
OutputDebugString = Win32API.new("kernel32.dll", "OutputDebugString", ['P'], 'V')

def opd(s="\0")
    s = s.to_s + "\0"
    OutputDebugString.call(s)
end

opd(Time.now)
0
Hi

Jim 
Global Moderator
 

Re: win32 output debugging

Postby thomthom » Sun Sep 26, 2010 11:44 am

This is excellent! :thumb: :thumb:

Jim wrote:Come to think of it, something like this should be part of the api.

Double Plus Good!
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: win32 output debugging

Postby Chris Fullmer » Sun Sep 26, 2010 5:45 pm

How would I use this Jim? I add that code to a script while I'm writing it. And do do what with it? It just does everything on its own?
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: win32 output debugging

Postby Jim » Sun Sep 26, 2010 6:15 pm

Here's what I came up with. Just make sure it is alphabetically the first file in Plugins in order to capture the earliest output.

Code: Select all
require 'Win32API'

class CL_rps_console < Sketchup::Console
    OutputDebugString = Win32API.new("kernel32.dll", "OutputDebugString", ['P'], 'V')
    def write(smess="\0")
        smess = smess.to_s + "\0"
        OutputDebugString.call(smess)
    end
end

# redefine standard output to our new class
$old_stdout = $stdout # in case you want to turn off traces
$stdout = CL_rps_console.new
$stderr = $stdout
puts "-" * 40
puts Time.now
puts "Starting SketchUp"
puts "-" * 40


0
Last edited by Jim on Wed Dec 01, 2010 2:23 pm, edited 1 time in total.
Hi

Jim 
Global Moderator
 

Re: win32 output debugging

Postby Jim » Mon Sep 27, 2010 12:30 am

In DebugView, you can clear the debugger window by outputting the string "DBGVIEWCLEAR"
0
Hi

Jim 
Global Moderator
 

Re: win32 output debugging

Postby tbd » Mon Sep 27, 2010 8:25 am

Jim: are you working for Render Plus now ? ;)
0
SketchUp Ruby Consultant | Podium 1.x developer
http://plugins.ro
User avatar
tbd 
 

Re: win32 output debugging

Postby thomthom » Mon Sep 27, 2010 8:56 am

I think this thread should be sticky... or in the sticky thread...
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: win32 output debugging

Postby Jim » Tue Sep 28, 2010 3:12 am

It turns out this OutputDebugString example is straight out of the Pickaxe book.
0
Hi

Jim 
Global Moderator
 

Re: win32 output debugging

Postby thomthom » Wed Oct 13, 2010 7:34 pm

class CL_rps_console < Sketchup::Console

Sketchup::Console :?: :?:
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 10 guests

Visit our sponsors: