[Libreoffice-commits] core.git: Branch 'feature/cib_contract57' - 3 commits - bridges/source sal/osl

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Thu Dec 22 09:38:10 UTC 2016


 bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx  |    9 +++
 bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx |    8 ++
 sal/osl/all/log.cxx                                  |   51 ++++++++++++++-----
 3 files changed, 57 insertions(+), 11 deletions(-)

New commits:
commit 61fe75043c1a106cd27bb84bbac36fdc5d93c2f6
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Wed Dec 21 21:16:49 2016 +0100

    bridges win32/64: Log uno method calls
    
    Change-Id: Ib18aea5e6ecf54dfabe9f417d5b288625dab0fb7

diff --git a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
index 58e4d64..e2f5976 100644
--- a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
@@ -241,6 +241,13 @@ static typelib_TypeClass __cdecl cpp_mediate(
             pThis);
 
     typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
+
+    SAL_INFO( "bridges.win32", "cpp_vtable_call: pCallStack=[" <<
+            std::hex << pCallStack[0] << "," << pCallStack[1] << "," << pCallStack[2] << ",...]" <<
+            ", pThis=" << pThis << ", pCppI=" << pCppI <<
+            std::dec << ", nFunctionIndex=" << nFunctionIndex << ", nVtableOffset=" << nVtableOffset );
+    SAL_INFO( "bridges.win32", "name=" << pTypeDescr->aBase.pTypeName );
+
     if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
     {
         SAL_WARN(
@@ -261,6 +268,8 @@ static typelib_TypeClass __cdecl cpp_mediate(
 
     TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
 
+    SAL_INFO( "bridges.win32", "Calling " << aMemberDescr.get()->pTypeName );
+
     typelib_TypeClass eRet = typelib_TypeClass_VOID;
     switch (aMemberDescr.get()->eTypeClass)
     {
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
index 4f1905c..14776e7 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
@@ -240,6 +240,12 @@ extern "C" typelib_TypeClass cpp_vtable_call(
 
     typelib_InterfaceTypeDescription * pTD = pCppI->getTypeDescr();
 
+    SAL_INFO( "bridges.win64", "cpp_vtable_call: pCallStack=[" <<
+            std::hex << pStack[0] << "," << pStack[1] << "," << pStack[2] << ",...]" <<
+            ", pThis=" << pThis << ", pCppI=" << pCppI <<
+            std::dec << ", nFunctionIndex=" << nFunctionIndex << ", nVtableOffset=" << nVtableOffset );
+    SAL_INFO( "bridges.win64", "name=" << pTD->aBase.pTypeName );
+
     if ( nFunctionIndex >= pTD->nMapFunctionIndexToMemberIndex )
     {
         SAL_WARN(
@@ -260,6 +266,8 @@ extern "C" typelib_TypeClass cpp_vtable_call(
 
     TypeDescription aMemberDescr( pTD->ppAllMembers[nMemberPos] );
 
+    SAL_INFO( "bridges.win64", "Calling " << aMemberDescr.get()->pTypeName );
+
     typelib_TypeClass eRet;
     switch ( aMemberDescr.get()->eTypeClass )
     {
commit 17802c07b34f44cfae0440a396dd3f3865ef8164
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Wed Dec 21 21:15:49 2016 +0100

    Add bootstrap option to enable/configure logging
    
    Change-Id: I71dc24f6d4a46584b4369f9ac4b0fb8c89c0e920

diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 9a8663c..8380d3c 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -23,6 +23,7 @@
 
 #include "osl/thread.hxx"
 #include "rtl/string.h"
+#include <rtl/bootstrap.hxx>
 #include "sal/detail/log.h"
 #include "sal/log.hxx"
 #include "sal/types.h"
@@ -81,7 +82,7 @@ char const * toString(sal_detail_LogLevel level) {
 // the process is running":
 #if defined ANDROID
 
-char const * getEnvironmentVariable() {
+char const * getLogLevel() {
     return std::getenv("SAL_LOG");
 }
 
@@ -99,14 +100,29 @@ char const * getEnvironmentVariable_(const char* env) {
     return p2;
 }
 
-char const * getEnvironmentVariable() {
+char const * getLogLevel() {
+    // First check the environment variable, then the bootstrap setting
     static char const * env = getEnvironmentVariable_("SAL_LOG");
-    return env;
+    if (env != nullptr)
+        return env;
+
+    OUString sLogLevel;
+    if (rtl::Bootstrap::get("LogLevel", sLogLevel) && !sLogLevel.isEmpty())
+        return  OUStringToOString( sLogLevel, RTL_TEXTENCODING_ASCII_US).getStr();
+    return nullptr;
+
 }
 
 char const * getLogFile() {
+    // First check the environment variable, then the bootstrap setting
     static char const * logFile = getEnvironmentVariable_("SAL_LOG_FILE");
-    return logFile;
+    if (logFile != nullptr)
+        return logFile;
+
+    OUString sLogFilePath;
+    if (rtl::Bootstrap::get("LogFilePath", sLogFilePath) && !sLogFilePath.isEmpty())
+        return  OUStringToOString( sLogFilePath, RTL_TEXTENCODING_ASCII_US).getStr();
+    return nullptr;
 }
 
 #endif
@@ -115,7 +131,7 @@ bool report(sal_detail_LogLevel level, char const * area) {
     if (level == SAL_DETAIL_LOG_LEVEL_DEBUG)
         return true;
     assert(area != 0);
-    char const * env = getEnvironmentVariable();
+    char const * env = getLogLevel();
     if (env == 0) {
         env = "+WARN";
     }
commit fb22a4f0d92d1a7a371fab21c965b26b9c0a5b42
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Dec 19 12:54:34 2016 +0100

    add an option to pipe log output to file
    
    The target file and the option are controlled by SAL_LOG_FILE. The
    variable should contain the target file in a system dependent notation.
    
    Change-Id: Ie1ce9c39740c8b7a989e5af222be21a3e3142084
    Reviewed-on: https://gerrit.libreoffice.org/32176
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 67e384c..9a8663c 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <fstream>
 
 #include "osl/thread.hxx"
 #include "rtl/string.h"
@@ -86,10 +87,10 @@ char const * getEnvironmentVariable() {
 
 #else
 
-char const * getEnvironmentVariable_() {
-    char const * p1 = std::getenv("SAL_LOG");
-    if (p1 == 0) {
-        return 0;
+char const * getEnvironmentVariable_(const char* env) {
+    char const * p1 = std::getenv(env);
+    if (p1 == nullptr) {
+        return nullptr;
     }
     char const * p2 = strdup(p1); // leaked
     if (p2 == 0) {
@@ -99,10 +100,15 @@ char const * getEnvironmentVariable_() {
 }
 
 char const * getEnvironmentVariable() {
-    static char const * env = getEnvironmentVariable_();
+    static char const * env = getEnvironmentVariable_("SAL_LOG");
     return env;
 }
 
+char const * getLogFile() {
+    static char const * logFile = getEnvironmentVariable_("SAL_LOG_FILE");
+    return logFile;
+}
+
 #endif
 
 bool report(sal_detail_LogLevel level, char const * area) {
@@ -240,8 +246,15 @@ void log(
         syslog(prio, "%s", s.str().c_str());
 #endif
     } else {
-        std::fputs(s.str().c_str(), stderr);
-        std::fflush(stderr);
+        const char* logFile = getLogFile();
+        if (logFile) {
+            std::ofstream file(logFile, std::ios::app | std::ios::out);
+            file << s.str();
+        }
+        else {
+            std::fputs(s.str().c_str(), stderr);
+            std::fflush(stderr);
+        }
     }
 #endif
 }


More information about the Libreoffice-commits mailing list