From: Alexandre Montplaisir Date: Mon, 6 Jun 2016 04:07:36 +0000 (-0400) Subject: lttng: Make use of "is_pic" event field in debug info analysis X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=d89151ba34c29c9667679d7c5b70ee8bd2796b61 lttng: Make use of "is_pic" event field in debug info analysis A field with name "is_pic" is now present in LTTng 2.8 final in "bin_info" events to indicate if the referred binary is PIC (position-independent code) or not. We can make use of this field to identify PIC binaries much more reliably than by just looking at the file name. Bug: 495551 Change-Id: Ib553f43e8236c399c56387ff8e20a8428c688fb5 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/74616 Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java index d818afbba7..0c17a69ebd 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.ArrayList; -import java.util.Collection; +import java.util.Comparator; import java.util.List; import org.eclipse.jdt.annotation.NonNull; @@ -42,8 +42,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; /** * Tests for the {@link UstDebugInfoAnalysisModule} @@ -195,64 +195,72 @@ public class UstDebugInfoAnalysisModuleTest { @Test public void testGetAllBinaries() { executeModule(); - Collection actualBinaries = fModule.getAllBinaries(); - Collection expectedBinaries = ImmutableList. builder() - .add(new UstDebugInfoBinaryFile("/home/alexandre/src/lttng-project/lttng/trace-utils/dynamicLinking/libhello.so" ,"c9ac43c6b4251b0789ada66931e33487d65f64a6")) - .add(new UstDebugInfoBinaryFile("/home/alexandre/src/lttng-project/lttng/trace-utils/dynamicLinking/main.out" ,"0ec3294d0cacff93ec30b7161ff21efcd4cdd327")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/ld-2.23.so" ,"edfa6d46e00ca97f349fdd3333d88493d442932c")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libc-2.23.so" ,"369de0e1d833caa693af17f17c83ba937f0a4dad")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libdl-2.23.so" ,"a2adf3615338d49c702c41eb83a99ab743d2b574")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libgcc_s.so.1" ,"68220ae2c65d65c1b6aaa12fa6765a6ec2f5f434")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0" ,"8b553ecf9133c50f36a7345a4924c5b97e9daa11")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/liblzma.so.5.0.0" ,"15aed4855920e5a0fb8791b683eb88c7e1199260")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libm-2.23.so" ,"5c4078c04888a418f3db0868702ecfdb35b3ad8b")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libpcre.so.3.13.2" ,"390b2228e9a1071bb0be285d77b6669cb37ce628")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libpthread-2.23.so" ,"b77847cc9cacbca3b5753d0d25a32e5795afe75b")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libresolv-2.23.so" ,"81ef82040e9877e63adca93b365f52a4bb831ee1")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/librt-2.23.so" ,"a779dbcb3a477dc0c8d09b60fac7335d396c19df")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libselinux.so.1" ,"62a57085aa17036efdcecf6655d9e7be566f6948")) - .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libz.so.1.2.8" ,"340b7b463f981b8a0fb3451751f881df1b0c2f74")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/indicator-transfer-service" ,"01c605bcf38d068d77a6e0a02cede6a50c5750b5")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/libbuteo-transfers.so" ,"a3a54ba90d7b7b67e0be9baaae3b91675b630a09")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/libdmtransfers.so" ,"ad8ebd563d733818f9f4a399b8d34c1b7e846f3d")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.5.1" ,"478d22fbdf6a3e0ec3b499bd2bb8e97dbed84fb6")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libQt5Xml.so.5.5.1" ,"3a16f2feccfdbca6a40d9bd43ae5a966bca065c7")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libaccounts-glib.so.0.1.3" ,"3aaeb6f74d07bd2331fa1664a90b11ca5cc1b71e")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libaccounts-qt5.so.1.2.0" ,"c4c36b5efb4dd5f92a53ed0a2844239f564328d7")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0" ,"8cebf2501fd917f393ef1390777415fca9289878")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0" ,"bb484981ddf4152bb6f02ad3a700ec21ca3805e2")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libclick-0.4.so.0.4.0" ,"79609d999eab77f934f6d7d296074ea54f1410e8")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libffi.so.6.0.4" ,"9d9c958f1f4894afef6aecd90d1c430ea29ac34f")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgee-0.8.so.2.5.1" ,"96aff01de4c5e4817d483de7278c8cc9c6d02001")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.0" ,"01d955da82f10209b515f362b2352d5a0d0b5330")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0.4800.0" ,"a9190276f6246d3a44ba820510ef7d469ea556b1")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0" ,"bce3f25958a5b88c9493990daf0c90a787444c28")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicudata.so.55.1" ,"233845f0cd27642c4b2cc43979c8801b52bc00a9")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicui18n.so.55.1" ,"7bf3774116dbb992ffcc2156b6f5c44f0a328f00")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicuuc.so.55.1" ,"323e4878073bb4e0d7b174ae24e383ec5e05d68a")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libindicator-transfer.so.0.0.2" ,"4e472120f2a19343e1ff5928459edcb4a6c0b1e2")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libjson-glib-1.0.so.0.102.0" ,"55c87753a67b0c24922bd091f042b9d8bd4995dc")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust-dl.so.0.0.0" ,"450c14d5a7a72780b2d88a3cf73d2e12c2774676")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust-tracepoint.so.0.0.0" ,"e70e1748e137bb59b542e15e0722455b998355fc")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust.so.0.0.0" ,"101115876419ead3a8bd9a9a08a6d92984015b99")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmirclient.so.9" ,"b4c1509382d3ef5f7458db59710b4d30dad86b5d")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmircommon.so.5" ,"25b5830854701533323f15195ae9e501ad7f772b")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3" ,"2f6b1a56f1ac43ae001dffde4dc1a24bfee04dec")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libpcre16.so.3.13.2" ,"2cc13260733c5b35f311725fca88219b338d5390")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.9.0.1" ,"625eb54ba7ccc3af18d3193e22cbe9f23dfb88e5")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6" ,"d9782ba023caec26b15d8676e3a5d07b55e121ef")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21" ,"662f4598d7854c6731f13802486e477a7bdb09c7")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libubuntu-app-launch.so.2.0.0" ,"1e5753f4feda98548bd230eb07b81e330f419463")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-bp.so.4.0.0" ,"d208fcd0e6e6968b8110d9c487f63ae1a400e7c2")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-cds.so.4.0.0" ,"177fbd0a1b21145ad2f29bf41ba9f45e43b1ae4a")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburl-dispatcher.so.1.0.0" ,"58e7febb6e33418eee311c0bad19aace5cba0fd1")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libxkbcommon.so.0.0.0" ,"29ebf0cc0837b321e6a751b9b7d43ae9f8f3f0c0")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3" ,"a155c7bc345d0e0b711be09120204bd88f475f9e")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libzeitgeist-2.0.so.0.0.0" ,"211049ef6c5ed6e7bbcdc75c0a25d1f11755151d")) - .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/url-dispatcher/url-dispatcher" ,"694fcf16ee9241e66a33de671d10f854312e0c87")) - .build(); + List actualBinaries = Lists.newArrayList(fModule.getAllBinaries()); + List expectedBinaries = Lists.newArrayList( + new UstDebugInfoBinaryFile("/home/alexandre/src/lttng-project/lttng/trace-utils/dynamicLinking/libhello.so", "c9ac43c6b4251b0789ada66931e33487d65f64a6", true), + new UstDebugInfoBinaryFile("/home/alexandre/src/lttng-project/lttng/trace-utils/dynamicLinking/main.out", "0ec3294d0cacff93ec30b7161ff21efcd4cdd327", false), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/ld-2.23.so", "edfa6d46e00ca97f349fdd3333d88493d442932c", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libc-2.23.so", "369de0e1d833caa693af17f17c83ba937f0a4dad", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libdl-2.23.so", "a2adf3615338d49c702c41eb83a99ab743d2b574", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libgcc_s.so.1", "68220ae2c65d65c1b6aaa12fa6765a6ec2f5f434", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0", "8b553ecf9133c50f36a7345a4924c5b97e9daa11", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/liblzma.so.5.0.0", "15aed4855920e5a0fb8791b683eb88c7e1199260", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libm-2.23.so", "5c4078c04888a418f3db0868702ecfdb35b3ad8b", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libpcre.so.3.13.2", "390b2228e9a1071bb0be285d77b6669cb37ce628", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libpthread-2.23.so", "b77847cc9cacbca3b5753d0d25a32e5795afe75b", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libresolv-2.23.so", "81ef82040e9877e63adca93b365f52a4bb831ee1", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/librt-2.23.so", "a779dbcb3a477dc0c8d09b60fac7335d396c19df", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libselinux.so.1", "62a57085aa17036efdcecf6655d9e7be566f6948", true), + new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libz.so.1.2.8", "340b7b463f981b8a0fb3451751f881df1b0c2f74", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/indicator-transfer-service", "01c605bcf38d068d77a6e0a02cede6a50c5750b5", false), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/libbuteo-transfers.so", "a3a54ba90d7b7b67e0be9baaae3b91675b630a09", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/indicator-transfer/libdmtransfers.so", "ad8ebd563d733818f9f4a399b8d34c1b7e846f3d", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.5.1", "478d22fbdf6a3e0ec3b499bd2bb8e97dbed84fb6", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libQt5Xml.so.5.5.1", "3a16f2feccfdbca6a40d9bd43ae5a966bca065c7", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libaccounts-glib.so.0.1.3", "3aaeb6f74d07bd2331fa1664a90b11ca5cc1b71e", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libaccounts-qt5.so.1.2.0", "c4c36b5efb4dd5f92a53ed0a2844239f564328d7", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0", "8cebf2501fd917f393ef1390777415fca9289878", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0", "bb484981ddf4152bb6f02ad3a700ec21ca3805e2", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libclick-0.4.so.0.4.0", "79609d999eab77f934f6d7d296074ea54f1410e8", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libffi.so.6.0.4", "9d9c958f1f4894afef6aecd90d1c430ea29ac34f", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgee-0.8.so.2.5.1", "96aff01de4c5e4817d483de7278c8cc9c6d02001", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.0", "01d955da82f10209b515f362b2352d5a0d0b5330", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0.4800.0", "a9190276f6246d3a44ba820510ef7d469ea556b1", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0", "bce3f25958a5b88c9493990daf0c90a787444c28", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicudata.so.55.1", "233845f0cd27642c4b2cc43979c8801b52bc00a9", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicui18n.so.55.1", "7bf3774116dbb992ffcc2156b6f5c44f0a328f00", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libicuuc.so.55.1", "323e4878073bb4e0d7b174ae24e383ec5e05d68a", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libindicator-transfer.so.0.0.2", "4e472120f2a19343e1ff5928459edcb4a6c0b1e2", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libjson-glib-1.0.so.0.102.0", "55c87753a67b0c24922bd091f042b9d8bd4995dc", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust-dl.so.0.0.0", "450c14d5a7a72780b2d88a3cf73d2e12c2774676", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust-tracepoint.so.0.0.0", "e70e1748e137bb59b542e15e0722455b998355fc", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liblttng-ust.so.0.0.0", "101115876419ead3a8bd9a9a08a6d92984015b99", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmirclient.so.9", "b4c1509382d3ef5f7458db59710b4d30dad86b5d", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmircommon.so.5", "25b5830854701533323f15195ae9e501ad7f772b", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3", "2f6b1a56f1ac43ae001dffde4dc1a24bfee04dec", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libpcre16.so.3.13.2", "2cc13260733c5b35f311725fca88219b338d5390", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.9.0.1", "625eb54ba7ccc3af18d3193e22cbe9f23dfb88e5", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6", "d9782ba023caec26b15d8676e3a5d07b55e121ef", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21", "662f4598d7854c6731f13802486e477a7bdb09c7", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libubuntu-app-launch.so.2.0.0", "1e5753f4feda98548bd230eb07b81e330f419463", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-bp.so.4.0.0", "d208fcd0e6e6968b8110d9c487f63ae1a400e7c2", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-cds.so.4.0.0", "177fbd0a1b21145ad2f29bf41ba9f45e43b1ae4a", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburl-dispatcher.so.1.0.0", "58e7febb6e33418eee311c0bad19aace5cba0fd1", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libxkbcommon.so.0.0.0", "29ebf0cc0837b321e6a751b9b7d43ae9f8f3f0c0", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3", "a155c7bc345d0e0b711be09120204bd88f475f9e", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/libzeitgeist-2.0.so.0.0.0", "211049ef6c5ed6e7bbcdc75c0a25d1f11755151d", true), + new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/url-dispatcher/url-dispatcher", "694fcf16ee9241e66a33de671d10f854312e0c87", false)); - assertTrue(actualBinaries.containsAll(expectedBinaries)); + Comparator comparator = Comparator.comparing(UstDebugInfoBinaryFile::getFilePath); + actualBinaries.sort(comparator); + expectedBinaries.sort(comparator); + + /* Highlights failures more easily */ + for (int i = 0; i < expectedBinaries.size(); i++) { + assertEquals(expectedBinaries.get(i), actualBinaries.get(i)); + } + + assertEquals(actualBinaries, expectedBinaries); } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryFile.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryFile.java index dd603c7e2c..b467720157 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryFile.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryFile.java @@ -9,6 +9,8 @@ package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.debuginfo; +import java.util.Objects; + import org.eclipse.jdt.annotation.Nullable; /** @@ -20,6 +22,7 @@ public class UstDebugInfoBinaryFile implements Comparable * @@ -71,8 +74,14 @@ import com.google.common.io.BaseEncoding; */ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { + /** + * Sub-attribute indicating if a given binary is PIC (position-independent + * code) or not. This information is present directly in the trace. + */ + public static final String IS_PIC_ATTRIB = "is_pic"; //$NON-NLS-1$ + /* Version of this state provider */ - private static final int VERSION = 1; + private static final int VERSION = 2; private static final int DL_DLOPEN_INDEX = 1; private static final int DL_BUILD_ID_INDEX = 2; @@ -89,9 +98,25 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { * We need both the soinfo/dlopen event AND the matching build_id/debug_link * event to get all the information about a particular binary. * - * Between these two events, we will store the in here. + * Between these two events, we will store the in here. */ - private final Map fPendingEntries = new HashMap<>(); + private final Map fPendingEntries = new HashMap<>(); + + /** + * Information contained in a "bin_info" event, which means a binary's path, + * base address, and if it is a PIC or not. + */ + private static class BinInfo { + public final long fBaddr; + public final String fPath; + public final int fIsPic; + + public BinInfo(long baddr, String path, int isPic) { + fBaddr = baddr; + fPath = path; + fIsPic = isPic; + } + } /** * Constructor @@ -192,11 +217,15 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { * * Uses fields: Long baddr, Long memsz, String sopath */ - private void handleOpen(ITmfEvent event, final Long vpid, final ITmfStateSystemBuilder ss) throws AttributeNotFoundException { + private void handleOpen(ITmfEvent event, final Long vpid, final ITmfStateSystemBuilder ss) { Long baddr = (Long) event.getContent().getField(fLayout.fieldBaddr()).getValue(); Long memsz = (Long) event.getContent().getField(fLayout.fieldMemsz()).getValue(); String sopath = (String) event.getContent().getField(fLayout.fieldPath()).getValue(); + /* "dlopen" events do not have a "is_pic" field, they always refer to PIC libs */ + ITmfEventField isPicField = event.getContent().getField(fLayout.fieldIsPic()); + Long isPicVal = (isPicField == null ? 1L : (Long) isPicField.getValue()); + long endAddr = baddr.longValue() + memsz.longValue(); int addrQuark = ss.getQuarkAbsoluteAndAdd(vpid.toString(), baddr.toString()); @@ -207,7 +236,8 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { * Add this library to the pending entries, the matching * build_id/debug_link event will finish updating this attribute */ - fPendingEntries.put(baddr, checkNotNull(sopath)); + BinInfo binInfo = new BinInfo(baddr, checkNotNull(sopath), isPicVal.intValue()); + fPendingEntries.put(binInfo.fBaddr, binInfo); } /** @@ -226,8 +256,8 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { String buildId = BaseEncoding.base16().encode(longArrayToByteArray(buildIdArray)).toLowerCase(); /* Retrieve the matching sopath from the pending entries */ - String sopath = fPendingEntries.remove(baddr); - if (sopath == null) { + BinInfo binInfo = fPendingEntries.remove(baddr); + if (binInfo == null) { /* * We did not previously handle the initial event for this * library. Lost events? @@ -237,9 +267,15 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { } /* addrQuark should already exist */ int addrQuark = ss.getQuarkAbsolute(vpid.toString(), baddr.toString()); + + /* build-id attribute */ int buildIdQuark = ss.getQuarkRelativeAndAdd(addrQuark, buildId); long ts = event.getTimestamp().getValue(); - ss.modifyAttribute(ts, TmfStateValue.newValueString(sopath), buildIdQuark); + ss.modifyAttribute(ts, TmfStateValue.newValueString(binInfo.fPath), buildIdQuark); + + /* "is_pic" sub-attribute */ + int isPicQuark = ss.getQuarkRelativeAndAdd(buildIdQuark, IS_PIC_ATTRIB); + ss.modifyAttribute(ts, TmfStateValue.newValueInt(binInfo.fIsPic), isPicQuark); } /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/layout/LttngUst28EventLayout.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/layout/LttngUst28EventLayout.java index 40548264ef..27ff9e0c6e 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/layout/LttngUst28EventLayout.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/layout/LttngUst28EventLayout.java @@ -89,4 +89,8 @@ public class LttngUst28EventLayout extends LttngUst27EventLayout { public String fieldBuildId() { return "build_id"; } + + public String fieldIsPic() { + return "is_pic"; + } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java index 30cd99d975..8f9cf51151 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java @@ -151,7 +151,20 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule { } String filePath = interval.getStateValue().unboxStr(); - files.add(new UstDebugInfoBinaryFile(filePath, buildId)); + /* Retrieve the value of "is_pic" at that time */ + try { + int isPicQuark = ss.getQuarkRelative(buildIdQuark, UstDebugInfoStateProvider.IS_PIC_ATTRIB); + int isPicVal = ss.querySingleState(interval.getStartTime(), isPicQuark).getStateValue().unboxInt(); + boolean isPic = (isPicVal != 0); + + files.add(new UstDebugInfoBinaryFile(filePath, buildId, isPic)); + + } catch (AttributeNotFoundException e) { + /* We should have built "is_pic" sub-attributes */ + throw new IllegalStateException("Missing expected \"is_pic\" attribute"); //$NON-NLS-1$ + } catch (StateSystemDisposedException e) { + /* We're closing down, ignore */ + } } } return files; @@ -229,7 +242,12 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule { int buildIdQuark = potentialBuildIdQuark.get().intValue(); String buildId = ss.getAttributeName(buildIdQuark); String filePath = fullState.get(buildIdQuark).getStateValue().unboxStr(); - return new UstDebugInfoLoadedBinaryFile(baddr, filePath, buildId); + + int isPicQuark = ss.getQuarkRelative(buildIdQuark, UstDebugInfoStateProvider.IS_PIC_ATTRIB); + int isPicVal = fullState.get(isPicQuark).getStateValue().unboxInt(); + boolean isPic = (isPicVal != 0); + + return new UstDebugInfoLoadedBinaryFile(baddr, filePath, buildId, isPic); } catch (AttributeNotFoundException e) { /* We're only using quarks we've checked for. */ diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java index 00f8aedb2f..3cb29f2851 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java @@ -107,10 +107,9 @@ public final class UstDebugInfoBinaryAspect implements ITmfEventAspect