help on a GPF situation

Re: help on a GPF situation

Postby karinha » Fri Oct 22, 2021 3:58 pm

Master, que versión de HARBOUR usas? En mi versión, esto no funciona.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: help on a GPF situation

Postby karinha » Fri Oct 22, 2021 4:04 pm

Code: Select all  Expand view  RUN

//-> \SAMPLES\HBSENHA.PRG

#Include "FiveWin.ch"

#define HB_TR_ALWAYS         0
#define HB_TR_FATAL          1
#define HB_TR_ERROR          2
#define HB_TR_WARNING        3
#define HB_TR_INFO           4
#define HB_TR_DEBUG          5
#define HB_TR_LEVEL_ALWAYS   0
#define HB_TR_LEVEL_FATAL    1
#define HB_TR_LEVEL_ERROR    2
#define HB_TR_LEVEL_WARNING  3
#define HB_TR_LEVEL_INFO     4
#define HB_TR_LEVEL_DEBUG    5

MEMVAR cText ,cKey, cEncrypted, cPassWord

FUNCTION Main()

   *---------------------------------------------------------------------------------------*
   #pragma TEXTHIDDEN(1)

   PUBLIC  cPassWord := "Q65h3l8j41B"  // <- Very important not to change Password or Delete !!!    <-------  "Top Secret ;-)"

   #pragma TEXTHIDDEN(0)
   *---------------------------------------------------------------------------------------*

   cText := "This is my secret message."

   cKey  := HB_blowfishKey( cPassWord )

   MsgInfo("Original:  "   + HB_StrToExp( cText ) )

   /* encrypt data */
   #ifdef __XHARBOUR__  // xHarbour

      __TRACEPRGCALLS( .T. )

      MsgInfo( "Encrypted: " + StrToHex( cEncrypted := HB_blowfishEncrypt( cKey, cText ) ) )

      ? "hb_traceLevel", hb_traceLevel()

      ? "hb_traceState", hb_traceState()

   #else  // Harbour

      hb_traceSysOut( .T. )

      MsgInfo( "Encrypted: " + HB_StrToHex( cEncrypted := HB_blowfishEncrypt( cKey, cText ) ) )

      ? HB_TRACELOG( "hbsenha" )  // retorna vacio

      ? HB_TRACEMODE()            // retorna W

   #endif

   /* decrypt data */
   MsgInfo( "Decrypted: " + HB_StrToExp( HB_blowfishDecrypt( cKey, cEncrypted ) ) )

   /*
   ? "LEVEL: HB_TR_ALWAYS",  HB_TRACELEVEL( HB_TR_ALWAYS )
   ? "LEVEL: HB_TR_FATAL",   HB_TRACELEVEL( HB_TR_FATAL )
   ? "LEVEL: HB_TR_ERROR",   HB_TRACELEVEL( HB_TR_ERROR )
   ? "LEVEL: HB_TR_WARNING", HB_TRACELEVEL( HB_TR_WARNING )
   ? "LEVEL: HB_TR_INFO",    HB_TRACELEVEL( HB_TR_INFO )
   ? "LEVEL: HB_TR_DEBUG",   HB_TRACELEVEL( HB_TR_DEBUG )
   */


RETURN NIL

FUNCTION StrToHex( cString )
RETURN Lower( cString )

// FIN
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: help on a GPF situation

Postby Antonio Linares » Fri Oct 22, 2021 6:31 pm

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: help on a GPF situation

Postby karinha » Fri Oct 22, 2021 10:17 pm

Maestro, ¿cómo llamo internamente dentro del programa para invocar DBWIN32.exe?
Ya lo he copiado DBWIN32.exe a la carpeta \ samples.

Gracias.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: help on a GPF situation

Postby karinha » Fri Oct 22, 2021 10:50 pm

No és posible, no funciona! Que hago mal?

Code: Select all  Expand view  RUN

//-> \SAMPLES\TESTE.PRG

#Include "FiveWin.ch"

#define HB_TR_ALWAYS         0
#define HB_TR_FATAL          1
#define HB_TR_ERROR          2
#define HB_TR_WARNING        3
#define HB_TR_INFO           4
#define HB_TR_DEBUG          5
#define HB_TR_LEVEL_ALWAYS   0
#define HB_TR_LEVEL_FATAL    1
#define HB_TR_LEVEL_ERROR    2
#define HB_TR_LEVEL_WARNING  3
#define HB_TR_LEVEL_INFO     4
#define HB_TR_LEVEL_DEBUG    5

FUNCTION Main()

   hb_tracelevel(5)

   hb_traceloglevel(5)

   hb_TraceSysOut( .T. )
   __TracePrgCalls( .T. )

   IF File( "test.txt" )

      OutputDebugString( "El archivo existe" + hb_osnewline() )

   ELSE

      OutputDebugString( "El archivo no existe" + hb_osnewline() )

   ENDIF

   ? hb_traceMode()  // W ? // no llama DBWIN32.exe ??

RETURN NIL

// FIN
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: help on a GPF situation

Postby karinha » Fri Oct 22, 2021 10:54 pm

Listo!

