Page 1 of 1

trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 6:50 am
by petah
Hi Eran,

I'd like to break to LLDB when my code throws an exception, is there a way to automatically do that like with GDB? if not is there a signal or exception I can call from my code to do so? I already have exception handlers in place so the latter would be just fine.

I realize GDB is more mature than LLDB but I'm occasionally testing libc++ on Linux (with libcxxrt).

thx a lot & cheers,

-- p

Re: trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 8:02 am
by eranif
Have you tried adding this to your code:

Code: Select all

raise(SIGTRAP)
Eran

Re: trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 10:06 am
by petah
it works with libstdc++ (clang and gcc) but with libc++/LLDB it freezes silently with CL's UI looking like it was about to enter the debugger. I tried both in wxApp::OnInit() and on a menu event later.

How can I ensure that CL's codelite-lldb gets called? I added the direct path to the project's settings, under debugger path, but it's still picking up mine over yours, i.e. I have a "locals" window title instead of "locals & watches" as I see in CL's source.

thx!

-- p

Re: trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 10:11 am
by eranif
petah wrote:I have a "locals" window title instead of "locals & watches" as I see in CL's source.
This is because you still have the old perspectives kept (wx keeps the frame title in it...)
petah wrote:it works with libstdc++ (clang and gcc) but with libc++/LLDB it freezes silently with CL's UI looking like it was about to enter the debugger. I tried both in wxApp::OnInit() and on a menu event later
I will need to debug this

Eran

Re: trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 10:30 am
by petah
ok it's possible that my libc6 has a problem but to exclude wx, I just tried this minimal sample

Code: Select all

#include <string>
#include <cassert>
#include <iostream>
#include <regex>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <stdexcept>
#include <csignal>

using namespace std;
using namespace chrono;

int main()
{
	string	s = "vanilla\n ";
	
	regex	re("[0-9]+");
	
	bool	f = regex_match("12300", re);
	
	cerr << s << (f ? "std::regex match" : "nope on regex") << endl << flush;
	
	const auto	ms = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
	
	const double	ms_d = ms;
	
	cerr << "chrono: elapsed ms " << ms_d << " since epoch" << endl;
	
	unordered_set<string>	test_set = {"un", "deux", "cinq"};
	bool	f1 = (test_set.count("deux") > 0);
	bool	not_f2 = (test_set.count("truete") > 0);
	
	cerr << "hashset: entry " << (f1 ? "ok" : "FAIL") << "... not entry: "<< (not_f2 ? "FAIL" : "ok") << "... (rastaman done)" << endl;
	
	unordered_map<string, int>	test_map = {{"trois", 3}, {"neuf", 9}};

	cerr << "hashmap: entries " << (test_map["trois"]) << "... " << (test_map["neuf"]) << endl;
		
	try
	{
		cerr << "crasher " << (test_map["boum"])  << endl;
		
		throw("whaaaa");
	}
	catch (...)
	{
		cerr << "caught crasher" << endl;
	}
	
	raise(SIGTRAP);
	
	return 1;
}
compiling with clang & libc++. when launched from CL it freeze, but from cmd line it gives:
./cxxtest64d.bin
vanilla
std::regex match
chrono: elapsed ms 7.70964e+07 since epoch
hashset: entry ok... not entry: ok... (rastaman done)
hashmap: entries 3... 9
crasher 0
caught crasher
Trace/breakpoint trap
thx again

Re: trigger LLDB breakpoint?

Posted: Wed Sep 10, 2014 10:39 am
by petah
eranif wrote:
petah wrote:I have a "locals" window title instead of "locals & watches" as I see in CL's source.
This is because you still have the old perspectives kept (wx keeps the frame title in it...)
ok I flushed the perspectives and can now see code changes in CL's UI :D

building libc++ on linux is ~ guesswork bc the clang page has 3 different ABIs; cxxrt works for me but dunno if there's a better way. I can send my receipe if you want.

thx,

-- p