/* Return scope DIEs containing PC address.
Copyright (C) 2005, 2007, 2015 Red Hat, Inc.
+ Copyright (C) 2023 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
/* Not there yet. */
return 0;
- /* Now we are in a scope that contains the concrete inlined instance.
- Search it for the inline function's abstract definition.
- If we don't find it, return to search the containing scope.
- If we do find it, the nonzero return value will bail us out
- of the postorder traversal. */
- return __libdw_visit_scopes (depth, die, NULL, &origin_match, NULL, a);
+ /* This is the innermost inline scope, we are done here. */
+ return a->nscopes;
}
int result = __libdw_visit_scopes (0, &cu, NULL, &pc_match, &pc_record, &a);
- if (result == 0 && a.scopes != NULL)
- result = __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a);
+ if (result >= 0 && a.scopes != NULL && a.inlined > 0)
+ {
+ /* We like the find the inline function's abstract definition
+ scope, but that might be in a different CU. */
+ cu.die = CUDIE (a.inlined_origin.cu);
+ result = __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a);
+ }
if (result > 0)
*scopes = a.scopes;
+2023-01-22 Mark Wielaard <mark@klomp.org>
+
+ * testfile-inlines-lto.bz2: New testfile.
+ * run-addr2line-i-test.sh: Add new lto inlines test.
+ * Makefile.am (EXTRA_DIST): Add testfile-inlines-lto.bz2.
+
2023-01-19 Mark Wielaard <mark@klomp.org>
* run-addr2line-C-test.sh: New test.
test-core.exec.bz2 run-addr2line-test.sh \
run-addr2line-C-test.sh \
run-addr2line-i-test.sh testfile-inlines.bz2 \
+ testfile-inlines-lto.bz2 \
run-addr2line-i-lex-test.sh testfile-lex-inlines.bz2 \
run-addr2line-i-demangle-test.sh run-addr2line-alt-debugpath.sh \
testfileppc32.bz2 testfileppc64.bz2 \
(inlined by) _Z2fuv at /tmp/x.cpp:33
EOF
+# == x.cpp ==
+# g++ x.cpp -g -fPIC -olibx.so -shared -O0 -flto
+#
+# __attribute__((always_inline)) inline
+# int foobar(int i)
+# {
+# return i + 1;
+# }
+#
+# __attribute__((always_inline)) inline
+# int fubar(int i)
+# {
+# return i + 1;
+# }
+#
+# __attribute__((always_inline)) inline
+# int bar(int i)
+# {
+# return fubar(i++);
+# }
+#
+# __attribute__((always_inline)) inline
+# int foo(int i)
+# {
+# return foobar(i++);
+# }
+#
+# int fu(int i)
+# {
+# return foo(i++) + bar(i++);
+# }
+
+testfiles testfile-inlines-lto
+
+testrun_compare ${abs_top_builddir}/src/addr2line --pretty -fiC -e testfile-inlines-lto 0x1118 0x1137 <<\EOF
+foobar(int) at /tmp/x.cpp:4:14
+ (inlined by) foo(int) at /tmp/x.cpp:22:16
+ (inlined by) fu(int) at /tmp/x.cpp:27:13
+fubar(int) at /tmp/x.cpp:10:14
+ (inlined by) bar(int) at /tmp/x.cpp:16:15
+ (inlined by) fu(int) at /tmp/x.cpp:27:24
+EOF
+
exit 0