Force a global variable using a specific register by Clang/LLVM - c++

I have the code as follows:
// global.cpp
int a = 5;
register unsigned b __asm("r9");
int test()
{
b = 4;
a++;
b = b + 7;
int c = a + b;
return c;
}
I run clang -target arm -c global.cpp -emit-llvm -o global.bc & llc -march=arm -filetype=asm global.bc -o -, but I get the following error:
.text
.syntax unified
.eabi_attribute 67, "2.09" # Tag_conformance
.eabi_attribute 6, 1 # Tag_CPU_arch
.eabi_attribute 8, 1 # Tag_ARM_ISA_use
.eabi_attribute 34, 1 # Tag_CPU_unaligned_access
.eabi_attribute 17, 1 # Tag_ABI_PCS_GOT_use
.eabi_attribute 20, 1 # Tag_ABI_FP_denormal
.eabi_attribute 21, 1 # Tag_ABI_FP_exceptions
.eabi_attribute 23, 3 # Tag_ABI_FP_number_model
.eabi_attribute 24, 1 # Tag_ABI_align_needed
.eabi_attribute 25, 1 # Tag_ABI_align_preserved
.eabi_attribute 38, 1 # Tag_ABI_FP_16bit_format
.eabi_attribute 18, 4 # Tag_ABI_PCS_wchar_t
.eabi_attribute 26, 2 # Tag_ABI_enum_size
.eabi_attribute 14, 0 # Tag_ABI_PCS_R9_use
.file "global.cpp"
LLVM ERROR: Invalid register name "r9".
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc -march=arm -filetype=asm global.bc -o -
1. Running pass 'Function Pass Manager' on module 'global.bc'.
2. Running pass 'ARM Instruction Selection' on function '#_Z4testv'
#0 0x00007f345d2fea1a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xb12a1a)
#1 0x00007f345d2fc7a4 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xb107a4)
#2 0x00007f345d2fc8f8 (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xb108f8)
#3 0x00007f345c39fde0 (/lib64/libc.so.6+0x38de0)
#4 0x00007f345c39fd61 raise (/lib64/libc.so.6+0x38d61)
#5 0x00007f345c389536 abort (/lib64/libc.so.6+0x22536)
#6 0x00007f345d2165e6 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xa2a5e6)
#7 0x00007f345f40b269 (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x2c1f269)
#8 0x00007f345dbb9000 llvm::SelectionDAGISel::Select_READ_REGISTER(llvm::SDNode*) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13cd000)
#9 0x00007f345dbbc52b llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13d052b)
#10 0x00007f345f3fcf21 (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x2c10f21)
#11 0x00007f345dbb85e8 llvm::SelectionDAGISel::DoInstructionSelection() (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13cc5e8)
#12 0x00007f345dbc11b5 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13d51b5)
#13 0x00007f345dbc4560 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13d8560)
#14 0x00007f345dbc7501 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x13db501)
#15 0x00007f345f406014 (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0x2c1a014)
#16 0x00007f345d6c949d (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xedd49d)
#17 0x00007f345d4503f8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xc643f8)
#18 0x00007f345d451971 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xc65971)
#19 0x00007f345d44f70b llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm/11/bin/../lib64/libLLVM-11.so+0xc6370b)
#20 0x000056232e849ef6 main (/usr/lib/llvm/11/bin/llc+0xeef6)
#21 0x00007f345c38ae6b __libc_start_main (/lib64/libc.so.6+0x23e6b)
#22 0x000056232e84a6ca _start (/usr/lib/llvm/11/bin/llc+0xf6ca)
Could anyone give me hints how to force global variable b to be stored in register r9 ?
My LLVM & Clang version: 11.0.0
Update:
I want to put a global variable to specific register (R9 in this example) since I am planning to port global register variables feature from ARM to my own back-end (I need global variables to be allocated in registers due to that no stack space for doing this). I just would like to confirm if this functionality can be used on ARM, so I could port this feature to my back-end.

"global variables in registers" is only supported for SP register on ARM. Patches are welcome :)

This post may not directly related to the question. But since I want to fix some global variables to corresponding registers on my own backed, I finally make it works by modifying LLVM via manipulating IR and writing the back-end. The details are as follows:
For the back-end, I refer to Tutorial: Creating an LLVM Backend for
the Cpu0 Architecture and remember to define the getRegisterByName function in XXXISelLowering.cpp.
For IR manipulation, I creating a pass to do that. Mainly, there are 3 steps:
Getting a list of global variable and its corresponding register (via cl:opt)
Iterating over each global variable:
Creating corresponding metadata (MDNode, NamedMDNode)
Initializing via module-level inline assembly (appendModuleInlineAsm)
Creating new instruction using corresponding metadata, which will be used to replace original users of global variable. Using IRBuilder might be easier to create new instruction to replace original one.
Replacing original global variable with corresponding metadata. Note that this step should be done outside the iteration since replacing might break iteration.
I also found that following references help me to learn LLVM:
Getting Started with LLVM Core Libraries
LLVM doxygen (Find the class you interested and look at what functions are provided)
Grep source code directly to learn how to use the class, functions, etc.

Related

Core Dump analysis with GDB - i2c library debugging

