2015-01-09 2 views
1

나는 두 개의 소스 파일 (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가 만족 스럽습니다.

  1. gdb에서 중복 된 심볼은 어떻게 인쇄해야합니까? 기호 대신 주소를 사용해야합니까?
  2. 중복 기호 끝에 .5782 등 번호는 무엇입니까? 그러면 심볼을 다시 오브젝트 파일에 매핑 할 수 있습니까?

참고 : 변수의 이름을 바꾸는 것이 아니라 둘 모두 타사 라이브러리에 정의되어 있습니다.

답변

1

중복 된 기호는 다음과 같이 인쇄됩니다. p 'f2.c':: x. 설명은 in this section of GDB manual입니다. -flto 플래그가 실행 구축하는 데 사용 된 경우에만 나는 문자의 끝에 숫자를 보았다

print *(int*)0x60103c 

:

주소를 사용하여 인쇄가 다음과 같이 수행 할 수 있습니다

(가정 0x60103c 정수 변수의 주소입니다) . 이 (기본 Ubuntu 14.04 toolchain 용)은 gdb가 다른 파일의 기호를 인쇄하는 기능을 손상시킵니다 (잘못된 것을 인쇄합니다). 이 문제에 대한 해결 방법은 디버깅 할 때 -flto없이 빌드하는 것입니다.

+0

우수! 나는 -flto를 지정했다. 또한 파일을 지정할 수 있음을 알고 있으면 도움이됩니다. – watkipet

관련 문제