Re: [Gems-users] Ruby magic instructions interference: Warning: in fn void magic_instruction_callback


Date: Wed, 16 May 2007 18:48:51 +0200
From: "Thomas De Schampheleire" <patrickdepinguin@xxxxxxxxx>
Subject: Re: [Gems-users] Ruby magic instructions interference: Warning: in fn void magic_instruction_callback
Hi,

When I execute for example
sethi 5031 %g0

then by having the following (python) handler:

def magic_callback(user_arg, cpu, n):
   print n

I get the value 5031, and not 5031 << 16 (as seems to be what you
expect in the ruby handler). I'm not sure if this is due Simics
version differences, but based on the behavior I see I don't
understand the shift in your code.

Anyway, as you suggested I will modify the commands.C handler to
ignore the '0' value.

Thanks, Thomas

On 5/16/07, Dan Gibson <degibson@xxxxxxxx> wrote:
The shift has been a subject of much confusion internally and among our
users, as some versions of ruby use shifted magic numbers and others do
not -- since the magic number is provided by a sethi instruction, the
original intent was to have "sethi 4 $g0" correspond to magic number 4,
for readability.

Nonetheless, the end result is the same. 6000 >> 16 is still 0, so Ruby
is still treating the value as unhandled, which is, inevitably, what you
probably want.

Regards,
Dan


Thomas De Schampheleire wrote:
> Hi,
>
> Thanks for the quick reply. See below:
>
> On 5/16/07, Dan Gibson <degibson@xxxxxxxx> wrote:
>
>> Ruby handles assumes magic instructions are directives passed to Ruby to
>> perform various tasks (eg. begin_transaction, etc.). Its actually a
>> *good* thing that you're seeing warnings -- its because Ruby doesn't
>> know how to interpret the magic number, and therefore isn't doing anything.
>>
>> You should have a look at commands.C to see what values Ruby associates
>> with various actions. So long as you don't use Ruby's magic numbers, you
>> will not incur any Ruby-strangeness due to magic calls.
>>
>> Since you're using magic number 0, you can safely ignore these warnings.
>> You can trivially modify commands.C to recognize "0" as a null command
>> and not print the warning at all.
>>
>
> Well, actually I'm using magic numbers in the range of 1000 upto 6000
> or something. However, I noticed that in the magic ruby code in
> commands.C, there is a right shift:
>   val = val >> 16;
> which effectively makes my magic numbers appear to be zero.
>
> Is there a particular reason why this shift takes place?
> Due to the shift, it seems that Ruby only uses magic numbers above
> 2^16 = 65 536.
>
> Thanks, thomas
>
>
>> Regards,
>> Dan
>>
>> Thomas De Schampheleire wrote:
>>
>>> Hi,
>>>
>>> I am using Simics 2.2.19 and Ruby release 1.2.
>>> I have added some magic instructions to the OpenSolaris kernel
>>> (UltraSPARC architecture), which are handled by my own callback
>>> function. This works as I expect.
>>>
>>> However, when adding Ruby to the simulation, I get warnings on every
>>> magic instruction:
>>>
>>> cpu0 [ cycle 56876262505L ]: [ magic 1021 ] disp_getwork()
>>> Warning: in fn void magic_instruction_callback(void*, void*,
>>> integer_t) in simics/commands.C:158: val is 0
>>> Warning: in fn void magic_instruction_callback(void*, void*,
>>> integer_t) in simics/commands.C:158: val is 0
>>> Warning: in fn void magic_instruction_callback(void*, void*,
>>> integer_t) in simics/commands.C:159: Unexpected magic call
>>> Warning: in fn void magic_instruction_callback(void*, void*,
>>> integer_t) in simics/commands.C:159: Unexpected magic call
>>>
>>> The first line is the line that is printed out by my own handler, and
>>> the subsequent four lines seem to come from Ruby code.
>>>
>>> Can I avoid having these warnings by using other numbers for my magic
>>> instructions? (which range of magic instructions is used by Ruby?)
>>> Can my magic instructions interfere with Ruby?
>>> Can I possibly turn off these warnings?
>>>
>>> Thank you,
>>> Thomas
>>> _______________________________________________
>>> Gems-users mailing list
>>> Gems-users@xxxxxxxxxxx
>>> https://lists.cs.wisc.edu/mailman/listinfo/gems-users
>>> Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.
>>>
>>>
>>>
>> --
>> http://www.cs.wisc.edu/~gibson [esc]:wq!
>>
>> _______________________________________________
>> Gems-users mailing list
>> Gems-users@xxxxxxxxxxx
>> https://lists.cs.wisc.edu/mailman/listinfo/gems-users
>> Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.
>>
>>
>>
> _______________________________________________
> Gems-users mailing list
> Gems-users@xxxxxxxxxxx
> https://lists.cs.wisc.edu/mailman/listinfo/gems-users
> Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.
>
>

--
http://www.cs.wisc.edu/~gibson [esc]:wq!

_______________________________________________
Gems-users mailing list
Gems-users@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/gems-users
Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.


[← Prev in Thread] Current Thread [Next in Thread→]