From 68229afa84412c3f15eda60bb7839dd630011a05 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Mon, 30 Jul 2018 16:00:48 +0200 Subject: [PATCH] import-trace: fix same-address symbol import This bugfix makes sure that from a set of symbols with the same address, only the first one gets imported. After an assessment whether analysis scripts can deal with multiple symbols at the same address, an import of all symbols should be made possible in the future. This will also require to relax the primary-key constraint of the `symbols' table. Change-Id: I61c4ddb1af1556d44eab54e53eaa3d0fc20de7c1 --- tools/import-trace/import-symbols.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/import-trace/import-symbols.sh b/tools/import-trace/import-symbols.sh index 7108d1e1..81542a1d 100755 --- a/tools/import-trace/import-symbols.sh +++ b/tools/import-trace/import-symbols.sh @@ -49,6 +49,8 @@ EOT LAST_ADDR= LAST_SYMBOL= + LAST_INSERTED_ADDR= + # The "dummy" entry at the end makes sure the last real symbol from the # nm output makes it into the database. (nm -n -S -C $ELF; echo ffffffff a dummy) \ @@ -65,17 +67,21 @@ EOT if [ $LAST_ADDR ]; then # only create INSERT-line, if $ADDR is new to us - if [ ! $ADDR = $LAST_ADDR ]; then + if [ $LAST_ADDR != "$LAST_INSERTED_ADDR" ]; then echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES " echo "($ID, cast(0x$LAST_ADDR AS UNSIGNED), CAST(0x$ADDR AS UNSIGNED)-CAST(0x$LAST_ADDR AS UNSIGNED), '$LAST_SYMBOL');" + LAST_INSERTED_ADDR=$LAST_ADDR fi fi if [ $SIZE != unknown ]; then - echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES " - echo "($ID, cast(0x$ADDR AS UNSIGNED), CAST(0x$SIZE AS UNSIGNED), '$SYMBOL');" - LAST_ADDR= - LAST_SYMBOL= + if [ $ADDR != "$LAST_INSERTED_ADDR" ]; then + echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES " + echo "($ID, cast(0x$ADDR AS UNSIGNED), CAST(0x$SIZE AS UNSIGNED), '$SYMBOL');" + LAST_ADDR= + LAST_SYMBOL= + LAST_INSERTED_ADDR=$ADDR + fi else LAST_ADDR=$ADDR LAST_SYMBOL=$SYMBOL