https://blog.csdn.net/nanfeibuyi/article/details/127940011

编译步骤

step1:指定交叉编译器,生成makefile文件。

./configure --prefix=/home/xinyi/android/code/Demos/gdb-9.2/arm_build 
--host=arm-linux 
CC=aarch64-linux-gnu-gcc-8  
CXX=/usr/bin/aarch64-linux-gnu-g++-8 
LD=/usr/bin/aarch64-linux-gnu-ld 
AR=/usr/bin/aarch64-linux-gnu-gcc-ar-8

step2: 执行make指令

可能会碰到2个问题
问题1:…/…/gdb/nat/linux-ptrace.h:21:22: error: ‘PTRACE_GETFPREGS’ was not declared in this scope

# vi ./aarch64-linux-gnu/libc/usr/include/sys/ptrace.h
...
  /* Get all general purpose registers used by a process.  */
  PTRACE_GETREGS = 12, 
#define PT_GETREGS PTRACE_GETREGS

  /* Set all general purpose registers used by a process.  */
  PTRACE_SETREGS = 13,
#define PT_SETREGS PTRACE_SETREGS

  /* Get all floating point registers used by a process.  */
  PTRACE_GETFPREGS = 14,
#define PT_GETFPREGS PTRACE_GETFPREGS                                          

  /* Set all floating point registers used by a process.  */
  PTRACE_SETFPREGS = 15,
#define PT_SETFPREGS PTRACE_SETFPREGS
...

少什么宏就定义什么宏,不一定要定义在交叉编译工具链里,定义在gdb程序中报错的c文件中的某个头文件中亦可:
gdb/linux-ptrace.h

/* Get all general purpose registers used by a process.  */
#define PT_GETREGS 12

/* Set all general purpose registers used by a process.  */
#define PT_SETREGS 13

/* Get all floating point registers used by a process.  */
#define PT_GETFPREGS 14

/* Set all floating point registers used by a process.  */
#define PT_SETFPREGS 15

/* Get all general purpose registers used by a process.  */
#define PTRACE_GETREGS 12

/* Set all general purpose registers used by a process.  */
#define PTRACE_SETREGS 13

/* Get all floating point registers used by a process.  */
#define PTRACE_GETFPREGS 14

/* Set all floating point registers used by a process.  */
#define PTRACE_SETFPREGS 15

问题2:…/…/…/gdb/gdbserver/linux-arm-low.c:779:29: error: ‘__NR_sigreturn’ was not declared in this scope

# vi ./aarch64-linux-gnu/libc/usr/include/asm-generic/unistd.h
...
#define __NR_sigreturn 292
...

少什么宏就定义什么宏,不一定要定义在交叉编译工具链里,定义在gdb程序中报错的c文件中的某个头文件中亦可:
gdb/linux-low.h

step3: 在android系统上运行gdbserver

错误1:system/bin/sh:xxx : No such file or directory
https://www.jianshu.com/p/ac9911eb7958

错误2:sh: ./gdbserver: Permission denied
待解决


0 条评论

发表回复

您的电子邮箱地址不会被公开。