Gdb/Armulator 源代码分析

时间:2022-12-05 16:54:05 理工毕业论文 我要投稿
  • 相关推荐

Gdb/Armulator 源代码分析

作者Email: Anti_chen2000@sohu.com

摘要

Gdb/Armulator 是Gdb自带的arm7模拟器,是调试arm程序的一个好工具.而了解它的原码结构对扩展它的IO功能有重要意义.本文介绍了从Armulator的启动到其内部运作和IO扩展的大部分原代码功能.

说明

源代码用的是gdb-5.0.tar gdb-5.0-uclinux-armulator-20021127.patch

A.和GDB间的通迅

Armulator一般和Gdb通讯有两种方式,其一是在Gdb内部直接调用模拟器的相关函数,另一方法则是用pipe或socket传递RDP协议来连接Gdb和Amulator.而第一种方法是现在Gdb/Armulator所真正使用的(第二种是早期使用的方法),下面就分析了函数直接调用法.

函数直接调用

这个方法是由Steve (sac@cygnus.com) 修改原RDP方法而来的,Steve本人的描述如下:
/******************************************************
This directory contains the standard release of the ARMulator from
Advanced RISC Machines, and was ftp'd from.

ftp.cl.cam.ac.uk:/arm/gnu

It likes to use TCP/IP between the simulator and the host, which is
nice, but is a pain to use under anything non-unix.

I've added created a new Makefile.in (the original in Makefile.orig)
to build a version of the simulator without the TCP/IP stuff, and a
wrapper.c to link directly into gdb and the run command.

It should be possible (barring major changes in the layout of
the armulator) to upgrade the simulator by copying all the files
out of a release into this directory and renaming the Makefile.

(Except that I changed armos.c to work more simply with our
simulator rigs)
********************************************************/
/gdb/target.c,/gdb/remote_sim.c以及在/sim/arm/wrapper.c是在Armulator和Gdb的通信中起着至关重要做用的几个文件.所有的Gdb调试命令最后都是通过在target.h里定义的target_ops结构中的函数指针调用在/sim/arm/wrapper.c中型如sim_xxx的函数完成的.以前这些sim_xxx函数是位于/sim/common中的,是建立RDP通讯的关键,代码修改后此目录中的文件不再有用,被wrapper.c取而代之了.

以下是RDP 通讯和直接函数调用的图示:

要清楚Armulator的执行过程就要从它的启动说起,当你在Gdb中键入target sim 去激活Amulator后Gdb首先进行命令行解释,并将current_target指针指向sim变量,即将Armulator的调试函数集赋予Gdb,随后的函数调用堆栈如下:

--àgdbsim_open (…) in remote-sim.c.
--àsim_open(…) in /sim/arm/wrapper.c/*这里Amulator对调用参数进行分析处理*/
--à*current_target-

【Gdb/Armulator 源代码分析】相关文章:

认识“业务分析”08-25

住房装修分析05-11

蕴涵与句义分析05-28

企业变现能力分析02-23

科研论文写作格式分析10-25

课题论文材料的整理与分析06-15

刑事上诉制度的概述分析06-10

旅游购物投诉心理分析01-03

网络虚拟财产属性分析08-26

企业盈利能力分析开题报告07-21