Configuring log4cpp Logging level Priority - c++

In an application we are using log4cpp-0.3.5rc3 for logging. The application is installed on linux devices. There is a bug in application and I want to set the log level of application to debug but I don't find anyway to do it on the remote device.
In the application configuration I couldn't find anything about log level just this line:
log4cpp_include_dir_default=${system_lib_dir}/log4cpp/log4cpp-0.3.5rc3/include
log4cpp_include_dir=${log4cpp_include_dir_default}
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [have GCC compile with symbols (default = no)]), enable_debug=$enableval, enable_debug=no)
Is it so that I have to build application with debug configuration and install a new build for setting Log level to debug? I wonder if log4cpp has any configuration file for logging like log4j in Java where we can easily change the log level.

Sure, log4cpp uses a log4cpp.properties file to configure the logger.
The path to this file will be passed to log4pp::PropertyConfigurator::configure(<path_to_file>)
when you configure your logger (usually at application startup); therefore, it could be stored anywhere in your filesystem, so you'll need to see what path is passed in to find the file.
A simple example properties file:
log4cpp.rootCategor=DEBUG, A1
log4cpp.main=INFO, A1
# A1 is to the console
log4cpp.appender.A1=org.apache.log4j.ConsoleAppender
log4cpp.appender.A1.layout=PatternLayout
log4cpp.appender.A1.ImmediateFlush=true
log4cpp.appender.A1.layout.ConversionPattern=Console %d [%t] %-5p %c - %m%n

Related

OpenOCD with XDS200 JTAG Emulator

So I have a Blackhawk XDS200 Debug Probe (TMDSEMU200-U) and I would like to use OpenOCD to debug on my target platform (IWR6483).
When I create a config file, I get the error:
Error: Can't find interface/xds200.cfg
The config file is:
source [find interface/xds200.cfg]
adapter speed 5500
transport select jtag
source [find target/ti_cc13x2.cfg]
Is there a reason it can't find this specific config file? When I change it to xds110.cfg, it doesn't give me this error (provided I connect the debug probe).
Alternatively, could anyone point me to this specific xds200.cfg file I could download?
Thanks!
XDS200 isn't one of the debug interfaces in https://github.com/openocd-org/openocd/tree/master/tcl/interface, so I don't think it is supported yet. I am also interested in OpenOCD supporting this debug probe!

Failing to start Windows service after a MajorUpgrade with WiX