Code: Select all  Expand view  RUN

Ejemplo:

IF File( "test.txt" )
   OutputDebugString( "El archivo existe" + hb_osnewline() )
ELSE
   OutputDebugString( "El archivo no existe" + hb_osnewline() )
ENDIF

Al incluir esto en nuestro codigo fuente realmente no estaremos viendo nada, en primer lugar antes de ejecutar nuestro programa debemos tener en ejecucion dbwin32.exe, este programa se encarga de mostrar en pantalla la informacion pasada como parametro a la funcion OutputDebugString().
 


http://codigo-base.blogspot.com/2008/07/depurando-en-windows_4979.html

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: help on a GPF situation

Postby cnavarro » Fri Oct 22, 2021 11:20 pm

Ahora lo "divertido" será capturar esas salidas en nuestro programa para no necesitar el dbwin2, no?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: help on a GPF situation

Postby Antonio Linares » Sat Oct 23, 2021 4:40 am

Joao,

Ejecutas primero dbwin32.exe, luego defines esa variable de entorno y ejecutas tu EXE

> ¿cómo llamo internamente dentro del programa para invocar DBWIN32.exe?

set HB_TR_SYSOUT=yes

tienes que tener esa variable de entorno definida y Harbour se encarga del resto

Harbour tiene que haber sido construido usando esto:

set HB_BUILD_DEBUG=yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: help on a GPF situation

Postby Antonio Linares » Sat Oct 23, 2021 4:49 am

https://github.com/harbour/core/blob/master/doc/tracing.txt

INTRODUCTION
============

This file explains how to enable tracing in Harbour.


TRACING
=======

Harbour implements tracing by adding calls to the following macro in
the C code:

HB_TRACE( level, ( "printf-style parameters", arg1, arg2 ) );

The level specified for the HB_TRACE call affects Harbour in two ways:
compilation time and run time.


COMPILATION TIME
================

At compilation time, the macro checks whether the preprocessor
constant HB_TR_LEVEL is set to any of the following values:

#define HB_TR_ALWAYS 0
#define HB_TR_FATAL 1
#define HB_TR_ERROR 2
#define HB_TR_WARNING 3
#define HB_TR_INFO 4
#define HB_TR_DEBUG 5

#define HB_TR_LEVEL_ALWAYS 0
#define HB_TR_LEVEL_FATAL 1
#define HB_TR_LEVEL_ERROR 2
#define HB_TR_LEVEL_WARNING 3
#define HB_TR_LEVEL_INFO 4
#define HB_TR_LEVEL_DEBUG 5

If it is not set to any of these, the macro is set to the value of
HB_TR_DEFAULT, which is currently set (in hbtrace.h) to HB_TR_WARNING.

Whether the user explicitly sets HB_TR_LEVEL or it is set by the
compiler, its effect is as follows: any calls in the code with a level
higher than HB_TR_LEVEL are obliterated from the code; these calls
simply disappear, and there is no effect in the code performance
thereafter.


RUN TIME
========

At run time, the user can set the environment variable HB_TR_LEVEL to
one of

HB_TR_ALWAYS
HB_TR_FATAL
HB_TR_ERROR
HB_TR_WARNING
HB_TR_INFO
HB_TR_DEBUG

with the following effect: any calls to HB_TRACE that were left by the
compiler and which have a level lower or equal to HB_TR_LEVEL will
print its arguments on STDERR.


EXAMPLES
========

HB_TR_LEVEL HB_TR_LEVEL Description
compilation run-time
----------- ----------- ----------------------------------------
HB_TR_INFO HB_TR_ERROR All calls with levels HB_DEBUG are
or erased from the code, so they have no
HB_TR_LEVEL_INFO performance effect; only calls with
levels HB_TR_ERROR, HB_TR_FATAL and
HB_TR_ALWAYS are printed.

HB_TR_WARNING HB_TR_INFO All calls with levels HB_INFO and
or HB_DEBUG are erased from the code, so
HB_TR_LEVEL_WARNING they have no performance effect; only
calls with levels HB_TR_WARNING,
HB_TR_ERROR, HB_TR_FATAL and
HB_TR_ALWAYS are printed. Notice how
setting HB_TR_INFO at run-time has no
effect, since the code was compiled with
a lower tracing level.

For example, I compile Harbour on Windows with gcc (mingw), so I
usually set the HB_USER_CFLAGS environment variable like this:

export HB_USER_CFLAGS='-DHB_TR_LEVEL=HB_TR_INFO'

or for other OS (e.g.: MS-DOS, Windows)

SET HB_USER_CFLAGS=-DHB_TR_LEVEL_INFO

and make sure I have all the tracing for the INFO, WARNING, ERROR,
FATAL and ALWAYS levels. If I get too much information, at run-time I
can set an environment variable like this:

export HB_TR_LEVEL=HB_TR_WARNING

or for other OS (e.g.: MS-DOS, Windows)

SET HB_TR_LEVEL=HB_TR_WARNING

and get rid of all the tracing for the INFO level. In this case, all
the calls to the tracing function for the INFO level will be done
anyway, so there will be a performance hit.


