libbacktrace: report decl_lineno with MOREDATA

Based on patch by Andi Kleen.

	* backtrace.h (struct backtrace_moredata): Add
	backtrace_decl_lineno field.
	* internal.h (BACKTRACE_MOREDATA_VERSION): Change to 4.
	* dwarf.c (struct function): Add decl_lineno field.
	(call_callback): Add decl_lineno parameter. Change all callers.
	(read_referenced_name_from_attr): Likewise.
	(read_referenced_name): Likewise.
	(report_inlined_functions): Likewise.
	(read_function_entry): Set decl_lineno field.
	(dwarf_lookup_pc): Handle decl_lineno across inlines.
	* mdtest.c (struct mdinfo): Define.
	(struct mddata): Define.
	(md_callback_one): Adjust for mddata.
	(md_callback_three): Likewise.
	(test1, f2): Reformat for simpler line number testing.
	(f3): Test that decl_lineno is correct.
	(f13): Adjust for mddata.
This commit is contained in:
Ian Lance Taylor
2026-08-31 12:42:36 -07:00
parent 6f8310e238
commit 6d913c4521
4 changed files with 142 additions and 62 deletions
+4 -1
View File
@@ -228,7 +228,7 @@ struct backtrace_moredata
possible that future versions of libbacktrace will add new fields
and increment the version number accordingly. There is no plan to
remove fields from this struct. Thus the current value of the
version field will be 3. */
version field will be 4. */
int backtrace_version;
/* The DATA value passed to whatever function is calling the callback
(backtrace_full, backtrace_pcinfo, or backtrace_syminfo). */
@@ -236,6 +236,9 @@ struct backtrace_moredata
/* The DWARF discriminator. This is zero if there is none. See
https://wiki.dwarfstd.org/Path_Discriminators.md. */
unsigned int backtrace_discriminator;
/* The line number of the start of the function declaration or
definition. This is 0 if not available. */
int backtrace_decl_lineno;
};
#ifdef __cplusplus