remake工具的使用

调试makefile如果有一个像gdb一样的调试器,工作起来肯定事半功倍,学习mekefile中文手册,看的是云里雾里,再去看u-boot的makefile更是看天书一样.在网上找了很久找到一个remake工具

单步调试gdb神器,remake工具

http://bashdb.sourceforge.net/remake/
但是网上关于此工具的中文网页少的可怜,但是英文的就稍微多一点了,不过我英文虽然能看懂,毕竟不是母语,再加上很多基本概念不清楚,这款工具也就只能学到点皮毛,希望中国有很多人能够知道有这么个工具,能够像gdb一样随手一搜索就是大把的教程.

  • 以u-boot为例 进入调试
    输入 remake --debugger就进入单步调试了
book@book-desktop:~/system/u-boot-1.1.6$ remake --debugger
GNU Make + Debugger 3.81+dbg-0.2
Copyright (C) 2002, 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i486-pc-linux-gnu
Reading makefiles...
Updating makefiles....
  File `/work/system/u-boot-1.1.6/cpu/arm920t/s3c24x0/config.mk' does not exist.

(/work/system/u-boot-1.1.6/cpu/arm920t/s3c24x0/config.mk:0)
/work/system/u-boot-1.1.6/cpu/arm920t/s3c24x0/config.mk: 

输入help命令可以查看详细的remake支持的所有命令

mdb<0> help
  Command                  Short Name  Aliases
  ----------------------   ----------  ---------
  break TARGET                    (b)  L
  cd DIR                          (C)
  comment TEXT                    (#)
  continue [TARGET]               (c)
  delete breakpoint numbers..     (d)
  down [AMOUNT]                   (D)
  eval STRING                     (e)
  examine STRING                  (x)
  finish                          (F)
  frame N                         (f)
  help [COMMAND]                  (h)  ?, ??
  info [THING]                    (i)
  list [TARGET]                   (l)
  next [AMOUNT]                   (n)
  print {VARIABLE [attrs...]}     (p)
  Print working directory         (P)
  quit [exit-status]              (q)  exit, return
  run                             (R)  restart
  set {*option*|variable} VALUE   (=)
  setq *variable* VALUE           (")
  shell STRING                    (!)  !!
  show [thing]                    (S)
  skip                            (k)
  step [AMOUNT]                   (s)
  target [target-name] [info1 [info2...]] (t)
  up [AMOUNT]                     (u)
  where                           (T)  backtrace, bt
  write [TARGET [FILENAME]]       (w)

Readline command line editing (emacs/vi mode) is available.
For more detailed help, type h <cmd> or consult online-documentation.

remake的离线帮助文档在以下目录,里面记载了详细的使用方法
*remake-3.82+dbg1.0\remake-3.82+dbg1.0\doc*

remake帮助文档

这里水平有限,只列举几条我能够知道什么意思的命令,不一定对,只是起个抛砖引玉的作用,以帮助文档参考为主
1.where命令-->当前正在执行哪个makefile

mdb<6> where

=>#0  /work/system/u-boot-1.1.6/cpu/arm920t/s3c24x0/config.mk at ??
  1. target命令-->当前的目标是什么,有没有更新,文件存不存在,依赖是什么
mdb<26> target

mdb<1> target

all: u-boot.srec u-boot.bin System.map
#  Implicit rule search has not been done.
#  Implicit/static pattern stem: `'
#  File does not exist.
#  File has not been updated.
# automatic
# @ := all
# automatic
# % := 
# automatic
# * := 
# automatic
# + := u-boot.srec u-boot.bin System.map
# automatic
# | := 
# automatic
# < := all
# automatic
# ^ := u-boot.srec u-boot.bin System.map
# automatic
# ? := 
mdb<2> 

3.print和x命令-->展开变量

mdb<31> p CFLAGS
/work/system/u-boot-1.1.6/config.mk:165 (origin: makefile) CFLAGS = -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float -malignment-traps -D__KERNEL__ -DTEXT_BASE=0x33F80000  -I/work/system/u-boot-1.1.6/include -fno-builtin -ffreestanding -nostdinc -isystem /work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv4 -mapcs-32 -Wall -Wstrict-prototypes
mdb<31> x CFLAGS
/work/system/u-boot-1.1.6/config.mk:165 (origin: makefile) CFLAGS := -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float -malignment-traps -D__KERNEL__ -DTEXT_BASE=0x33F80000  -I/work/system/u-boot-1.1.6/include -fno-builtin -ffreestanding -nostdinc -isystem /work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv4 -mapcs-32 -Wall -Wstrict-prototypes
mdb<32> 