USAGE
=====

When Harbour is compiled/run with some level of tracing and then used
to compile a regular Harbour application, the app will output LOTS of
tracing information to STDERR. If you are using a sensible command
shell (such as bash) you can redirect STDERR to a file like this:

my_app 2> trace.txt


REDIRECTION
===========

The output generated while tracing goes to STDERR by default. You can
control this at run-time by setting the environment variable
HB_TR_OUTPUT to the name of a file where you would like the tracing
output to be directed. If there is any problem opening the file for
writing, the output reverts to STDERR.

When it happens an error and the controller of errors of Harbour cannot
intercept it (e.g.: GPF), it can happen that part of information of tracing
it is not written. This problem is avoided setting the environment
variable HB_TR_FLUSH to 1 (one). This makes that every time that one
record is sent to write, don't remain in the buffer, but rather it is
written in the file before continuing with the execution.
This set can produce an important reduction of speed of execution.

TRACING THE PREPROCESSOR AND COMPILER
=====================================

Usually, you will not want tracing enabled in the preprocessor and
compiler; otherwise, you will see the trace output while compiling
Harbour itself. If you REALLY want to enable tracing in the
preprocessor and/or compiler, you must define, in addition to
HB_TR_LEVEL as described above, the following variable, and then
recompile the preprocessor/compiler:

HB_TRACE_UTILS

The value is of no importance.


TRACING AND RUNTIME
===================

It is also possible to enable and disable tracing at run-time, and to
query and set the trace level. From C code:

* To query the current tracing state, and optionally change the
current state to a given value (which should be in the range [0,1],
otherwise the current state remains unchanged):

hb_tracestate( state );

Therefore, to just query the current state, you can safely call

current_state = hb_tracestate( -1 );

To turn tracing completely off:

hb_tracestate( 0 );

To turn tracing back on:

hb_tracestate( 1 );

* To query the current tracing level, and optionally change the
current level to a given value (which should be in the range [0,5],
otherwise the current level remains unchanged):

hb_tracelevel( level );

Therefore, to just query the current level, you can safely call

current_level = hb_tracelevel( -1 );


There are wrapper functions callable from Clipper code:

current_state := hb_traceState( [<new_state>] )
current_level := hb_traceLevel( [<new_level>] )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: help on a GPF situation

Postby Antonio Linares » Sat Oct 23, 2021 6:07 am

This example generates info.log and uses dbwin32. Please have dbwin32 running before calling go.bat

go.bat
Code: Select all  Expand view  RUN
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_x64
set HB_TR_LEVEL=debug
set HB_USER_CFLAGS=-DHB_TR_LEVEL_DEBUG
set HB_TR_SYSOUT=yes
set HB_TR_OUTPUT=info.log
c:\harbour\bin\win\msvc64\hbmk2 test.prg -comp=msvc64
test


test.prg
Code: Select all  Expand view  RUN
function Main()

   hb_traceLevel( 5 )
   hb_traceSysOut( .T. )
   hb_traceLog( "hello" )
   Test()
   
return nil

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( TEST )
{
   HB_TRACE( HB_TR_DEBUG, ( "TEST()(%s)", "ok" ) );
}

#pragma ENDDUMP


Harbour must have been built using this:
set HB_BUILD_DEBUG=yes

Please check the contents of the generated file info.log and the dbwin32 output
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: help on a GPF situation

Postby Antonio Linares » Sat Oct 23, 2021 6:29 am

I am building Harbour 64 bits this way:

Remove the rem here to have full Harbour activity:
set HB_TR_LEVEL=debug

go.bat (run this from c:\harbour)
Code: Select all  Expand view  RUN
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
set HB_COMPILER=msvc64
set HB_BUILD_MODE=c
set HB_USER_PRGFLAGS=-l-
set HB_BUILD_CONTRIBS

set HB_BUILD_DEBUG=yes
rem set HB_TR_LEVEL=debug
set HB_USER_CFLAGS=-DHB_TR_LEVEL_DEBUG

set HB_WITH_OPENSSL=c:\OpenSSL-Win64\include
set HB_WITH_CURL=c:\curl\include
set HB_OPENSSL_STATIC=yes      
set HB_STATIC_OPENSSL=yes  
set HB_STATIC_CURL=yes
set HB_BUILD_DYN=no
set HB_BUILD_CONTRIB_DYN=no
del .\src\common\obj\win\msvc64\hbver.obj
del .\src\common\obj\win\msvc64\hbver_dyn.obj
del .\src\common\obj\win\msvc\hbverdsp.obj
win-make.exe
copy c:\harbour\lib\win\msvc64\libcurl-x64.lib c:\harbour\lib\win\msvc64\libcurl.lib
copy c:\harbour\lib\win\msvc64\libssl-1_1-x64.lib c:\harbour\lib\win\msvc64\ssleay32.lib
copy c:\harbour\lib\win\msvc64\libcrypto-1_1-x64.lib c:\harbour\lib\win\msvc64\libcrypto.lib
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: help on a GPF situation

Postby Antonio Linares » Sat Oct 23, 2021 2:33 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests

cron