我有兩個源文件(C語言),它們具有相同名稱的全局變量。全局變量是靜態的。如果我使用nm
從目標文件轉儲符號,我可以看到調試信息包括:如何從GDB中的不同目標文件中區分具有相同名稱的符號?
hostname:ble_app_hrs username$ find Debug -name '*.o' -exec /usr/local/gcc-arm-none-eabi-4_8-2014q2/bin/arm-none-eabi-nm -o -l {} \; | grep m_user_array_size
Debug/components/libraries/gpiote/app_gpiote.o:00000000 b m_user_array_size GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/gpiote/app_gpiote.c:36
Debug/components/libraries/timer/app_timer.o:00000000 b m_user_array_size GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/timer/app_timer.c:131
但是,如果我從聯結束後的ELF文件轉儲符號,看來調試這些重複的符號被剝離出來。這是正常的行爲 - 即。是what's described here是否自動發生?並不是所有的調試信息被剝離
hostname:ble_app_hrs username$ /usr/local/gcc-arm-none-eabi-4_8-2014q2/bin/arm-none-eabi-nm -o -l Debug/ble_app_hrs.elf | grep user
Debug/ble_app_hrs.elf:0001cb50 T app_gpiote_user_enable GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/gpiote/app_gpiote.c:224
Debug/ble_app_hrs.elf:0001ca88 T app_gpiote_user_register GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/gpiote/app_gpiote.c:190
Debug/ble_app_hrs.elf:200020a4 B m_enabled_users_mask.6444
Debug/ble_app_hrs.elf:200020c0 B m_gpiote_user_id.6603
Debug/ble_app_hrs.elf:20002080 B m_user_array_size.5782
Debug/ble_app_hrs.elf:200020a8 B m_user_array_size.6446
Debug/ble_app_hrs.elf:200020a9 B m_user_count.6445
Debug/ble_app_hrs.elf:20002084 B mp_users.5783
Debug/ble_app_hrs.elf:200020ac B mp_users.6443
Debug/ble_app_hrs.elf:0001d688 t user_id_get.5752.4484 GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/timer/app_timer.c:1056
Debug/ble_app_hrs.elf:0001d2cc t user_op_alloc.5716.4521 GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/timer/app_timer.c:794
Debug/ble_app_hrs.elf:0001d2b4 t user_op_enque.5691.4546 GNU_ARM_Eclipse/nRF51_SDK_7/components/libraries/timer/app_timer.c:781
注意 - 它仍然存在像app_gpiote_user_enable
符號。如果我嘗試打印其中一個副本,如m_user_array_size
,gdb告訴我,No symbol "m_user_array_size" in current context.
但是,如果我打印app_gpiote_user_enable
,gdb對此感到滿意。
- 我應該如何在gdb中打印重複符號?我必須使用地址而不是符號嗎?
- 什麼是
.5782
等數字在重複符號的末尾?這會幫助我將符號映射回目標文件嗎?
注意:我寧願不只是重命名變量 - 它們都在第三方庫中定義。
非常好!我確實有-fl指定。也知道我可以指定文件是有幫助的。 – watkipet 2015-01-13 06:00:05