5

I'm looking for such tool, to see state of CPU registers, eax, ebx, ecx, edx.

I've discovered cpuid:

 eax in    eax      ebx      ecx      edx
00000000 0000000d 756e6547 6c65746e 49656e69
00000001 000206a7 06100800 1f9ae3bf bfebfbff
00000002 76035a01 00f0b0ff 00000000 00ca0000
00000003 00000000 00000000 00000000 00000000
00000004 00000000 00000000 00000000 00000000
00000005 00000040 00000040 00000003 00001120
00000006 00000077 00000002 00000009 00000000
00000007 00000000 00000000 00000000 00000000
00000008 00000000 00000000 00000000 00000000
00000009 00000000 00000000 00000000 00000000
0000000a 07300803 00000000 00000000 00000603
0000000b 00000000 00000000 0000002c 00000006
0000000c 00000000 00000000 00000000 00000000
0000000d 00000000 00000000 00000000 00000000
80000000 80000008 00000000 00000000 00000000
80000001 00000000 00000000 00000001 28100800
80000002 20202020 49202020 6c65746e 20295228
80000003 65726f43 294d5428 2d356920 30303532
80000004 5043204b 20402055 30332e33 007a4847
80000005 00000000 00000000 00000000 00000000
80000006 00000000 00000000 01006040 00000000
80000007 00000000 00000000 00000000 00000100
80000008 00003024 00000000 00000000 00000000

However, ebx second line is changing, only.

  • 06100800
  • 04100800
  • 00100800
  • 02100800
  • 04100800

Nothing more.

Is it possible to monitor registers?

9
  • Exactly how CPUID helped you?
    – Braiam
    Commented Jan 30, 2014 at 2:36
  • No, only second line of ebx changes. Am I right, that eax,ebx,ecx,edx must are very dynamically change their values? Commented Jan 30, 2014 at 2:41
  • 1
    What tool did you use to dump that output?
    – slm
    Commented Jan 30, 2014 at 2:48
  • 2
    Is that output from cpuid -r?
    – slm
    Commented Jan 30, 2014 at 2:55
  • 3
    Maybe you're looking for the sysrq show-registers(p) command? Run echo 1 > /proc/sys/kernel/sysrq as root and then type Alt+SysRq+p. Commented Jan 30, 2014 at 9:51

3 Answers 3

3

If you were to look at the working registers on your cpu, then you are correct they will change a lot ( a very lot ).

If you were to write a program to inspect and dump the contents of the registers (and this is not too difficult if you know C, assembler language for your cpu and how to integrate the two (see GCC manual)), then you would not see them changing (much). Even though they are. So why is this?

So your program runs, runs some code (that sets up the registers to do what ever it is that it is doing). This code then samples the registers, but at this point the register values have all converged at what ever they need to be at when running this bit of code, so we end up printing the same values every time.

How do we, sensibly, look at the registers?

We need a thing called a debugger or a tracer.

  • A debugger allows you to set a break point somewhere that you wish to examine. You could set break-points in various places.

  • A tracer will record information at regular points, possibly after each instruction. (Tracers will make the program run slow, is it will be spending more time tracing that running the actual program.)

A debugger usually has a tracer. One type of tracer is single stepping, where you tell the program to do one instruction. Another is to tell it to trace (run and log trace info to a file).

2

The cpuid command does not do what you think it does. See Wikipedia CPUID article.

The first column (the one that mostly counts) is the value in eax before the cpuid instruction is executed, the other columns are the values of the respective registers afterwards. Therefore the values in the registers represent the same ID information that you get when running cpuid without -r, and so will not change, unless you change the CPU.

From Wikipedia:

EAX=1: … EBX[bits 31:24]) is used to identify the executing logical processor.”

[If it shows n different states, and you have n cores, then that would make sence.]


Note: This is not an answer of how to do what you want, but of why what you are doing does not do what you want. See my other answer, for how to do what you want.

0

I ran the following command and saw no changes either.

$ watch -d "cpuid -r"

I used this version:

$ cpuid --version
cpuid version 20130610
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .