# DTRACE treats int64_t as uint32_t on i386



## PMc (Dec 1, 2019)

Hi folks,
hope You can help me with use of the development tools:


```
# dtrace -Sn 'arc-available_memory { printf("%x %x", arg0, arg1); }'

DIFO 0x286450a0 returns D type (integer) (size 8)
OFF OPCODE      INSTRUCTION
00: 29010601    ldgs DT_VAR(262), %r1           ! DT_VAR(262) = "arg0"
01: 23000001    ret  %r1

NAME             ID   KND SCP FLAG TYPE
arg0             262  scl glb r    D type (integer) (size 8)

DIFO 0x286450f0 returns D type (integer) (size 8)
OFF OPCODE      INSTRUCTION
00: 29010701    ldgs DT_VAR(263), %r1           ! DT_VAR(263) = "arg1"
01: 23000001    ret  %r1

NAME             ID   KND SCP FLAG TYPE
arg1             263  scl glb r    D type (integer) (size 8)
dtrace: description 'arc-available_memory ' matched 1 probe
  0     14        none:arc-available_memory 2fb000 2
  0     14        none:arc-available_memory 4e000 2
  1     14        none:arc-available_memory ffffb000 2
  1     14        none:arc-available_memory ffffb000 2
  1     14        none:arc-available_memory ffffb000 2
  1     14        none:arc-available_memory 19000 2
  0     14        none:arc-available_memory d38000 2
```

As you can see, the negative values are just 32bit. But this probe delivers an `int64_t`, correctly mentioned in the intermediate code:  `size 8`, and the same probe is properly shown on an amd64 machine.

And when they are displayed as "%d", they do not even appear as negative:


```
1     14        none:arc-available_memory 81920 5
  1     14        none:arc-available_memory 69632 5
  1     14        none:arc-available_memory 4294955008 5
  1     14        none:arc-available_memory 4294955008 5
```

This is quite bad, and very misleading. So, what is going on here, or what am I doing wrong??

PMc


----------



## shkhln (Dec 1, 2019)

What does `dtrace -Sn 'BEGIN { printf("%d %x", (int64_t)-1, (int64_t)-1); }'` print on i386?


----------



## PMc (Dec 2, 2019)

```
#  dtrace -Sn 'BEGIN { printf("%d %x", (int64_t)-1, (int64_t)-1); }'

DIFO 0x286450a0 returns D type (integer) (size 8)
OFF OPCODE      INSTRUCTION
00: 25000001    setx DT_INTEGER[0], %r1         ! 0xffffffffffffffff
01: 23000001    ret  %r1

DIFO 0x286450f0 returns D type (integer) (size 8)
OFF OPCODE      INSTRUCTION
00: 25000001    setx DT_INTEGER[0], %r1         ! 0xffffffffffffffff
01: 23000001    ret  %r1
dtrace: description 'BEGIN ' matched 1 probe
CPU     ID                    FUNCTION:NAME
  1      1                           :BEGIN -1 ffffffffffffffff
```

I already tried to cast the arg0 value from the kernel in that way, but that doesn't  change anything.


----------

