Go to the first, previous, next, last section, table of contents.


Target Vector Definition

Ÿ°Ù º¤ÅÍ Á¤ÀÇ

The target vector defines the interface between GDB's abstract handling of target systems, and the nitty-gritty code that actually exercises control over a process or a serial port. GDB includes some 30-40 different target vectors; however, each configuration of GDB includes only a few of them.

Ÿ°Ù º¤Åʹ Ÿ°Ù ½Ã½ºÅÛÀÇ GDB Ãß»óÀû Çڵ鸵°ú ÇÁ·Î¼¼½º¿Í ½Ã¸®¾ó Æ÷Æ®¿¡¼­ Á¦¾î¸¦ ½ÇÁ¦ÀûÀ¸·Î ÇÒ¼ö ÀÖ´Â ÄÚµå»çÀÌÀÇ ÀÎÅÍÆäÀ̽º¸¦ Á¤ÀÇÇÑ´Ù. GDB´Â ¸î¸î 30-40 ´Ù¸¥ Ÿ°Ù º¤Å͸¦ Æ÷ÇÔÇÑ´Ù; ±×·¯³ª, GDB °¢ ¼³Á¤Àº À̰͵éÁß ÀϺθ¸À» Æ÷ÇÔÇÑ´Ù.

File Targets

ÆÄÀÏ Å¸°Ù

Both executables and core files have target vectors.

½ÇÇàÆÄÀÏ°ú ÄÚ¾î ÆÄÀÏÀº Ÿ°Ù º¤Å͸¦ °¡Áö°í ÀÖ´Ù.

Standard Protocol and Remote Stubs

Ç¥ÁØ ÇÁ·ÎÅäÄÝ°ú ¿ø°Ý Stubs

GDB's file `remote.c' talks a serial protocol to code that runs in the target system. GDB provides several sample stubs that can be integrated into target programs or operating systems for this purpose; they are named `*-stub.c'.

GDBÀÇ ÆÄÀÏ `remote.c'´Â Ÿ°Ù ½Ã½ºÅÛ¿¡¼­ ÀÛµ¿ÇÏ´Â Äڵ带 À§ÇÑ ½Ã¸®¾ó ÇÁ·ÎÅäÄÝÀ» ¸»ÇÑ´Ù. GDB´Â Ÿ°Ù ÇÁ·Î±×·¥À̳ª ÀÌ·± ¸ñÀûÀ» À§ÇÑ OS¿¡ ÅëÇյɼö ÀÖ´Â ¸î¸î »ùÇà stubs¸¦ Á¦°øÇÑ´Ù; `*-stub.c'À¸·Î À̸§Áö¾îÁ® ÀÖ´Ù.

The GDB user's manual describes how to put such a stub into your target code. What follows is a discussion of integrating the SPARC stub into a complicated operating system (rather than a simple program), by Stu Grossman, the author of this stub.

GDB »ç¿ëÀÚ ¸Å´º¾óÀº ÀÌ·¯ÇÑ stub¸¦ Ÿ°Ù Äڵ忡 ³Ö´Â ¹æ¹ýÀ» ±â¼úÇÑ´Ù. ´ÙÀ½Àº ÀÌ stubÀÇ ÀúÀÚÀÎ Stu Grossman¿¡ ÀÇÇØ, SPARC stub¸¦ º¹ÀâÇÑ ¿ÀÆÛ·¹ÀÌÆà ½Ã½ºÅÛ(°£´ÜÇÑ ÇÁ·Î±×·¥ ÀÌ»óÀ¸·Î)¿¡ ÅëÇÕÇÏ´Â ³»¿ëÀÌ´Ù.

The trap handling code in the stub assumes the following upon entry to trap_low:

stub³» trap Çڵ鸵 ÄÚµå´Â trap_low¿¡ ´ëÇÑ ¿£Æ®¸®¸¦ ´ÙÀ½°ú °°ÀÌ °¡Á¤ÇÑ´Ù.:

  1. %l1 and %l2 contain pc and npc respectively at the time of the trap;

    %l1°ú %l2Àº trap½Ã °¢°¢ pc¿Í npc¸¦ Æ÷ÇÔÇÑ´Ù.:

  2. traps are disabled;

    trapÀº disableµÈ´Ù.:

  3. you are in the correct trap window.

    ¿©·¯ºÐÀº Á¤È®ÇÑ trap window¾È¿¡ ÀÖ´Ù.