先写到这..............

1.1.3 A Larger Real-World Makefile Trace
  GNU Make and GNU Remake work like many other interpreters.  First Makefiles are read in and parsed and then they are "executed" which in GNU Make means that dependency checks are done and actions are performed based on those checks.  However there is quite a bit work that may be done just in portion which reads in the Makefiles and performs variable expansion.  Most of the time this information is will not be of much use.  But if you should be interested in this phase, use the flag '--trace=read'.

Makefile文件被读入进行解析,之后才是执行,依赖检查没有问题才能进行action的执行.这部分信息可以通过以下命令查看

remake --trace=read
3.7.3 Examining Targets ('target', 'list')
the GNU Make debugger can print information about targets.  When your
script stops, the GNU Make debugger spontaneously prints the line and
target name where it stopped.  Likewise, when you select a stack frame
(*note Selecting a frame: Selection.), the GNU Make debugger the default
target name is changed.
   As with debugging any program, the value shown at a particular point
in time may change.  Targets, and commands can use GNU Make uses
variables and these values can change.

'target'
't'
     print information about the current target.

'target TARGET'
't TARGET'
     Print information about TARGET.  A list of attributes can be
     specified after the target name.  The list of attributes names are

     'attributes'
          Show the list of "attributes" associated with the target.
          Attributes can be:
             * implicit rule search has been done
             * phony: has no file associated with it
             * precious:
             * a command-line target

     'commands'
          Show the list of commands that need to get run in order to
          bring the target up to date.

     'depends'
          Show the targets that this one depends on.

     'expand'
          Show the list of commands that need to get run in order to
          bring the target up to date with GNU Remake variables
          expanded.

     'nonorder'
          Show the dependencies that are not ordered.

     'previous'
     'state'
          Show status of target:
             * Successfully updated
             * Needs to be updated
             * Failed to be updated
             * Invalid - error of some sort

     'time'
          This shows the time that the file was last modified and if the
          file has been brought up to date.  If it is not up to date you
          will see the message "File is very old."  If a target is
          "phony", i.e.  doesn't have file associated with it, the
          message "File does not exist."  will appear instead of the
          time.  In some cases you may see "Modification time never
          checked."

     'variables'
          Show single-character automatic state variables (if defined):
             * @ - the target name
             * % - target member name, when target is an the archive
               member
             * * - the stem with which an implicit rule matches
             * + - like $^ but with the duplicate dependencies listed in
               order
             * < - the name of the first prerequisite
             * ^ - the names of all prerequisites (no duplicates)
             * ?  - the names of all prerequisites newer than the target
               (@)

          Note that there are other automatic variables defined based on
          these.  In particular those that have a 'D' or 'F' suffix,
          e.g.  $(@D), or $(*F). These however are not listed here but
          can shown in a 'print' command or figured out from their
          corresponding single-letter variable name.

'list'
'l'
     The "list" is like target but only text-oriented information is
     shown.

当makefile停止运行时the GNU Make debugger可以打印target的信息,当你在几个makefile之前进行切换时,能够打印的目标也一直在变.
使用命令t或者target--t target-name 后面还可以接一堆参数

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,830评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,992评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,875评论 0 331
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,837评论 1 271
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,734评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,091评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,550评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,217评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,368评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,298评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,350评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,027评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,623评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,706评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,940评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,349评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,936评论 2 341

推荐阅读更多精彩内容

  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,713评论 6 342
  • 1:InputChannel提供函数创建底层的Pipe对象 2: 1)客户端需要新建窗口 2)new ViewRo...
    自由人是工程师阅读 5,222评论 0 18
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,566评论 18 139
  • 程序调试的基本思想是“分析现象->假设错误原因->产生新的现象去验证假设”这样一个循环过程,根据现象如何假设错误原...
    Manfred_Zone阅读 16,494评论 0 26
  • 都说万事开头难,却不说开了头之后的日子才是难上加难! 第二章我想介绍一下自己,我叫福大,喜欢文字...
    小七福阅读 234评论 0 1