I have run mos debug-core-dump on my local machine to debug some code running on an ESP32 with Mongoose OS. This is part of the GDB output, possible to get some help interpreting it?
Dump contains FreeRTOS task info
Loaded core dump from last snippet in /core
0x40186bb9 in TwoWire::read (this=0x3ffb6d98 <Wire>)
at /home/harry/MOS/VersionJ_Mongoose/deps/arduino-wire/src/mgos_arduino_wire.cpp:133
133 return (pbyte_to_recv < recv_buf + n_bytes_avail) ? *pbyte_to_recv++ : -1;
#0 0x40186bb9 in TwoWire::read (this=0x3ffb6d98 <Wire>)
at /home/harry/MOS/VersionJ_Mongoose/deps/arduino-wire/src/mgos_arduino_wire---Type <return> to continue, or q <return> to quit---
.cpp:133
#1 0x400d72db in ACS71020::getRaw (this=0x3ffb4b14 <mySensor>,
reg_address=48 '0')
at /home/harry/MOS/VersionJ_Mongoose/src/ACS71020.cpp:115
#2 0x400d7496 in ACS71020::custom_en (this=0x3ffb4b14 <mySensor>)
at /home/harry/MOS/VersionJ_Mongoose/src/ACS71020.cpp:425
#3 0x400d9131 in mgos_app_init ()
at /home/harry/MOS/VersionJ_Mongoose/src/main.cpp:476
#4 0x400d3466 in mgos_init () at /mongoose-os/src/mgos_init.c:29
#5 0x400db5ba in mgos_init2 ()
at /home/harry/MOS/VersionJ_Mongoose/deps/freertos/src/mgos_freertos.c:169
#6 0x4008279b in mgos_task (arg=0x0)
at /home/harry/MOS/VersionJ_Mongoose/deps/freertos/src/mgos_freertos.c:180
here are a couple code snippets referenced (images to show line numbers):

Thrown exception never caught, but thread not killed?