As long as your trap handler can guarantee those conditions, then there is no reason why you shouldn't be able to "share" traps with the stub. The stub has no requirement that it be jumped to directly from the hardware trap vector. That is why it calls exceptionHandler(), which is provided by the external environment. For instance, this could set up the hardware traps to actually execute code which calls the stub first, and then transfers to its own trap handler.

trap handler°¡ À̵é Á¶°ÇÀ» º¸ÀåÇÒ¼ö ÀÖ´Â ÇÑ, ¿©·¯ºÐÀÌ stub¸¦ °¡Áø trapÀ» °øÀ¯ÇؾßÇÏ´Â ÀÌÀ¯°¡ ¾ø´Ù. stub´Â hardware trap vector¿¡¼­ÀÇ Á÷Á¢ Á¡ÇÁ¸¦ ¿ä±¸ÇÏÁö ¾Ê´Â´Ù. ÀÌ°ÍÀÌ ¿ÜºÎ ȯ°æ¿¡¼­ Á¦°øÇÏ´Â exceptionHandler()¸¦ È£ÃâÇÏ´Â ÀÌÀ¯ÀÌ´Ù. ¿¹¸¦ µé¾î, ¿ì¼± stub¸¦ È£ÃâÇÑ Äڵ带 ½ÇÇàÇϵµ·Ï hardware trapÀ» ¼³Á¤ÇÒ¼ö ÀÖÀ¸¸ç ±×¸®°í ÀÚ½ÅÀÇ trap handler¿¡ Àü´ÞÇÑ´Ù

For the most point, there probably won't be much of an issue with "sharing" traps, as the traps we use are usually not used by the kernel, and often indicate unrecoverable error conditions. Anyway, this is all controlled by a table, and is trivial to modify. The most important trap for us is for ta 1. Without that, we can't single step or do breakpoints. Everything else is unnecessary for the proper operation of the debugger/stub.

ÀϹÝÀûÀ¸·Î, trap °øÀ¯½Ã ¸¹Àº ¸»Àº ¾øÀ» °ÍÀÌ´Ù. ¿Ö³ÄÇÏ¸é ¿ì¸®°¡ »ç¿ëÇÏ´Â trapÀº Ä¿³Î¿¡ ÀÇÇØ »ç¿ëµÇÁö ¾ÊÀ¸¸ç ÀÚÁÖ È¸º¹ÇÒ¼ö ¾ø´Â ¿¡·¯ Á¶°ÇµéÀ» °¡¸®Å°±â ¶§¹®ÀÌ´Ù. ¾î¶µç, ÀÌ°ÍÀº Å×ÀÌºí¿¡ ÀÇÇØ ¸ðµÎ Á¦¾îµÇ¸ç ¼öÁ¤µÈ´Ù. ¿ì¸®¿¡°Ô °¡Àå Áß¿äÇÑ trapÀº ta 1ÀÌ´Ù. ±×°ÍÀÌ ¾ø´Ù¸é, ¿ì¸®´Â ´ÜÀÏ stepÀ̳ª breakpoint¸¦ ÇÒ¼ö ¾ø´Ù. ±× ¹ÛÀÇ ¸ðµç °ÍÀº debugger/stub ÀÛµ¿¿¡ ºÒÇÊ¿äÇÏ´Ù.

From reading the stub, it's probably not obvious how breakpoints work. They are simply done by deposit/examine operations from GDB.

stub¸¦ ÀÐÀ»¶§, breakpoint°¡ ÀÛµ¿ÇÏ´Â ¹æ¹ýÀº ºÐ¸íÇÏÁö ¾Ê´Ù. À̰͵éÀº GDB¿¡¼­ ÀÛµ¿ °Ë»ç½Ã °£´ÜÈ÷ ÇàÇØÁø´Ù.

ROM Monitor Interface

ROM ¸ð´ÏÅÍ ÀÎÅÍÆäÀ̽º

Custom Protocols

Custom ÇÁ·ÎÅäÄÝ

Transport Layer

Àü¼Û Ãþ

Builtin Simulator

³»Àå Simulator


Go to the first, previous, next, last section, table of contents.