gdb: fix conversion of gdb.Value to int

Python3 no longer has "long" type, and what was "long" on python2 is
now "int". To make the code portable commit
eb5eb91041bb6316b29c38679a4d575d40e860ed switched long() conversions
to int() conversion, which should be equivalent. It turns out that
GDB's implementation of gdb.Value, when compiled against python 2, has
a slight difference between int() and long() conversions. The long
conversion can be used on pointers whereas int conversion cannot. I
don't about any reason it should be like this, maybe it is a GDB bug:

This is int() handler:

      if (!is_intlike (type, 0))
	error (_("Cannot convert value to int."));
      l = value_as_long (value);

This is long() handler:

      if (!is_intlike (type, 1))
	error (_("Cannot convert value to long."));
      l = value_as_long (value);

Note the second argument to is_intlike() differs between variants, "1"
means "pointers allowed". Since on python3 int() conversion calls the
long handler, it works as expected. As a workaround for this I defined
to_int() function which performs the conversion in a portable way. This
needs to be done only when the value may be a pointer.

Places which check:

 if int(x) != 0:

can be simplified to:

 if x:

which works with both pointers and numbers in both versions.

Reported-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>