This is happening on a Solaris sparc machine:
-bash-3.2$ uname -a
SunOS b2s-sol10spr-1 5.10 Generic_147147-26 sun4v sparc sun4v
I'm seeing a strange issue with exception handling. Here's a log of a short debugging session:
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./Touchstone_solaris64_iodbc...done.
(gdb) catch throw
Catchpoint 1 (throw)
(gdb) catch catch
Catchpoint 2 (catch)
(gdb) r
Starting program: /bamboo/mattheww/Touchstone_solaris64_iodbc -te Tests/Touchstone/SQL/SqlTestEnv_utf32.xml -ts Tests/Touchstone/SQL/SqlTestSuite.xml -o failure -rtn EXPECTEDFAILURES_QUERIESONLY-15
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
Simba Test Verbose Log Started on Fri Aug 17 12:51:50 2018
Starting test run
---------------------------
Touchstone test utility for ODBC and OLE DB for OLAP
Version: 4.5.0.5 (64-bit)
Copyright (c) 2018 Simba Technologies Incorporated
__BUILD_INFO__ built at __BUILD_TIME__
getpid=22056
[Switching to Thread 1 (LWP 1)]
Catchpoint 1 (exception thrown), __cxxabiv1::__cxa_throw (obj=0x101ec52f0, tinfo=0xffffffff7b8d0138 <typeinfo for Simba::SQLEngine::SESqlErrorException>, dest=
0xffffffff7a697850 <Simba::SQLEngine::SESqlErrorException::~SESqlErrorException()>) at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
65 /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc: No such file or directory.
(gdb) where
#0 __cxxabiv1::__cxa_throw (obj=0x101ec52f0, tinfo=0xffffffff7b8d0138 <typeinfo for Simba::SQLEngine::SESqlErrorException>, dest=0xffffffff7a697850 <Simba::SQLEngine::SESqlErrorException::~SESqlErrorException()>)
at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
#1 0xffffffff7a6f4188 in Simba::SQLEngine::AEScalarFnMetadataFactory::ValidateCotArgs (in_argument=0) at AEBuilder/Value/AEScalarFnMetadataFactory.cpp:2186
#2 0xffffffff7ab72d28 in Simba::SQLEngine::ETCotFn::RetrieveData (this=0x101db8ff0, io_dataRequest=...) at ETree/Value/ScalarFunctions/ETCotFn.cpp:37
#3 0xffffffff7a98c96c in Simba::SQLEngine::ETComparisonT<Simba::SQLEngine::ETEQFunctorT<double> >::GetLeftData (this=0x101db90f0) at Include/ETree/ETComparisonT.h:80
#4 0xffffffff7a976ac4 in Simba::SQLEngine::ETComparisonT<Simba::SQLEngine::ETEQFunctorT<double> >::Evaluate (this=0x101db90f0) at Include/ETree/ETComparisonT.h:104
#5 0xffffffff7a9c2510 in Simba::SQLEngine::ETSelect::DoMove (this=0x101ec53f0, in_moveRequest=...) at ETree/Relational/ETSelect.cpp:143
#6 0xffffffff7a8b4e18 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec53f0, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:352
#7 0xffffffff7a9b8c90 in Simba::SQLEngine::ETProject::DoMove (this=0x101ec5450, in_moveRequest=...) at ETree/Relational/ETProject.cpp:143
#8 0xffffffff7a8b4e18 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec5450, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:352
#9 0xffffffff7a8b4ae8 in Simba::SQLEngine::ETResultSet::Move (this=0x101dd6c40, in_direction=Simba::DSI::DSI_DIR_NEXT, in_offset=0) at ETResultSet.cpp:158
#10 0xffffffff7ad4f590 in Simba::ODBC::ForwardOnlyCursor::FetchRowset (this=0x101ec5650, in_orientation=1, in_offset=0, in_rowsetSize=1, in_ard=0x1014de6f0, in_rowStatusPtr=0x0, in_rowsProcessedPtr=0x0)
at Cursor/ForwardOnlyCursor.cpp:329
#11 0xffffffff7adc0c88 in Simba::ODBC::QueryManager::FetchRowset (this=0x101eb4810, in_orientation=1, in_offset=0, in_rowsetSize=1, in_rowStatusPtr=0x0, in_rowsProcessedPtr=0x0) at QueryManager/QueryManager.cpp:87
#12 0xffffffff7adf93a0 in Simba::ODBC::StatementStateCursor::DoFetchScroll (this=0x101b12280, in_fetchOrientation=1, in_fetchOffset=0) at Statement/StatementStateCursor.cpp:823
#13 0xffffffff7ae06f18 in Simba::ODBC::StatementState5::SQLFetch (this=0x101b12280) at Statement/StatementState5.cpp:74
#14 0xffffffff7add6f20 in Simba::ODBC::Statement::SQLFetch (this=0x101e63c30) at Statement/Statement.cpp:986
#15 0xffffffff7acb1610 in Simba::ODBC::SQLFetchTask::DoSynchronously (in_stmt=..., in_params=...) at CInterface/SQLFetchTask.h:73
#16 0xffffffff7acc5884 in DoTask<Simba::ODBC::SQLFetchTask> (in_functionName=0xffffffff7af8fcb0 "SQLFetch", in_handle=0x3, in_parameters=...) at CInterface/CInterface.cpp:679
#17 0xffffffff7ac9ab3c in SQLFetch (StatementHandle=0x3) at CInterface/CInterface.cpp:1693
#18 0xffffffff7d32a1f4 in SQLFetch_Internal (hstmt=0x101b04fb0) at fetch.c:161
#19 0xffffffff7d32a560 in SQLFetch (hstmt=0x101b04fb0) at fetch.c:230
#20 0x00000001001f7454 in Simba::ODBCTest::Cli::SqlFetch (this=0x10143a3b0 <Simba::ODBCTest::Singleton<Simba::ODBCTest::Cli>::m_instance>, handle=0x101b04fb0) at SimbaODBCTestFramework/Cli/Cli.cpp:1109
#21 0x00000001002c9c98 in Simba::ODBCTest::Statement::SqlFetch (this=0x101e640a0, outcome=..., callerFile=0x100df8af0 "TestCases/SQLTests/ODBCXmlResultTestsBase.cpp", callerLine=828) at SimbaODBCTestFramework/ODBC/Statement.cpp:200
#22 0x0000000100c9ae98 in Simba::ODBCTest::ODBCXmlResultTestsBase::Pimpl::ValidateRows (this=0x1014e0640, test=..., xmlResult=0x1014df050) at TestCases/SQLTests/ODBCXmlResultTestsBase.cpp:828
#23 0x0000000100c96a94 in Simba::ODBCTest::ODBCXmlResultTestsBase::DoResultValidation (this=0x1018fc800, test=..., xmlFileName=..., expectedFileName=..., queryFileName=...) at TestCases/SQLTests/ODBCXmlResultTestsBase.cpp:504
#24 0x0000000100ca5ca4 in Simba::ODBCTest::ODBCXmlSimpleResultTestsBase::executeTest (this=0x1018fc800) at TestCases/SQLTests/ODBCXmlSimpleResultTestsBase.cpp:215
#25 0x0000000100ca8478 in Simba::Test::Case::runTest (this=0x1018fc800, runId=...) at TestFrameworkLibrary/SBTCase.cpp:180
#26 0x0000000100cb3b58 in Simba::Test::Engine::runTest (this=0xffffffff7ffff2a0, test=0x1018fc800) at TestFrameworkLibrary/SBTEngine.cpp:219
#27 0x0000000100cb3368 in Simba::Test::Engine::RunTests (this=0xffffffff7ffff2a0, testEnv=0x1014dfed0, loopCount=1) at TestFrameworkLibrary/SBTEngine.cpp:186
#28 0x00000001001f2090 in (anonymous namespace)::DoMain (argc=9, argv=0xffffffff7ffff898) at Main.cpp:557
#29 0x00000001001f256c in main (argc=9, argv=0xffffffff7ffff898) at Main.cpp:581
(gdb) cont
Continuing.
Catchpoint 1 (exception thrown), __cxxabiv1::__cxa_throw (obj=0x101ff73b0, tinfo=0x1013b9960 <typeinfo for Simba::Test::ValueMismatchException>, dest=0x100ce4e34 <Simba::Test::ValueMismatchException::~ValueMismatchException()>)
at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
65 in /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc
(gdb) where
#0 __cxxabiv1::__cxa_throw (obj=0x101ff73b0, tinfo=0x1013b9960 <typeinfo for Simba::Test::ValueMismatchException>, dest=0x100ce4e34 <Simba::Test::ValueMismatchException::~ValueMismatchException()>)
at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
#1 0x0000000100ce4f28 in Simba::Test::ValueMismatchException::raise (this=0xffffffff7fffdd38) at TestFrameworkLibrary/Exceptions/SBTValueMismatchException.cpp:28
#2 0x000000010029e524 in Simba::ODBCTest::RaiseMismatchException (msg=...) at SimbaODBCTestFramework/Framework/VerifyValues.h:29
#3 0x000000010033c3d4 in Simba::ODBCTest::VerifyAndThrowComparator<Simba::ODBCTest::Comparator<short> > (comparator=..., msg=..., callerFile=0x100df8af0 "TestCases/SQLTests/ODBCXmlResultTestsBase.cpp", callerLine=888)
at SimbaODBCTestFramework/Framework/VerifyValues.h:227
#4 0x000000010033c1b0 in Simba::ODBCTest::VerifyAndThrow<short> (expected=#0xffffffff7fffe34e: 1, actual=#0xffffffff7fffe396: 100, msg=..., callerFile=0x100df8af0 "TestCases/SQLTests/ODBCXmlResultTestsBase.cpp", callerLine=888)
at SimbaODBCTestFramework/Framework/VerifyValues.h:251
#5 0x0000000100c9b450 in Simba::ODBCTest::ODBCXmlResultTestsBase::Pimpl::ValidateRows (this=0x1014e0640, test=..., xmlResult=0x1014df050) at TestCases/SQLTests/ODBCXmlResultTestsBase.cpp:888
#6 0x0000000100c96a94 in Simba::ODBCTest::ODBCXmlResultTestsBase::DoResultValidation (this=0x1018fc800, test=..., xmlFileName=..., expectedFileName=..., queryFileName=...) at TestCases/SQLTests/ODBCXmlResultTestsBase.cpp:504
#7 0x0000000100ca5ca4 in Simba::ODBCTest::ODBCXmlSimpleResultTestsBase::executeTest (this=0x1018fc800) at TestCases/SQLTests/ODBCXmlSimpleResultTestsBase.cpp:215
#8 0x0000000100ca8478 in Simba::Test::Case::runTest (this=0x1018fc800, runId=...) at TestFrameworkLibrary/SBTCase.cpp:180
#9 0x0000000100cb3b58 in Simba::Test::Engine::runTest (this=0xffffffff7ffff2a0, test=0x1018fc800) at TestFrameworkLibrary/SBTEngine.cpp:219
#10 0x0000000100cb3368 in Simba::Test::Engine::RunTests (this=0xffffffff7ffff2a0, testEnv=0x1014dfed0, loopCount=1) at TestFrameworkLibrary/SBTEngine.cpp:186
#11 0x00000001001f2090 in (anonymous namespace)::DoMain (argc=9, argv=0xffffffff7ffff898) at Main.cpp:557
#12 0x00000001001f256c in main (argc=9, argv=0xffffffff7ffff898) at Main.cpp:581
(gdb) cont
Continuing.
Catchpoint 2 (exception caught), __cxxabiv1::__cxa_begin_catch (exc_obj_in=0x101ff7390) at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_catch.cc:41
41 /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_catch.cc: No such file or directory.
(gdb) where
#0 __cxxabiv1::__cxa_begin_catch (exc_obj_in=0x101ff7390) at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_catch.cc:41
#1 0x0000000100ca8774 in Simba::Test::Case::runTest (this=0x1018fc800, runId=...) at TestFrameworkLibrary/SBTCase.cpp:183
#2 0x0000000100cb3b58 in Simba::Test::Engine::runTest (this=0xffffffff7ffff2a0, test=0x1018fc800) at TestFrameworkLibrary/SBTEngine.cpp:219
#3 0x0000000100cb3368 in Simba::Test::Engine::RunTests (this=0xffffffff7ffff2a0, testEnv=0x1014dfed0, loopCount=1) at TestFrameworkLibrary/SBTEngine.cpp:186
#4 0x00000001001f2090 in (anonymous namespace)::DoMain (argc=9, argv=0xffffffff7ffff898) at Main.cpp:557
#5 0x00000001001f256c in main (argc=9, argv=0xffffffff7ffff898) at Main.cpp:581
(gdb) info share
From To Syms Read Shared Object Library
0xffffffff7f606ca0 0xffffffff7f634270 Yes (*) /usr/lib/sparcv9/ld.so.1
Yes (*) /bamboo/mattheww/icu-53.1.x/release64/lib//libicudata_sb64.so.53
0xffffffff7d8e00e8 0xffffffff7da07e0c Yes (*) /bamboo/mattheww/icu-53.1.x/release64/lib//libicui18n_sb64.so.53
0xffffffff7d56a798 0xffffffff7d62c31c Yes (*) /bamboo/mattheww/icu-53.1.x/release64/lib//libicuuc_sb64.so.53
Yes (*) /lib/64/libpthread.so.1
0xffffffff7d30f8b0 0xffffffff7d377994 Yes /usr/local/odbc/dm/iodbc-3.52.8_gcc/64/debug/lib//libiodbc.so.2
0xffffffff7d104fe0 0xffffffff7d10cc20 Yes (*) /lib/64/libsocket.so.1
0xffffffff7cf22340 0xffffffff7cf9e350 Yes (*) /lib/64/libnsl.so.1
0xffffffff7cca9d38 0xffffffff7cd4a6a8 Yes /opt/csw/lib/64/libstdc++.so.6
0xffffffff7ca0b080 0xffffffff7ca7b7a8 Yes (*) /lib/64/libm.so.2
0xffffffff7c802d68 0xffffffff7c806000 Yes (*) /lib/64/librt.so.1
0xffffffff7c602ef8 0xffffffff7c610028 Yes /opt/csw/lib/64/libgcc_s.so.1
0xffffffff7c32ed60 0xffffffff7c3dd4b0 Yes (*) /lib/64/libc.so.1
Yes (*) /lib/64/libdl.so.1
0xffffffff7bf02328 0xffffffff7bf09b38 Yes /usr/sfw/lib/64/libgcc_s.so.1
0xffffffff7bd01e60 0xffffffff7bd076ac Yes (*) /lib/64/libaio.so.1
0xffffffff7bb008a0 0xffffffff7bb0c880 Yes (*) /lib/64/libmd.so.1
0xffffffff7c000460 0xffffffff7c00137c Yes (*) /platform/sun4v/lib/sparcv9/libc_psr.so.1
0xffffffff79dece38 0xffffffff7ae0d3ec Yes /bamboo/mattheww/DRIVER
0xffffffff796009b8 0xffffffff7960c840 Yes (*) /platform/sun4v/lib/sparcv9/libmd_psr.so.1
0xffffffff79400bb0 0xffffffff79402bb0 Yes (*) /lib/64/libmp.so.2
0xffffffff79207690 0xffffffff79217630 Yes (*) /lib/64/libscf.so.1
0xffffffff79001358 0xffffffff79002008 Yes (*) /lib/64/libdoor.so.1
0xffffffff78e02518 0xffffffff78e06c58 Yes (*) /lib/64/libuutil.so.1
0xffffffff78c01f08 0xffffffff78c06104 Yes (*) /lib/64/libgen.so.1
0xffffffff78a03030 0xffffffff78a21078 Yes /usr/local/odbc/dm/iodbc-3.52.8_gcc/64/debug/lib//libiodbcinst.so
(*): Shared library is missing debugging information.
(gdb) quit
After the first exception is thrown, frame 14 has a catch block for a base class of SESqlErrorException, so it should be caught there (and there are no intervening catch blocks that should). Yet, gdb's catch catch fails to break.
Also, the thread/process isn't killed; instead it seems like execution continues somehow (without causing any other problems) until we return into the main binary (frame 20 after the initial throw). I'm still not sure exactly where execution continues after the throw, will need to look into that later.
But, it seems that exception handling is working in the main binary, as we break when the main binary throws & catches an exception.
I don't have it in the log above, but I've noticed that the address of the instruction it breaks on when throwing the exception (i.e __cxxabiv1::__cxa_begin_catch) is actually slightly outside of the memory range that info share shows for libstdc++.so.6. How do I interpret that? I was looking at that, because earlier I had noticed that we had incorrectly built libicui18n_sb64.so.53 to be statically-linked with the C++ runtime, and when this issue occurred, the instruction doing the throw was (as far as I could tell, again it was a little outside of the info share range, but not in any other library's range) in libicui18n_sb64.so.53. I thought this was the source of the issue (throwing an exception using code from one copy of the runtime, so it wouldn't be caught by another copy), but fixing that library didn't make the issue go away.
Something else I noticed was that it claims that __cxxabiv1::__cxa_throw comes from /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65, which makes me a bit suspicious since we compiled everything with gcc 4.9, but not sure if that's an issue.
Here's some information about the dependencies of all the libraries/binaries in the callstack:
Dependencies for /bamboo/mattheww/icu-53.1.x/release64/lib//libicui18n_sb64.so.53:
libicuuc_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicuuc_sb64.so.53
libicudata_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicudata_sb64.so.53
libpthread.so.1 => /lib/64/libpthread.so.1
libstdc++.so.6 => /opt/csw/lib/64/libstdc++.so.6
libm.so.2 => /lib/64/libm.so.2
librt.so.1 => /lib/64/librt.so.1
libgcc_s.so.1 => /opt/csw/lib/64/libgcc_s.so.1
libc.so.1 => /lib/64/libc.so.1
libaio.so.1 => /lib/64/libaio.so.1
libmd.so.1 => /lib/64/libmd.so.1
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
/platform/sun4v/lib/sparcv9/libmd_psr.so.1
Dependencies for /bamboo/mattheww/icu-53.1.x/release64/lib//libicuuc_sb64.so.53:
libicudata_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicudata_sb64.so.53
libpthread.so.1 => /lib/64/libpthread.so.1
libstdc++.so.6 => /opt/csw/lib/64/libstdc++.so.6
libm.so.2 => /lib/64/libm.so.2
librt.so.1 => /lib/64/librt.so.1
libgcc_s.so.1 => /opt/csw/lib/64/libgcc_s.so.1
libc.so.1 => /lib/64/libc.so.1
libaio.so.1 => /lib/64/libaio.so.1
libmd.so.1 => /lib/64/libmd.so.1
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
/platform/sun4v/lib/sparcv9/libmd_psr.so.1
Dependencies for /usr/local/odbc/dm/iodbc-3.52.8_gcc/64/debug/lib//libiodbc.so.2:
libdl.so.1 => /lib/64/libdl.so.1
libc.so.1 => /lib/64/libc.so.1
libgcc_s.so.1 => /usr/sfw/lib/64/libgcc_s.so.1
libm.so.2 => /lib/64/libm.so.2
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
Dependencies for /bamboo/mattheww/DRIVER:
libstdc++.so.6 => /opt/csw/lib/64/libstdc++.so.6
libicudata_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicudata_sb64.so.53
libicui18n_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicui18n_sb64.so.53
libicuuc_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicuuc_sb64.so.53
libpthread.so.1 => /lib/64/libpthread.so.1
libsocket.so.1 => /lib/64/libsocket.so.1
libnsl.so.1 => /lib/64/libnsl.so.1
libm.so.2 => /lib/64/libm.so.2
librt.so.1 => /lib/64/librt.so.1
libgcc_s.so.1 => /opt/csw/lib/64/libgcc_s.so.1
libc.so.1 => /lib/64/libc.so.1
libmp.so.2 => /lib/64/libmp.so.2
libmd.so.1 => /lib/64/libmd.so.1
libscf.so.1 => /lib/64/libscf.so.1
libaio.so.1 => /lib/64/libaio.so.1
libdoor.so.1 => /lib/64/libdoor.so.1
libuutil.so.1 => /lib/64/libuutil.so.1
libgen.so.1 => /lib/64/libgen.so.1
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
/platform/sun4v/lib/sparcv9/libmd_psr.so.1
Dependencies for ./Touchstone_solaris64_iodbc:
libicudata_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicudata_sb64.so.53
libicui18n_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicui18n_sb64.so.53
libicuuc_sb64.so.53 => /bamboo/mattheww/icu-53.1.x/release64/lib//libicuuc_sb64.so.53
libpthread.so.1 => /lib/64/libpthread.so.1
libiodbc.so.2 => /usr/local/odbc/dm/iodbc-3.52.8_gcc/64/debug/lib//libiodbc.so.2
libsocket.so.1 => /lib/64/libsocket.so.1
libnsl.so.1 => /lib/64/libnsl.so.1
libstdc++.so.6 => /opt/csw/lib/64/libstdc++.so.6
libm.so.2 => /lib/64/libm.so.2
librt.so.1 => /lib/64/librt.so.1
libgcc_s.so.1 => /opt/csw/lib/64/libgcc_s.so.1
libc.so.1 => /lib/64/libc.so.1
libdl.so.1 => /lib/64/libdl.so.1
libgcc_s.so.1 => /usr/sfw/lib/64/libgcc_s.so.1
libmp.so.2 => /lib/64/libmp.so.2
libmd.so.1 => /lib/64/libmd.so.1
libscf.so.1 => /lib/64/libscf.so.1
libaio.so.1 => /lib/64/libaio.so.1
libdoor.so.1 => /lib/64/libdoor.so.1
libuutil.so.1 => /lib/64/libuutil.so.1
libgen.so.1 => /lib/64/libgen.so.1
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
/platform/sun4v/lib/sparcv9/libmd_psr.so.1
They all depend on /opt/csw/lib/64/libstdc++.so.6 & /opt/csw/lib/64/libgcc_s.so.1, I'm not sure if any other libraries would be relevant w.r.t. exception handling? (I've read about/seen issues when mixing gcc & 'native' runtimes, but I don't think that's happening here?)
Here's how the library (/bamboo/mattheww/DRIVER) was built:
Example command for compiling one of the .cpp files (I removed a bunch of include directories)
/opt/csw/gcc4/bin/g++ -DSIZEOF_LONG_INT=8 -DSQL_WCHART_CONVERT -DHAVE_MEMMOVE -m64 -fPIC -pthread -Wall -Wno-unknown-pragmas -DSIMBA -D_REENTRANT -DCLUNIX -DNDEBUG -D_POSIX_PTHREAD_SEMANTICS -O0 -g -D_DEBUG -c Common/QSTableMetadataFile.cpp -o Common/QSTableMetadataFile_solaris10sparc_gcc4_9_debug64.cpp.o
Command used to link (removed a bunch of .o files)
/opt/csw/gcc4/bin/g++ -DSIMBA -D_REENTRANT -m64 -fPIC -pthread -Wall -Wno-unknown-pragmas -lrt -O0 -g -shared -L/bamboo/bamboo-agent-home/xml-data/build-dir/ThirdParty/icu/53.1.x/solaris10sparc/gcc4_9/release64/lib -lstdc++ -licudata_sb64 -licui18n_sb64 -licuuc_sb64 -lpthread -lm -lsocket -lnsl -Wl,-M,exports_SunOS.map -Wl,-zallextract,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libSimbaDSI.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libSimbaSupport.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libAEProcessor.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libCore.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libDSIExt.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libExecutor.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libParser.a,/bamboo/bamboo-agent-home/xml-data/build-dir/SimbaEngine/Maintenance/10.1/Product/Lib/solaris10sparc/gcc4_9/debug64/libSimbaODBC.a -Wl,-zweakextract -o ../Bin/solaris10sparc/gcc4_9/debug64/libQuickstart64.so
Another thing to mention is that this happens in 64-bit, but not 32-bit. Originally, the 32-bit version of libicui18n_sb64.so.53 had been dynamically-linked to the runtime, while libicui18n_sb64.so.53 hadn't, so I thought that difference was the cause, but it didn't change the observed behaviour.
edit:
(gdb) where
#0 __cxxabiv1::__cxa_throw (obj=0x101ec52f0, tinfo=0xffffffff7b8d0138 <typeinfo for Simba::SQLEngine::SESqlErrorException>, dest=0xffffffff7a697850 <Simba::SQLEngine::SESqlErrorException::~SESqlErrorException()>)
at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
#1 0xffffffff7a6f4188 in Simba::SQLEngine::AEScalarFnMetadataFactory::ValidateCotArgs (in_argument=0) at AEBuilder/Value/AEScalarFnMetadataFactory.cpp:2186
#2 0xffffffff7ab72d28 in Simba::SQLEngine::ETCotFn::RetrieveData (this=0x101db8ff0, io_dataRequest=...) at ETree/Value/ScalarFunctions/ETCotFn.cpp:37
#3 0xffffffff7a98c96c in Simba::SQLEngine::ETComparisonT<Simba::SQLEngine::ETEQFunctorT<double> >::GetLeftData (this=0x101db90f0) at Include/ETree/ETComparisonT.h:80
#4 0xffffffff7a976ac4 in Simba::SQLEngine::ETComparisonT<Simba::SQLEngine::ETEQFunctorT<double> >::Evaluate (this=0x101db90f0) at Include/ETree/ETComparisonT.h:104
#5 0xffffffff7a9c2510 in Simba::SQLEngine::ETSelect::DoMove (this=0x101ec53f0, in_moveRequest=...) at ETree/Relational/ETSelect.cpp:143
#6 0xffffffff7a8b4e18 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec53f0, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:352
#7 0xffffffff7a9b8c90 in Simba::SQLEngine::ETProject::DoMove (this=0x101ec5450, in_moveRequest=...) at ETree/Relational/ETProject.cpp:143
#8 0xffffffff7a8b4e18 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec5450, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:352
#9 0xffffffff7a8b4ae8 in Simba::SQLEngine::ETResultSet::Move (this=0x101dd6c40, in_direction=Simba::DSI::DSI_DIR_NEXT, in_offset=0) at ETResultSet.cpp:158
<Snipped as this post is now too long>
(gdb) fin
Run till exit from #0 __cxxabiv1::__cxa_throw (obj=0x101ec52f0, tinfo=0xffffffff7b8d0138 <typeinfo for Simba::SQLEngine::SESqlErrorException>, dest=0xffffffff7a697850 <Simba::SQLEngine::SESqlErrorException::~SESqlErrorException()>)
at /home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/libstdc++-v3/libsupc++/eh_throw.cc:65
0xffffffff7a8b4e38 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec5450, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:357
357 ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h: No such file or directory.
(gdb) where
#0 0xffffffff7a8b4e38 in Simba::SQLEngine::ETRelationalExpr::Move (this=0x101ec5450, in_moveRequest=...) at ../../../Include/SQLEngine/Executor/ETree/ETRelationalExpr.h:357
#1 0xffffffff7a8b4ae8 in Simba::SQLEngine::ETResultSet::Move (this=0x101dd6c40, in_direction=Simba::DSI::DSI_DIR_NEXT, in_offset=0) at ETResultSet.cpp:158
<Snipped as this post is now too long>
(gdb)
I'm not sure what exactly it means to do a fin in GDB when the exception handling machinery is about to unwind the stack, but it's back in the non-exceptional flow of code, without the exception being caught...
Edit:
I've uploaded a zip file containing two binaries, one that works and one that doesn't (when I rebuild myself, it works, when our automated build system does, it doesn't): https://simba.app.box.com/s/qzo8735h9nzyv6t4x2lhzze896v361t1
You can reproduce the issue with iodbctest using a connection string like
DRIVER=<path to driver>;DBF=<path to DBF directory>
and executing the query
select dbl_zero from trig where COT(dbl_zero) = dbl_zero
Also, I dissassembled both the function throwing the exception, and the function which should catch that exception, in both binaries, and they were they same (other than some constants which I assume corresponded to different addresses).
Edit:
I've created logs of when the test is run, with both working & broken binaries, using LD_DEBUG=bindings: https://simba.box.com/s/w5y246hb4ydm97krjeyjykc90zvjqfo3
I've noticed a few differences, but not sure exactly how to interpret them

How to identify the full command that caused the crash from the core dump file

There is a problem to identify the full command from the core dump file using gdb
The crashed command itself can be long
i.e.
myCommand -f log/SlaRunTimeReport.rep -I input/myFile.txt -t output/myFile.txt
But When using gdb to identify the command in the location “Core was generated by”
i.e. by executing
gdb -c core.56536
The Output:
GNU gdb (GDB) Red Hat Enterprise Linux 7.10-20.el7
….
Core was generated by `myCommand -f log/SlaRunTimeReport.rep -I
input/myFile.t'.
It is possible to see that the full command(executable + parameters) was cut in the middle
‘myCommand -f log/SlaRunTimeReport.rep -I input/myFile.t'
In additional using strings command , also did not help to identify the full command
strings core.56536 | grep PMRunTimeReport
The Output:
myCommand
myCommand -f log/SlaRunTimeReport.rep -I input/myFile.t
Is there any way to get from coredump file the full command that caused the failure
Thanks in Advance
Is there any way to get from coredump file the full command that caused the failure
There are multiple ways, but running strings is the wrong way.
IF you built your program with debug info, you should be able to simply execute up command until you reach main, then examine argv[0] through argv[argc-1].
If your main was not built with debug info, or if it doesn't use argc and argv, you should be able to recover that info from __libc_argc and __libc_argv variables. Example:
$ ./a.out foo bar baz $(python -c 'print "a" * 500')
Aborted (core dumped)
$ gdb -q ./a.out core
Core was generated by `./a.out foo bar baz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.
Note that the "generated by" is truncated -- it comes from a fixed length array inside of struct prpsinfo, saved in NT_PRPSINFO ELF note in the core.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fab38cfcf2b in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.27-15.fc28.x86_64
(gdb) p (int)__libc_argc
$1 = 5
(gdb) p ((char**)__libc_argv)[0]#5
$2 = {0x7ffede43289f "./a.out", 0x7ffede4328a7 "foo", 0x7ffede4328ab "bar",
0x7ffede4328af "baz",
0x7ffede4328b3 'a' <repeats 200 times>...}
This last line is actually a lie -- we know that 'a' repeats 500 times.
We can fix it like so:
(gdb) set print elem 0
(gdb) p ((char**)__libc_argv)[0]#5
$3 = {0x7ffede43289f "./a.out", 0x7ffede4328a7 "foo", 0x7ffede4328ab "bar",
0x7ffede4328af "baz",
0x7ffede4328b3 'a' <repeats 500 times>}
Voila: we now have the complete command.
Lastly, if you install debug info for GLIBC, you can simply look in the __libc_start_main (which called your main):
(gdb) set backtrace past-main
(gdb) bt
#0 __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007fab38ce7561 in __GI_abort () at abort.c:79
#2 0x00000000004004ef in main () at foo.c:3
#3 0x00007fab38ce918b in __libc_start_main (main=0x4004e6 <main>, argc=5, argv=0x7ffede431118,
init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffede431108)
at ../csu/libc-start.c:308
#4 0x000000000040042a in _start ()
Here you can clearly see argc and argv in frame 3, and can examine that argv like so:
(gdb) fr 3
#3 0x00007fab38ce918b in __libc_start_main (main=0x4004e6 <main>, argc=5, argv=0x7ffede431118,
init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffede431108)
at ../csu/libc-start.c:308
308 result = main (argc, argv, __environ MAIN_AUXVEC_PARAM);
(gdb) p argv[0]#5
$1 = {0x7ffede43289f "./a.out", 0x7ffede4328a7 "foo", 0x7ffede4328ab "bar",
0x7ffede4328af "baz",
0x7ffede4328b3 'a' <repeats 500 times>}

