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  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 后面还可以接一堆参数

你可能感兴趣的:(remake工具的使用)