Logging disk access in Bochs

Programming, for all ages and all languages.
Post Reply
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Logging disk access in Bochs

Post by madanra »

I would like to log what is read from disk by an OS running in Bochs; is this possible? I tried logging 'HD' events, but every IO was logged so there was vastly too much data, when all I'm really wanting is a list of which sectors were read.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Logging disk access in Bochs

Post by turdus »

madanra wrote:I would like to log what is read from disk by an OS running in Bochs; is this possible? I tried logging 'HD' events, but every IO was logged so there was vastly too much data, when all I'm really wanting is a list of which sectors were read.
Put a logger into your readsector routine. Read this about how to write to bochs' output: http://wiki.osdev.org/Bochs#I.2FO_debugger_macros
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Logging disk access in Bochs

Post by Combuster »

Did both of you tried running "man grep"? Why introduce new code when you already have something that can do it?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Logging disk access in Bochs

Post by madanra »

@turdus:
This isn't actually for my OS, I'm actually running Windows 7 (which does work in Bochs, just), so I can't edit the OS.
@Combuster:
Ah, managed to find the information, using grep to get rid of most of the unimportant data and then find+replace to trim it down a bit more. I hadn't actually realised to begin with that the necessary information was actually in the log file, but it is there, if a little confusing - it says 'sector number', 'cylinder low' and 'cylinder high' despite the fact that it's using 28-bit LBA!
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Logging disk access in Bochs

Post by Solar »

madanra wrote:...and then find+replace to trim it down a bit more...
I hope that by "find + replace" you mean that you wrote...

Code: Select all

grep <searchstring> $1 | sed "s/<find>/<replace>/g"
...into a script somewhere. ;-)
Every good solution is obvious once you've found it.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Logging disk access in Bochs

Post by turdus »

Combuster wrote:Did both of you tried running "man grep"? Why introduce new code when you already have something that can do it?
Well, my bochs cannot log as much as I want, and it's not configurable (only at runtime, which is quite annoying). And I usually trust code only if it was written by me :-) Yes, you can call me paranoid :-D That's why I suggested an ultimate solution, but I didn't know it's not his/her own OS.
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Logging disk access in Bochs

Post by madanra »

Solar wrote:
madanra wrote:...and then find+replace to trim it down a bit more...
I hope that by "find + replace" you mean that you wrote...

Code: Select all

grep <searchstring> $1 | sed "s/<find>/<replace>/g"
...into a script somewhere. ;-)
Sorry, no :( I'm a Windows guy, I get confused without a GUI :P
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Logging disk access in Bochs

Post by Solar »

That's a problem that should be addressed. You may love or loathe the Unix shell, but it is a powerful and useful tool for any developer.

Actually, I consider a Windows without Cygwin installed to be crippled.
Every good solution is obvious once you've found it.
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Logging disk access in Bochs

Post by madanra »

Ooh, this forum has weird smilies, I used :P which normally would have shown I was (slightly) joking, but it replaced it with more of a :D smilie...
I do have Cygwin, and would probably switch to Linux if it wasn't for the lack of decent parental controls, which is an instant dealbreaker.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Logging disk access in Bochs

Post by Solar »

Every good solution is obvious once you've found it.
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Logging disk access in Bochs

Post by madanra »

I know there are options, but when I last tried actually using any of them, nothing was really up to standard. That was ~8 months ago though, the situation may have improved by now. I may well have a look again when I have the time.
Post Reply