ok, so it's not really a debugger, that's just what I call it. I'm making an application for my OS that lets you execute C commands on the system. The only problem is HOW? My puny libc contains printf(), pause(), reboot(), text(), reboot(), scanf(), run(), read(), strcmp() and strdef().
#include "kernel.h"
int i;
int main(void);
{
printf("Tide kernel debugger by St8ic and YOURNAME\n\r");
while(true)
printf(": ");
i=scanf();
printf("\n\r");
if(strcmp(i,"?")==true){
printf("Enter C code to execute it on system\n\r");
}else if(i,"?")==false){
???????????????????????????????????
I just don't know what to put there! It has to execute what ever the user enters in at that prompt as if it were the next line in the program. If you help me with it, I'd be happy to give you credit!
Thanks.
Help with kernel debugger?
RE:Help with kernel debugger?
Are you saying you essentially want to write a C interpreter for your debugger?!
That's an impressive feat, and certainly not easy!
Do you want the debugger to only allow a select number of functions to be called, or should it be able to call any methods available in your 'libc' (or 'libOS' or whatever )?
The former is certainly easier to code, but neither are simple.
You're probably going to want to look into string tokenizing, parsing, and compiler design... when I started writting my compiler I found Jack Crenshawe's 'How to Build a Compiler' articles very helpful. Some of them talk about writting interpreters as well.
You might also find it useful to take a look at the source to my compiler (inCode) on www.neuraldk.org It compiles to assembly language, but the idea isn't much different then an interpreter.
Anyway, toss out some more ideas... this sound interesting!
Cheers,
Jeff
That's an impressive feat, and certainly not easy!
Do you want the debugger to only allow a select number of functions to be called, or should it be able to call any methods available in your 'libc' (or 'libOS' or whatever )?
The former is certainly easier to code, but neither are simple.
You're probably going to want to look into string tokenizing, parsing, and compiler design... when I started writting my compiler I found Jack Crenshawe's 'How to Build a Compiler' articles very helpful. Some of them talk about writting interpreters as well.
You might also find it useful to take a look at the source to my compiler (inCode) on www.neuraldk.org It compiles to assembly language, but the idea isn't much different then an interpreter.
Anyway, toss out some more ideas... this sound interesting!
Cheers,
Jeff
RE:Help with kernel debugger?
As I said before, it's not a debugger at all. I just call it that for lack of a better term. I just want to execute whatever the user inputs e.g.:
Welcome to Tide Kernel Debugger!
:> printf("My anus is bleeding!\n\r");
My anus is bleeding!
:>
So I just need to execute the input as if it were a line in the debugger's program. It doesn't need to do more then one line at a time, or compile the code. If the only way I can do that is by writing an interpreter, so be it.
Do you think I could do it my way, or would I have to actualy write a C interpreter for it? I guess if the OS is gonna go somewhere, it will need a interpreter/compiler sooner or later...
Welcome to Tide Kernel Debugger!
:> printf("My anus is bleeding!\n\r");
My anus is bleeding!
:>
So I just need to execute the input as if it were a line in the debugger's program. It doesn't need to do more then one line at a time, or compile the code. If the only way I can do that is by writing an interpreter, so be it.
Do you think I could do it my way, or would I have to actualy write a C interpreter for it? I guess if the OS is gonna go somewhere, it will need a interpreter/compiler sooner or later...
RE:Help with kernel debugger?
you should definitly look at "C The Complete Reference":
http://www.amazon.com/exec/obidos/tg/de ... ce&s=books
it has a nice interpreter which is small and mostely compatible with C code, also,
it may be worth looking at "C++: The Complete Reference" which has basically the same this, but is more gears towards executing expressions (not whole programs).
Now, i know you are saying, "but i didn't write my OS in C++", well code is really very Cish, doesn't use many objects at all, only C++ish thing it did was use templates for different types of expressions (float vs int), but you can ditch that if you limit it to int.
good luck, you've actually given me a good idea for my OS as well
proxy
http://www.amazon.com/exec/obidos/tg/de ... ce&s=books
it has a nice interpreter which is small and mostely compatible with C code, also,
it may be worth looking at "C++: The Complete Reference" which has basically the same this, but is more gears towards executing expressions (not whole programs).
Now, i know you are saying, "but i didn't write my OS in C++", well code is really very Cish, doesn't use many objects at all, only C++ish thing it did was use templates for different types of expressions (float vs int), but you can ditch that if you limit it to int.
good luck, you've actually given me a good idea for my OS as well
proxy