Insert debugging symbol using GIMPLE

dw.dev dw.dev.mailing@gmail.com
Fri Apr 22 23:21:00 GMT 2016


Hello all,

I'd like to add a debug symbol to the currently compiled object. To find
the point of interest, I iterate using gsi_{start,next,end}. As I am not
sure how debug symbols are handled in GCC, I tried to add a simple label
before the statement roughly as follows:

	static unsigned label_count = 0;
	char name[32] = { 0 };
	sprintf(name, "test_label_%x", ++label_count);

	location_t loc = gimple_location(stmt);
	tree identifier = get_identifier(name);

	tree l = build_decl(loc, LABEL_DECL, identifier,
	  void_type_node);

	DECL_CONTEXT(l) = current_function_decl;
	DECL_MODE(l) = VOIDmode;
	FORCED_LABEL(l) = 1;
	DECL_ARTIFICIAL(l) = 0;

	SET_IDENTIFIER_LABEL_VALUE(identifier, l);

	gimple label;
	label = gimple_build_label(l);
	gsi_insert_before(&gsi_current, l, GSI_NEW_STMT);
	// gimplestmt stmt = gsi_stmt(gsi_current)

While the label is visible in the RTL output (-fdump-rtl-all,
test.cpp.123r.expand), it does not show up in the resulting binary. This
is not unexpected; however, I am unsure how to add a debugging symbol in
place of that label.

I'd appreciate if anyone could point me into the right direction.

Regards



More information about the Gcc-help mailing list