lttng: Make use of "is_pic" event field in debug info analysis
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Mon, 6 Jun 2016 04:07:36 +0000 (00:07 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 7 Jun 2016 18:37:26 +0000 (14:37 -0400)
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 <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/74616
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryFile.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoLoadedBinaryFile.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/layout/LttngUst28EventLayout.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java

index d818afbba786bd688b821cafc8476ed0b5c71232..0c17a69ebda9e0df9c18f1c73e7d15d06c9ea87c 100644 (file)
@@ -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<UstDebugInfoBinaryFile> actualBinaries = fModule.getAllBinaries();
-        Collection<UstDebugInfoBinaryFile> expectedBinaries = ImmutableList.<UstDebugInfoBinaryFile> 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<UstDebugInfoBinaryFile> actualBinaries = Lists.newArrayList(fModule.getAllBinaries());
+        List<UstDebugInfoBinaryFile> 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<UstDebugInfoBinaryFile> 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);
     }
 
 }
index dd603c7e2c7a5e8e0e3b641b78af2a3e24351956..b467720157ccd9c05eb6a4d1379d6657b01b2136 100644 (file)
@@ -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<UstDebugInfoBinaryFile
 
     private final String fFilePath;
     private final String fBuildId;
+    private final boolean fIsPic;
     private final String fToString;
 
     /**
@@ -29,11 +32,17 @@ public class UstDebugInfoBinaryFile implements Comparable<UstDebugInfoBinaryFile
      *            The binary's path on the filesystem
      * @param buildId
      *            The binary's unique buildID (in base16 form).
+     * @param isPic
+     *            If the binary is position-independent or not
      */
-    public UstDebugInfoBinaryFile(String filePath, String buildId) {
+    public UstDebugInfoBinaryFile(String filePath, String buildId, boolean isPic) {
         fFilePath = filePath;
         fBuildId = buildId;
-        fToString = filePath + " (" + buildId + ')'; //$NON-NLS-1$
+        fIsPic = isPic;
+
+        fToString = filePath + " (" + //$NON-NLS-1$
+                (fIsPic ? "PIC" : "non-PIC") + //$NON-NLS-1$ //$NON-NLS-2$
+                ", " + buildId + ')'; //$NON-NLS-1$
     }
 
     /**
@@ -57,6 +66,20 @@ public class UstDebugInfoBinaryFile implements Comparable<UstDebugInfoBinaryFile
         return fBuildId;
     }
 
+    /**
+     * Return whether the given file (binary or library) is Position-Independent
+     * Code or not.
+     *
+     * This indicates whether the symbols in the ELF are absolute or relative to
+     * the runtime base address, and determines which address we need to pass to
+     * 'addr2line'.
+     *
+     * @return Whether this file is position-independent or not
+     */
+    public boolean isPic() {
+        return fIsPic;
+    }
+
     @Override
     public String toString() {
         return fToString;
@@ -68,17 +91,14 @@ public class UstDebugInfoBinaryFile implements Comparable<UstDebugInfoBinaryFile
             return false;
         }
         UstDebugInfoBinaryFile other = (UstDebugInfoBinaryFile) obj;
-        return (fFilePath == other.fFilePath &&
-                fBuildId == other.fBuildId);
+        return (fFilePath.equals(other.fFilePath) &&
+                fBuildId.equals(other.fBuildId) &&
+                fIsPic == other.fIsPic);
     }
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + fBuildId.hashCode();
-        result = prime * result +  fFilePath.hashCode();
-        return result;
+        return Objects.hash(fBuildId, fFilePath, fIsPic);
     }
 
     /**
index f1c9372dc14b0428100d9380d1ad4de57ff506cf..993af783365936918f8ea21882cac5877d60b220 100644 (file)
@@ -28,9 +28,11 @@ public class UstDebugInfoLoadedBinaryFile extends UstDebugInfoBinaryFile {
      *            The file path of the loaded binary/library
      * @param buildId
      *            The build ID of the binary object
+     * @param isPic
+     *            If the binary is position-independent or not
      */
-    public UstDebugInfoLoadedBinaryFile(long baseAddress, String filePath, String buildId) {
-        super(filePath, buildId);
+    public UstDebugInfoLoadedBinaryFile(long baseAddress, String filePath, String buildId, boolean isPic) {
+        super(filePath, buildId, isPic);
         this.baseAddress = baseAddress;
     }
 
index 90bba3bd3b2902fd08214b55fbfb164cbe0fb977..7301c34c6b955998aefb5871ec95659cf32e8c3f 100644 (file)
@@ -44,9 +44,12 @@ import com.google.common.io.BaseEncoding;
  *   +-- 3000 (VPIDs)
  *        +-- baddr (value = addr range end, long)
  *        |     +-- buildId (value = /path/to/library (sopath), string)
+ *        |           +- is_pic (value = 0 or 1 (int))
  *        +-- baddr
  *        |     +-- buildId1
+ *        |           +- is_pic
  *        |     +-- buildId2 (if the same address is re-used later)
+ *        |           +- is_pic
  *       ...
  * </pre>
  *
@@ -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 <baddr, sopath> in here.
+     * Between these two events, we will store the <baddr, BinInfo> in here.
      */
-    private final Map<Long, String> fPendingEntries = new HashMap<>();
+    private final Map<Long, BinInfo> 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);
     }
 
     /**
index 40548264efb4e1702958cf2c61015055b7122671..27ff9e0c6e9e695c0121a426f0d062d5860a2435 100644 (file)
@@ -89,4 +89,8 @@ public class LttngUst28EventLayout extends LttngUst27EventLayout {
     public String fieldBuildId() {
         return "build_id";
     }
+
+    public String fieldIsPic() {
+        return "is_pic";
+    }
 }
index 30cd99d975ac80c6ae0259c945c2ba72795fbb9d..8f9cf5115134ab59ff51f1fe057553697c383e09 100644 (file)
@@ -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. */
index 00f8aedb2f33313614d08a9c064489c7b6deba77..3cb29f28512a3f6f3b0bb52c3f21bdafdff7c628 100644 (file)
@@ -107,10 +107,9 @@ public final class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCal
 
         /* Apply the path prefix defined by the trace, if any */
         String fullPath = (trace.getSymbolProviderConfig().getActualRootDirPath() + file.getFilePath());
-        boolean isPIC = isPIC(fullPath);
 
         long offset;
-        if (isPIC) {
+        if (file.isPic()) {
             offset = (ip - file.getBaseAddress());
         } else {
             /*
@@ -121,21 +120,7 @@ public final class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCal
             offset = ip;
         }
 
-        return new BinaryCallsite(fullPath, file.getBuildId(), offset, isPIC);
-    }
-
-    /**
-     * Return if the given file (binary or library) is Position-Independent Code
-     * or not. This indicates if addr2line considers the addresses as absolute
-     * addresses or as offsets.
-     */
-    private static boolean isPIC(String filePath) {
-        /*
-         * Ghetto binary/library identification for now. It would be possible to
-         * parse the ELF binary to check if it is position-independent
-         * (-fPIC/-fPIE) or not.
-         */
-        return (filePath.endsWith(".so") || filePath.contains(".so.")); //$NON-NLS-1$ //$NON-NLS-2$
+        return new BinaryCallsite(fullPath, file.getBuildId(), offset, file.isPic());
     }
 
 }
This page took 0.033089 seconds and 5 git commands to generate.