I have a pretty straight forward WiX project. Nothing fancy. When trying to perform a MajorUpgrade over an existing installation, it is unable to start the service and inevitably rolls back to the previous version and starts the service just fine. I have removed the Start="install" and manually started the application successfully, so I know it's not a dependency issue.
I have searched endlessly and found no answers to my problem.
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallFinalize" />
My service install:
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="LsdnService"
DisplayName="Lsdn Service"
Description="Placeholder for now."
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="LsdnService" Wait="yes" />
I dumped the MSI log to a file and got this error but it is quite vague.
MSI (s) (18:48) [22:41:27:349]: Note: 1: 2205 2: 3: Error
MSI (s) (18:48) [22:41:27:349]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1920
There are some registry modifications during an installation. The installer attempts to read from the registry and inherit the already existing values.
<Property Id="LSDNADDRESS" Value="127.0.0.1">
<RegistrySearch Id="LsdnAddressProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnAddress" Type="raw" />
</Property>
<Property Id="LSDNPORT" Value="9920">
<RegistrySearch Id="LsdnPortProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnPort" Type="raw" />
</Property>
<Property Id="LSDNKEY" Value="6f380b07-0b54-4904-8303-95d1ec45d453">
<RegistrySearch Id="LsdnKeyProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnKey" Type="raw" />
</Property>
Debugging Results: Following a lot of debugging (by original poster - OP) this turned out to be a known MSI issue described here:
https://wix-users.narkive.com/EMfQPDrM/a-bug-get-reg-sz-when-using-type-integer. Nice search work.
What is in a DWORD? (a REG_SZ apparently): Essentially MSI "converts" a DWORD value found via a RegistrySearch
operation to a formatted string - REG_SZ - during upgrade
installations (could be more involved too). This causes services that
expect a DWORD value to fall over on startup during major
upgrades. A very exotic error.
Workaround: One can try to "solve" this problem by making the service code capable of reading both DWORD and REG_SZ.
This yields a more robust solution than solving the problem in a
custom action since it is a "permanent" fix as long as the code is in
there (and the presence of the code alerts other developers about the
problem). Or maybe use only REG_SZ?
Quick Checks: Check the service password and login - obviously. Anything in the
Event Viewer? Windows Key + Tap R + eventvwr.msc + Enter. How to use the Event Viewer to troubleshoot problems with a Windows Service. Perhaps you can try to do a folder diff on the before and after folders and see if you see something unexpected in
the config files? Naturally there will be lots of binary
differences, but check the text files (also encoding). Check the MSI log file
again and search for "value 3" as described here: Tips For Checking MSI Log
Files. Manually copy the new files in place and attempt to start the service via the services.msc applet.
Service Experts: Windows Services Frequently Asked Questions (FAQ). Content seems to be up to date - at face value at least.
These guys claim to be experts on services. I have no idea who they
are.
Look in the "Errors" section in the link above. Here are some
extracts:
1053: The service did not respond to the start or control request in a timely fashion
Why doesn't my Windows Service start automatically after a reboot?
1069: The service did not start due to a logon failure
Generic Check Lists: If none of the above does anything, maybe try these "torpedoes full spread" check-lists (just ideas to start debugging):
Desktop applicaton not opening after installation in client system
Windows Application Startup Error Exception code: 0xe0434352
General Purpose Debugging: Throwing in some general-purpose debugging approaches.
Custom Action Debugging: WIxsharp debug custom action in console
Dependency Scanning: Which winform project files should be packed up into the installer
Some Further Links:
C# Debug folder when copied to another location does not run the exe
wix service install not enough permission
How exactly does the WiX 'Service Install' work internally?
WiX Toolset PermissionEx Problem - App Does Not Run After Installation
It certainly could be a dependency issue. For example, GAC / WinSXS files don't get installed into the GAC until the commit phase which is after StartServices.
I would leave the Start="Install" in and while it's sitting at the failed to start prompt inspect the state of the machine and debug the service start manually. I bet you'll find something missing.

Windows biometric framework sample umdf driver: This device cannot start. (Code 10)

