Search Posts

Tutorial : Add a debug command in bochs

This tutorial teach you how to add a debug command in boots, you need to touch these files only:

  • debug.h
  • lexer.l
  • parser.y

Step 1) First of all, you need to add your command (see below) to lexer.l, don’t add anything below the line “[A-Za-z_][A-Za-z0-9_]* { bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }”, because it will eat up anything, although you can compile but your command won’t work. The “gkd” is my own boots command, you can place any command name you like.

gkd			{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GKD); }

Step 2) I created my own token “BX_TOKEN_GKD” for my command, you need to add it to parser.y, so please add “%token BX_TOKEN_GKD_R” to it. You also need a handler for your command in the parser, add these to parser.y

      BX_TOKEN_GKD '\n'

Step 3) In the handler, i called “some_function”. You need to add the prototype to debug.h and add the function body to

So in debug.h, add “void some_function();”

And in, add these:

void some_function(int which_regs_mask)
printf(“my boots debug command\n”);

!!! Thats all

Leave a Reply

Your email address will not be published. Required fields are marked *