Skip to content

LLDB debugging

Switch your build to debug

Locate C:\Program Files (x86)\Rational\Rose RealTime\C++\TargetRTS\libset\x86-clang-7.0\libset.mk. There is a possibility you already have a file named libset_RELEASE.mk there, then just rename it to libset.mk, and the original file to libset_DEBUG.mk. if not create file libset.mk with the following configuration.

# Licensed Materials - Property of MB (Author: Vinzenz Petr)

VENDOR = clang

# with an empty one --> shared libraries are not supported
SHLIBS =

LIBSETCCFLAGS = @"$(RTS_HOME)\libset\$(LIBRARY_SET)\CompilerArguments_DEBUG.rsp"

LIBSETCCEXTRA = -Wno-int-to-pointer-cast

LIBSETLDEXTRA = -s
#TARGETLDFLAGS = Rose lib ld flags

DEBUG_TAG = -ferror-limit=1 -Wno-tautological-compare -I "C:\BeckhoffSDKs\BeckhoffOS"

# see https://clang.llvm.org/docs/UsersManual.html
CC = $(LLVM_BIN)\\clang++.exe -target x86_64-pc-freebsd13 -isystem"$(SDK_BECKHOFFOS_INCLUDE)" --sysroot="$(SDK_BECKHOFFOS_SYSROOT)"

LD = $(LLVM_BIN)\\clang++.exe -fuse-ld=lld --verbose -g -target x86_64-pc-freebsd13 -lc++ -lcxxrt -lpthread -lm --sysroot="$(SDK_BECKHOFFOS_SYSROOT)" -L "$(LD_LIBRARY_PATH)"

AR_CMD        = $(PERL) "$(RTS_HOME)/tools/ar.pl" \
            -create=$(LLVM_BIN)\\llvm-ar.exe,rc \
            -add=$(LLVM_BIN)\\llvm-ar.exe,r \
            -ranlib=$(LLVM_BIN)\\llvm-ranlib.exe \
            -suffix=$(OBJ_EXT) \
            -limit=4000 \
            -debug

#not used but overwritten to be sure              
AS          = $(LLVM_BIN)\\clang++.exe -fuse-ld=lld -target x86_64-pc-freebsd13

#ALL_OBJS_LIST = $(ALL_OBJS_LISTFILE)
ALL_OBJS_LIST = \""$(ALL_OBJS)\""



EXEC_EXT      =
#LIB_PFX       = lib
LIB_PFX       = 
LIB_EXT       = .a
CPP_EXT       = .cc
OBJ_EXT       = .o
SHLIB_PFX     = lib
SHLIB_EXT     = .so

Locate core dump file

Copy the specific core dump file from Beckhoff located in /var/coredumps/NameOfYourApp_-0.core.zst to your simulation or if you have LLDB installed on your Beckhoff you can proceed from there. Put it in same folder as your BOS app.

Unzip core dump file with the following command.

doas unzstd NameOfYourApp_-0.core.zst

Load your file into lldb debugger.

doas lldb NameOfYourApp -c NameOfYourApp_-0.core

Use command bt the see backtrace of last function when application crashed.

bt