I am trying to run a windows biometric driver sample and I am naive to driver development
I have changed the hardware id in the inx file and rebuilt the driver project and installed the resulting driver on my Windows 10 Pro version 1803.
I am using a Fingerprint Morpho Device 1300 E3
Driver got installed successfully but there is one error showing up:
This device cannot start. (Code 10)
The specified request is not a valid operation for the target device.
I reviewed the file C:\Windows\INF\setupapi.dev.log
It shows the next warnings:
sig: {_VERIFY_FILE_SIGNATURE} 10:13:03.130
sig: Key = wudfbiousbsample.inf
sig: FilePath = C:\WINDOWS\System32\DriverStore\Temp\{ee9ffca3-751f-0b4e-a7ac-dce2543d995e}\wudfbiousbsample.inf
sig: Catalog = C:\WINDOWS\System32\DriverStore\Temp\{ee9ffca3-751f-0b4e-a7ac-dce2543d995e}\biometrics.cat
! sig: Verifying file against specific (valid) catalog failed.
! sig: Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
!!! dvi: Device not started: Device has problem: 0x0a (CM_PROB_FAILED_START), problem status: 0xc0000450.
But I installed the TestCertificate on the Trusted Root Certification Authorities and Trusted Publishers on the local machine
I also checked the EventViewer:
Application and Services Logs > Microsoft\Windows\CodeIntegrity
Application and Services Logs > Microsoft\Windows\Biometrics
I tried to debug with wdfverifier.exe following some videos from msdn but the process is not started so I couldn't debug :(
I verified that Visual Studio is not signing the EngineAdapter.dll plugin file so I disabled driver signing and did it manually following this paper. But I get the same error code 10 :(
I also wondered if error code 10 is this the expected behavior because the code of EngineAdapter.dll is not implemented.
UPDATE: I am testing on a Windows 10 Pro Version 1709 Virtual Machine VMWare and I get other error:
This device is not working properly because Windows cannot load the drivers required for this device. (Code 31)
!!! dvi: Device not started: Device has problem: 0x1f (CM_PROB_FAILED_ADD), problem status: 0xc0000001.
And the same warnings:
sig: {_VERIFY_FILE_SIGNATURE} 17:19:01.646
sig: Key = wudfbiousbsample.inf
sig: FilePath = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\wudfbiousbsample.inf
sig: Catalog = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\biometrics.cat
! sig: Verifying file against specific (valid) catalog failed.
! sig: Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
sig: {_VERIFY_FILE_SIGNATURE exit(0x800b0109)} 17:19:01.661
sig: {_VERIFY_FILE_SIGNATURE} 17:19:01.676
sig: Key = wudfbiousbsample.inf
sig: FilePath = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\wudfbiousbsample.inf
sig: Catalog = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\biometrics.cat
sig: Success: File is signed in Authenticode(tm) catalog.
sig: Error 0xe0000241: The INF was signed with an Authenticode(tm) catalog from a trusted publisher.
sig: {_VERIFY_FILE_SIGNATURE exit(0xe0000241)} 17:19:01.708
sto: {DRIVERSTORE IMPORT VALIDATE: exit(0x00000000)} 17:19:01.739
Full log file here setupapi.dev.log
I tought the driver does not load because the warnings about the certificate or the error could be somewhere else.
If someone could give me a small advice to continue. I am stuck now :(
Many Thanks.
All started when I was able to install my Biometric Driver but it showed a "Yellow Exclamation Mark" and a generic message "This device cannot start. (Code 10)"
The biometric sample project does not include an example how to sign properly EngineAdapter.dll with Visual Studio I found this resource (page 33-34) where shows How to Sign The EngineAdapter on project properties Build Events -> Post Build Event:
Command Line: signtool sign /v /ac "Path_to_cross_certificate_DigiCert Assured ID Root CA.crt" /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f "path_to_my_certificate_file.pfx" /p mypassword "$(Platform)\$(ConfigurationName)\EngineAdapter.dll"
Use In Build: Yes
Next This first video tutorial shows an example of debugging umdf driver using a tool from the WDK wdfverifier.exe
I couldn't attach the debugger to my driver process because the process is not present. But I could debug at startup before the process crashes.
To debug with wdfverifier.exe I took the following steps:
Settings Tab:
Check the option "Automatically Launch user-mode debugger when requested", specify 15 seconds in the input "Host Process will wait"
Preferences Tab:
Check "Use WinDbg", then
Disable/Enable my device on Device Manager
WinDbg launches and I can check if my driver module was loaded with the next command:
lm m *bio*
//the module is not loaded, use g commant to continue
g
//again see if the module was loaded
lm m *bio*
//module shows up, great!
Now I can set break points but before that I had to specify to WinDbg where are the symbol file (*.pdb) and source code of the driver with the next commands (the paths may be different if you build the package project, I am building the WudfBioUsbSample with a reference to EngineAdapter Project):
.symfix
.srcpath+ C:\Users\myuser\Documents\Windows-driver-samples\biometrics\driver
.sympath+ C:\Users\myuser\Documents\Windows-driver-samples\biometrics\driver\x64\Debug
.reload /f
Next I could set a break point:
//x command is used to search if the method exist
x WudfBioUsbSample!CBiometricDriver::*
x WudfBioUsbSample!CBiometricDevice::*
x WudfBioUsbSample!CBiometricDevice::OnGetAttributes
//examples of breakpoints
bp WudfBioUsbSample!CBiometricDriver::OnDeviceAdd
bp WudfBioUsbSample!CBiometricDevice::OnGetAttributes
bp WudfBioUsbSample!CBiometricDevice::CreateUsbIoTargets
The method CreateUsbIoTargets is where the errors show up. These errors are fixed by JinZhuXing in this github issue
After fixing the driver code and debugging that the method CreateUsbIoTargets runs Ok
Still showed me The Yellow Exclamation Mark but this time the error was in the EngineAdapter.dll. The next error shows in EventViewer: Application and Services Logs > Microsoft\Windows\Biometrics
The module's "Engine Adapter" initialization routine failed with error: 0x80004001
The EngineAdapter project methods were returning E_NOTIMPL I just changed this to return S_OK instead for all methods. And the biometric unit was successfully created.
Also debugging of the Engine Plugin is done with Visual Studio. Here are the steps I followed:
Use wdfverifier.exe to attach WinDbg to the process of my umdf driver and set a break point to OnGetAttributes method (this method is called when I start/restart the Windows Biometric Service)This breakpoint will make the service to wait before it calls the EngineAdapter Plugin code.
x WudfBioUsbSample!CBiometricDevice::OnGetAttributes
bp WudfBioUsbSample!CBiometricDevice::OnGetAttributes
g
Restart or start Windows Biometric Service (WbioSrvc on Task Manager->Services Tab)
Copy The Process ID (PID)
Run Visual Studio as Administrator, Open WBDIsample project
Use Menu Debug -> Attach to Process...
Enter the following values:
Connection Type: Windows User Mode Debugger
Connection Target: Localhost
Check "Show processes from all users"
Filter by Process ID
Select the process and Click Attach button.
Set Breakpoints on WbioQueryEngineInterface, EngineAdapterAttach, EngineAdapterDetach
a sample implementation is on msdn
run the command g (Go) on WinDbg
g
After this you can debug the code of the plugin on Visual Studio.
What is left is to implement the code for the Biometric Driver and The necessary plugins for your device

Exit 1 when calling mono_jit_init

Hi, I try to embed mono in a c++ application on windows. I followed http://www.mono-project.com/docs/compiling-mono/windows/ and I have my headers, lib and dll built for win64.
I wrote a simple app that just calls
MonoDomain *domain;
domain = mono_jit_init("ConsoleApplication1.exe");
Everything builds and link find but when I run my program, I can break and step until the mono_jit_init call. Then the apps performs an exit1 and I can't see what's wrong.
I tried both release and debug.
Any ideas on how to find the issue? Properly embed mono?
Thanks, JNQ
Your application probably fails on loading Mono libraries.
You can use Process Monitor (https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) to find out what exactly fails for you:
Run Process Monitor
Set Process Monitor filter to "[Process Name] [is] [Your process name, e.g. ConsoleApplication1.exe] then [Include]"
Run you program and lookup for "CreateFile" operations with "NAME NOT FOUND" Result and see Path column to find out what file is missing
In my case it was a failure on loading mono mscorlib.dll from lib\mono\4.5\mscorlib.dll so copying the files from the Mono installation to the path pointed by Process Monitor has helped.

gdbinit "no such file or directory" Eclipse c

I'm using Xming to connect to a Linux (enterprise edition) server on which I'm trying to debug a C++ project in Eclipse Galileo. The following errors occurred:
Reading symbols from ../workspace/myfile ..(no debugging symbols found) ... done.
.gdbinit : No such file or directory
Setting environment variable "LS_COLORS " to null value
(.gdbinit is on the server (in root), my account has rights)
If i try to run gmake on the same file from the terminal I get the following error :
gmake ** No rule to make target /workspace/myfile' . Stop.
//I have exported the path (including the library path), and gmake exists.
My project has 3 subprojects (proj1 , proj2 and proj 3). In order to debug proj3 I have to build projs 1 and 2 . I created make targets for projects 1 and 2, and I obtained .so files for which i made softlinks to corresponding files in my_project/libs folder.
My Eclipse debug configuration is as follows (tab order):
Main
  Project: My Project
  Build Configuration: UseActive
  C++ Application: path to my project/myproject
  Environment: path to libs on server (my user rights)
Debugger
  Debugger: gdb/mi
  (Checked) Stop startup at main
  GDB debugger: gdb
  GDB command line .gdbinit
  GDB command set: standard
  Protocol mi
Project Properties:
  Builders CDT Builder
  Scanner Configuration Builder
  C/C++ Build
  Build command gmake -k
Behaviour
  build incremental build : all ( sometimes i get the error no rule for make all)
  Clean: clean
  Discovery options:
    (Checked) Automatic discovery path
    (checked) Report path detection problems
    Discovery profile GCC per project
    (checked ) Enable build output
    Compile invocation comand gcc
    Toolchain
    No toolchain
    Correct builder GNU make builder
This Eclipse debug configuration works on another account (on the same server using the same Eclipse). The gdbinit and gmake files are on the server and work, I'm not supposed to update the versions (this was one solution I found online).
Has anyone seen this error before? Does anyone have a clue what I'm doing wrong?