Libpurple can't connect - purple_presence_is_online failed - c++

I am writing myself a small jabber client. I have used code from Libpurple.com and on Linux (Mint) everything works fine. With libraries linked program compiles with no errors and receives messages.
But when I use the same code on Windows 7, link all neccessary libraries and with Cygwin installed and PATH set, program compiles with no errors, but then NetBeans (IDE I use in Windows and Linux) says 'RUN FAILED'
When I run program from windows command line it says:
libpurple initialized. Running version 2.10.7.
** <myclient.exe:6500>: CRITICAL **: purple_presence_is_online: assertion 'presence != NULL' failed
and then it freeze. I already tried going back to libpurple 2.10.3 (the version I have in Linux) but still the same. Turning firewall off did'n help either.

Few things to note:
Each OS has its own issues when a program is deployed. So, ignore the fact that your client is working in Linux. Start with the fact, that your program / libpurple didn't work in Windows.
Try to see if there is a client ( pidgin etc ) which uses the same code path ( the function where the assertion fails ), and succeeds. This is to do basic sanity check that the libpurple code is in fact usable in that environment ( Cygwin )
If there is any traffic between your client and the server, try getting a wireshark traffic dump, and compare it between working ( Linux ) and failing ( Cygwin ) environment.

Why not use a simple XMPP client library like GLOOX (http://camaya.net/gloox) instead of libPurple. GLOOX is a cross platform library that do not need CYGWIN on Windows to compile. And its complete, providing implementation for all the essentail XMPP estensions.
However, if you want to connect to other non-XMPP networks like Yahoo, Facebook, then libPurple will definitely is the answer.

Since your issue is hard to reproduce, I'd suggest you use the debugger to investigate where that "presence" pointer comes from, and which code block sets it to NULL. Then you could ask "why purple_stupid_function() returns a NULL pointer" which is much easier to answer.

The last time I looked at LibPurple (years ago) I could only get it working with MinGW, not Cygwin.

Related

Debug remotely on STM32CubeIDE with an STM32 eval board

I want to setup the following environment: I've got a STM32H753I-EVAL2 eval board, connected on a Windows PC. Until now I was developping and debugging locally on this PC with STM32CubeIDE. For several reasons my code source is on a Linux server (Samba mounting) so it takes forever to build a project. Hence I want to develop on the linux server from my Windows machine.
Compiling is working fine (and is way faster) but the issue is about debugging. I know it is possible to debug remotely, the Debug Configuration window from Eclipse (I'm using OpenOcd) allows to connect to a remote GDB server. What I don't know is how to start a GDB server on the Windows machine that will connect to the STM32 board ?
Sorry for the "answer to myself" but I think it might be useful for others (and even to me when I have forgotten in a few weeks ;) ).
Here is how to do.
on host side (on the machine where the eval board is physically plugged in) you have to manually launch the GDB server application that comes with STM32CubeIDE installation. See STMicro application note UM2576 for details. The default command line is:
ST-LINK_gdbserver.exe -d -v -cp "C:\ST\STM32CubeIDE_1.0.0.19w12patch\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_1.0.0.201903011553\tools\bin"
Now you've done the hardest. On server/remote side you have to setup the Debug Configuration to use OpenOcd with option "Connect to remote GDB server" and simply enter IP address and port number (which is not 3333 by default but 61234, but it can be modified).
This setup is working fine, even if I encoutered some instabilities during debugging once in a while.
I see two (maybe three) options
Use an alternate GDB server (see below)
Run the GDB server from STMCubeIDE in isolation (see OP's answer for Windows, this answer for Linux)
GDB Serial (not really an option right now but I'll share my experience so far)
I have used the second option to succesfully debug my target using arbitary GDBs such as gdb-multiarch command line and in the (non STMCube-ified) Eclipse CDT
Alternative GDB Servers
You could try STLink open source. I did. The problem is, your device might not be supported properly. I built 1.6.1 from Github to enable support for STM32G03x device. While moving to this version enabled it to detect the device, and I can use st-flash to program the device, the debugger is unusable (try and alter a register, it alters the wrong one, try and single step a program, it crashes immediately).
Do try it though .. it's easy and quick to install (or build), so it's worth checking if your device will work correctly with it.
Openocd is another option, but seems not to support SWD connection. I tried a build that allegedly had a patch for this but no luck.
If you can get one of these open source alternatives to work, they have another advantage, you may be able run them on something like a Raspberry PI, which means you don't have to get a PC physically close to your target.
Run the GDB server from STMCubeIDE in isolation
For Windows, see the OP's answer. For Linux, I do this alter the pathnames to suit your installation
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/apps/st/stm32cubeide_1.5.1/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_1.5.0.202011040924/tools/bin/native/linux_x64/ /home/user/apps/st/stm32cubeide_1.5.1/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_1.5.0.202011040924/tools/bin/ST-LINK_gdbserver -p 61234 -l 1 -d -s -cp /home/user/apps/st/stm32cubeide_1.5.1/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64_1.5.0.202011040924/tools/bin -m 0 -k
How did I get to this? Firstly launched a debugging session from STMCubeIDE, then ran
ps aux | grep gdbserver
Then we can see how Eclipse (STMCube) is launching the gdbserver and work from there.
If you find it complains about a .so file, locate that file from the STMCube installation and ensure the path to the directory containing it is in LD_LIBRARY_PATH (as per my example)
You can also launch the program with --help to show more options.
If add -e (persistent) you can disconnect and reconnect a GDB client without resetting the target (it will reset on initial invocation of the gdb server though, even without -k).
GDB Serial
This is where the target implements the GDB server end of the protocol. The GDB stub usually runs in an exception handler. This would usually be your breakpoint handler but you can also make it the default handler for unhandled exceptions, or, for example, the ctrl-c interrupt.
I have done a lot of Googling about this recently and basically when people ask about it on forums they usually get responses along the lines of "Here be dragons" or "Why don't you use JTAG?"
So the drivers for this, you might like to know, are in the GDB sources git://sourceware.org/git/binutils-gdb.git under gdb/stubs. The documentation is here. There isn't a stub implementation there for arm. Which is sad really, I used to use GDB remote serial regularly where I worked, and some of those targets were indeed ARM. The operating system was ecos.
So could ecos GDB stubs be ported to bare metal? Having giving it a good coat of looking at, I believe yes they could. The stubs are based on the ones from the GDB sources but they are heavily polluted with Ecos and Redboot build macros and copyright (the ogiringals were written by HP and released without copyright). We don't know what bugs the Ecos stubs may contain (I fixed at least one back in the day and I don't recall whether I submitted a patch). We don't know if they really support the latests architectures properly. And, we don't know if, after that, they simply use up too much memory - my STM32 has 8K of SRAM and I already see buffers that have a default size of 2K (not saying that's necessary but you see how work needs to be done here..)
So this third option, I will revisit this one day but for now, for me, it's a nope.

Problems with running the application using OpenSSL

Good day, colleagues. I'm building an application using OpenSSL - the application crashes with an error code: 0xc0000142.
The standard application openssl.exe also crashes with this error code. What could be the trouble?
According to Microsoft Support in KB 2701373:
This issue is caused by an error in the
Microsoft.powershell.consolehost.dll file. When a Windows PowerShell
script calls the Console.Write method, or when you run an executable
file for an application from a Windows PowerShell session, values are
written into the PowerShell console. Additionally, a corresponding
console handle is created. When many console handles are created, the
console handles leak, and the issue that is described in the
"Symptoms" section occurs.
There's also a question in the Microsoft Communities, CMD.EXE error 0xc0000142, and the answer appear to be "reinstall your application".
I'm not sure how MinGW affects the problem. Since MinGW is abandoned, I'm guessing its the problem and you likely won't be able to fix it. Its probably providing an old, buggy version of something with ABI problems.
Maybe you can use Cygwin for Linux on Windows. Cygwin is still actively developed and maintained.

Eclipse Remote Debugging CDT tutorial

TL;DR: is there a step by step tutorial to do remote code debugging using Eclipse Neon?
I have the source code in a Linux machine with a GCC dev environment. Normally, I ssh to the box, edit the file, and compile/debug using gdb, and it works, but it is a bit clunky for me.
I am now trying to debug the code from my Windows machine using the latest Eclipse version (Neon as of this writing).
I've tried following the instructions online (like this one), but they all seem to point towards (cross-)compiling the code locally, deploying it remotely and debugging there. This is not what I'm after. I essentially want to use Eclipse as a remote text editor+gdb interface, with the building and compiling being done in the remote system.
I've installed CDT, plus pretty much any plugin remotely related to remote development
Remote System Explorer
Remote Launch
GCC Cross compiler support
Remote (over TCF/TE) Run/Debug Launcher
Direct Remote C++ Debugging
TCF C/C++ Debugger
TM Terminal
So far, I can connect to the remote system, create a Remote Project and edit the source code.
I don't need Eclipse to compile the code (I can do that separately) but I'm unable to debug the code.
Using C/C++ Remote Application fails in many creative ways when trying to find gdb in the remote system.
Using GDB (DSF) Automatic Remote Debugging Launcher ends in a java.lang.NullPointerException, which also invalidates the configuration
Using Direct Remote Debugging Launcher asks about a remote workspace, then complains with "Error with command: gdb --version Cannot run program "gdb": Launching failed"
Remote Application complains about the Process/Image field. Setting it to the binary output doesn't enable the Debug button, so no dice.
TCF is dead in the water. It doesn't recognize the SSH connections I set up on RSE, it asks for the username password (I use public keys) and root password (?!) Even when entering that info, it fails to continue.
On a whim, I tried NetBeans, and followed the instructions here, and got it working in five minutes. The mode I'm following is the "Full Remote Development" according to NetBeans. The reason I'll still need to stick to Eclipse is that it is the dev environment that we use in the company, and it makes little sense to me to add another IDE to do something that Eclipse by all rights should do no problem.
What I find is that the walkthroughs for Eclipse I've found are either
Using plugins that are now either deprecated, not supported or have been completely reworked. Eclipse crashes and burns on these.
Trying to compile locally and deploy remotely, doing things like embedded even, but that's not what I'm looking for.
Using the Eclipse DStore client-server combo, which is essentially an alternative to SSH, but not what I'm looking for either.
I'm then hoping someone has written/found a tutorial that is relatively simple to follow (it is, after all, a relatively simple thing to do, as NetBeans has proven), and that works on any version of Eclipse.
I'll consider using an older version of Eclipse, but if so, please be specific in which version I should use, and which plugins I should install.

"Program File does not exist" while trying to debug with Eclipse/OpenOCD

I recently got a nrf51 bluetooth module and I am trying to debug it with Eclipse Mars. I installed the required toolchain as well as OpenOCD (I am using STLink v2 to debug the board).
While running openOCD and arm-none-eabi-gdb in console, everything works fine. The OpenOCD server starts up and I am able to connect with the gdb tool.
However, when trying to start a debug session with Eclipse, it throws the error "Exception occurred during launch. Reason: Program file does not exist". The build process finishes normally. It's the first time I used Eclipse for C/C++ development and the first time after years I used Eclipse at all so I don't even have an idea what could be wrong.
I tried messing around with the project settings without luck. Can anyone give me a hint?
I should mention, I used an already existing Makefile since I tried compiling one of the nordic SDK examples. I Changed it so the resulting files are ready for debugging.
In past I've used Segger's Jlink programmer and the JlinkExe (A pre-built binary) for Linux platform to program Nordic Bluetooth module such as NRF51 and it worked seamlessly. There are some very good documentation on using GNU toolchain with NRF51 series SOC and in case you get your hands on Segger's Jlink, I would recommend you to use that for programming. Meanwhile, this thread in the Nordic's developer zone seem to be very much similar to your problem. Maybe you'll be find some clues there.

Error STATUS_BAD_NETWORK_PATH when running qt executables through developer studio

I have searched and found no answer to this
I have a weird problem when running executables through developer studio (2008): a basic 'hello world' exe works OK when created through the usual dev studio project creation mechanism, but when trying to run a library based program the software crashes with STATUS_BAD_NETWORK_PATH. The program uses Qt and zlib behind the scenes and is written in C++, but (as far as I'm aware) is not dependent on any particular network locations on initialisation; we do have Sophos installed on the PC too.
The weird thing is that one cant even step into the main: the program fails well before this with the error. If we plug the network in, it starts up just fine ... The odd thing is this only occurs on a specific 64 bit Windows 7 machine.
Does anyone have any tips as to how to trace where the issue is? We've tried tracking using procmon but it is not very revealing; no obvious failures up to the point where the program crashes.
We have now figured out the answer. It transpired that there were 2 issues:
Firstly a wrapper .bat script that was launching developer studio was setting the PATH environment variable: a location in this path was being specified using a UNX style path (e.g. \\a\location\somewhere) rather than a mapped drive. The executables were not actually using this location but when the network was unplugged this it seems that this was disrupting things from dev studio
This, in tandem with a network configuration error on the PC, meant that deep down in the runes, something was failing.
So - advice if you see such an error
Check your PATH and make sure it is sensible
Look in your PC's configuration logs, and see if you can see any networking issues
...