core dump in basic_string.tcc - optimized out

Occasionally I experience some core dumps which i can't figure out why they happen. Typically this happens when assigning av value to a string. Below is the backtrace for one of this cases. A core dump seems to be caused by this line in my c++ code:
m_strValue = "---";
I can't figure out what is going on in this case and I home someone can shed some light over this issue.
Below is the backtrace
#0 0x40227ed4 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67
#1 0x402293d0 in *__GI_abort () at abort.c:92
#2 0x4011a594 in __gnu_cxx::__verbose_terminate_handler () at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3/libstdc++-v3/libsupc++/vterminate.cc:93
#3 0x40118770 in __cxxabiv1::__terminate (handler=<optimized out>) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3/libstdc++-v3/libsupc++/eh_terminate.cc:39
#4 0x40118798 in std::terminate () at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3/libstdc++-v3/libsupc++/eh_terminate.cc:49
#5 0x40118914 in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=<optimized out>, dest=<optimized out>) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3/libstdc++-v3/libsupc++/eh_throw.cc:83
#6 0x400c8de8 in std::__throw_length_error (__s=<optimized out>) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3/libstdc++-v3/src/functexcept.cc:74
#7 0x400fe02c in std::string::_Rep::_S_create (__capacity=4294967293, __old_capacity=<optimized out>, __alloc=<optimized out>) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3-stage3/armv5l-linux-gnueabi/libstdc++-v3/include/bits/basic_string.tcc:552
#8 0x400fe260 in std::string::_M_mutate (this=0x7d3d78, __pos=0, __len1=9, __len2=3) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3-stage3/armv5l-linux-gnueabi/libstdc++-v3/include/bits/basic_string.tcc:479
#9 0x400fe3fc in std::string::_M_replace_safe (this=0x7d3d78, __pos1=0, __n1=<optimized out>, __s=0x62d708 "---", __n2=3) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3-stage3/armv5l-linux-gnueabi/libstdc++-v3/include/bits/basic_string.tcc:684
#10 0x400fe48c in std::string::assign (this=0x7d3d78, __s=<optimized out>, __n=3) at /home/habbjack/ssd/workspace/builder2/build_armv5l-linux-gnueabi/gcc-4.5.3/gcc-4.5.3-stage3/armv5l-linux-gnueabi/libstdc++-v3/include/bits/basic_string.tcc:264
#11 0x0026175c in CLCD_Wnd::Refresh (this=0x7d3d60) at ../../lib/src/HAL/LCD/CLCD_Wnd.cpp:49
Line 7 show creation with capacity=4294967293 followed immediately by throw_length_error.
Plus, your object at line 11 is only 24 bytes away from your string, which may indicate some kind of allocation problem if CLCD_Wnd needs more space than that.
Almost certainly m_strValue or its containing object no longer exists (deleted or went out of scope). It's impossible to say without more code but if you're on Linux valgrind can help you out.

How to backtrace how main's called with gdb?

Inside the main,is there any command to show how's it invoked?
This might be what you're looking for, if I get the question right:
(gdb) help set backtrace past-main
Set whether backtraces should continue past "main".
Normally the caller of "main" is not of interest, so GDB will terminate
the backtrace at "main". Set this variable if you need to see the rest
of the stack trace.
so if you set it to on (and the debug info for the libc are available, cf. this anwser), you'll see a stack looking like that:
(gdb) where
#0 main () at ./functionPtr.c:8
#1 0x0000003c47e2139d in __libc_start_main (main=0x40052b <main>, argc=1, ubp_av=0x7fffffffde28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde18) at libc-start.c:226
#2 0x0000000000400449 in _start ()
with the surrounding libc-start.c code looking like that:
struct pthread *self = THREAD_SELF;
/* Store old info. */
unwind_buf.priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
unwind_buf.priv.data.cleanup = THREAD_GETMEM (self, cleanup);
/* Store the new cleanup handler info. */
THREAD_SETMEM (self, cleanup_jmp_buf, &unwind_buf);
/* Run the program. */
result = main (argc, argv, __environ MAIN_AUXVEC_PARAM);