I'm using xcode instruments to profile some code on my mac.
When I double-click on a function to see the disassembly, instruments shows it in AT&T syntax.
Is it possible to show the disassembly in Intel syntax instead?
Related
I have a toolchain for my target which includes a gdb client in it:
GNU gdb (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 7.12.1.20170417-git
(It's not the latest available from GNU ARM, but I have to use it for now, so let's assume there is no latest..)
The remote target (connecting through a gdbserver connected to JTAG) in is a Cortex-A7, which is armv7-a architecture.
What I don't understand why the gdb as is from this toolchain does not list armv7-a as one of the architectures that I can with "set architecture" command, yet, it appears to debug just fine.
I build binaries for armv7-a, and verify that they are built for this arch.
I can then start the gdb from the toolchain, and load and start debugging.
If I list available inside gdb, it shows this:
set architecture
arm arm_any armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5t armv5te auto ep9312 iwmmxt iwmmxt2 xscale
No armv7 anywhere. Yet gdb doesn't complain about anything, I can debug/single step instruction code, and, I see some v7 / new instructions which are new to the architecture.
These posts somewhat related but not answering it:
How does GDB determine ARM architecture
GDB remote debug: can't stop the thread
Attributes from my elf
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_enum_size: int
Tag_DIV_use: Allowed in v7-A with integer division extension
Tag_Virtualization_use: TrustZone and Virtualization Extensions
Gdb build was configured with:
configure --host=x86_64-linux-gnu --target=arm-none-eabi
What I expected is that "armv7-a" or "armv7-m" or any may be some "armv7" should be listed by gdb as supported, but it isn't .
Yet it seems to be able to work with armv7-a target code - can disassemble it and understand armv7 new instructions , such as movt/movw.
So how does it do it? Is it a special/patched gdb (client) which does not list the arch, or what am I missing?
(I've seen that later gdb versions do allow set architecture armv7-a, but that's not mine gdb, and I want to understand how mine works)
I am trying to debug Linux using gdb, I compiled kernel with "compile kernel with debug info".
once kernel is compiled I am trying to give
GDB file vmlinux
(running above command gives me below error)
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Reading symbols from file...(no debugging symbols found)...done.
"/home/Linux/vmlinux" is not a core dump: File format not recognized
Even I am setting debug con-figs it is giving me "no debugging symbols found"
kernel debugging is a whole different ballgame from debugging a user process and is not as simple as firing up GDB. For this you will need support of a JTAG.
QEMU allows you to virtualize a machine and therefore use a virtual JTAG.
For simple stuff you will probably find printk much easier.
I'm trying to compile a program to run on a Linux powered board, which has an ARM926EJ-S processor. So I've installed Debian embedded cross-development toolchain, and tried compiling an Hello World with in gcc with -march=armv5te . When I tried running the binary on the board it crashed with file not found errors (due to library versions), after that I've tried compiling with -static flag and I got a seg fault (0x0000827c in __libc_start_main (), said mr gdb trough gdbserver).
Any idea on what to do here to get something running?
Apparently the solution is to try as many toolchains as you can find. Eventually you'll find the one that works, after spending a few too many hours compiling toolchains. uClibc buildroot in this case.
You can find toolchains which support ARM926EJ-S on Linaro Page. Use the most recent arm-linux-gnueabi from Linaro project. I am currently using a version with gcc 4.9.4 which you can find here
It is recommended to use -mcpu=arm926ej-s instead of -march and -mtune. See gcc documentation because it combines -march and -mtune for your specified processor. It was deprecated for x86, but not for arm.
Other possibility could be building your own toolchain via crosstools-ng. But the Linaro toolchains are working out of the box if you don't need some specific setting (for example only using static libraries).
I understand that compilers convert c source code to assembly and then to machine code. I searched through every compiler setting I could find, and their website but I can't get it to generate assembly. Also, the website states that Dev-C++ uses AT&T assembly, can I also convert from that to Intel?
Dev-C++ seems to use GCC.
You can try this option: gcc -S -masm=intel as answered in this question: How do you use gcc to generate assembly code in Intel syntax?
I do not know how to set command line options on Dev-C++ but guides can be easily found.
C:\Program Files (x86)\Dev-Cpp\MinGW32\bin>gcc -S -masm=intel try.cpp
Type this in command prompt(location of gcc depends on where you have install dev-C++),it will generate assembly file,in my case try.s
I'm trying to use GDB to debug (to find an annoying segfault). When I run:
gdb ./filename
from the command line, I get the following error:
This GDB was configured as "i686-pc-linux-
gnu"..."/path/exec": not in executable
format: File format not recognized
When I execute:
file /path/executable/
I get the following info:
ELF 64-bit LSB executable, AMD x86-64,
version 1 (SYSV), for GNU/Linux 2.4.0,
dynamically linked (uses shared libs), not stripped
I am using GDB 6.1, and the executable is compiled with gcc version 3.4.6.
I'm a little out of my water in terms of using gdb, but as far as I can tell it should be working in this instance. Any ideas what's going wrong?
The executable is 64-bit (x86-64) and the debugger is a 32 bit (i686-pc-linux) build. You may need to install a 64-bit (x86-64) version of the debugger.
I'm not sure if this is your problem, but I faced this situation very often. The executable in the build tree, build by make/automake is not a binary, but a script, so you cannot use gdb with it. Try to install the application and change the directory, because else gdb tries to debug the script.
The question refers to "./filename" and to "/path/executable". Are these the same file?
If you are doing a post-mortem analysis, you would run:
gdb executable-file core-file
If you are going to ignore the core file, you would run:
gdb executable-file
In both cases, 'executable-file' means a pathname to the binary you want to debug. Most usually, that is actually a simple filename in the current directory, since you have the source code from your debug build there.
On Solaris, a 64-bit build of GDB is supposed to be able to debug both 32-bit and 64-bit executables (though I've had some issues with recent versions of GDB). I'm not sure of the converse - that a 32-bit GDB can necessarily debug 64-bit executables.
What you need to be checking, is really the bfd library. The binary file descriptor library is what binutils / gdb uses to actually parse and handle binaries (ELF/a.out etc..).
You can see the current supported platforms via objdump;
# objdump -H
objdump: supported targets: elf32-powerpc aixcoff-rs6000 elf32-powerpcle ppcboot elf64-powerpc elf64-powerpcle elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex binary ihex
objdump: supported architectures: rs6000:6000 rs6000:rs1 rs6000:rsc rs6000:rs2 powerpc:common powerpc:common64 powerpc:603 powerpc:EC603e powerpc:604 powerpc:403 powerpc:601 powerpc:620 powerpc:630 powerpc:a35 powerpc:rs64ii powerpc:rs64iii powerpc:7400 powerpc:e500 powerpc:MPC8XX powerpc:750
The following PPC specific disassembler options are supported for use with
the -M switch:
booke|booke32|booke64 Disassemble the BookE instructions
e300 Disassemble the e300 instructions
e500|e500x2 Disassemble the e500 instructions
efs Disassemble the EFS instructions
power4 Disassemble the Power4 instructions
power5 Disassemble the Power5 instructions
power6 Disassemble the Power6 instructions
32 Do not disassemble 64-bit instructions
64 Allow disassembly of 64-bit instructions
It seems your GNU Debugger (gdb) doesn't support x86_64 architecture.
So try LLDB Debugger (lldb) which aims to replace it. It supports i386, x86-64 and ARM instruction sets.
It's available by default on BSD/OS X, on Linux install via: sudo apt-get install lldb (or use yum).
See: gdb to lldb command map page for more info.