397 Commits

Author SHA1 Message Date
Philippe Waroquiers
55c12b3a18 On a big application linking with gtk, using the compilation options
-ffunction-sections -fdata-sections and the linker option
-Wl,--gc-sections, --read-var-info=yes gives the following:

    valgrind: m_debuginfo/d3basics.c:973 (vgModuleLocal_evaluate_GX): Assertion 'aMax == ~(Addr)0' failed.

    host stacktrace:
    ==18521==    at 0x38057C54: show_sched_status_wrk (m_libcassert.c:308)
    ==18521==    by 0x38057F50: report_and_quit (m_libcassert.c:367)
    ==18521==    by 0x38058151: vgPlain_assert_fail (m_libcassert.c:432)
    ==18521==    by 0x3813F084: vgModuleLocal_evaluate_GX (d3basics.c:973)
    ==18521==    by 0x38098300: data_address_is_in_var (debuginfo.c:2769)
    ==18521==    by 0x38099E26: vgPlain_get_data_description (debuginfo.c:3298)
    ...

The problem is that -Wl,--gc-sections eliminates the unused functions
but keeps some debug info for the functions or their compilation units.
The dwarf entry has low and high pc, but both are equal to 0.
The dwarf reader of Valgrind is confused by this, as the varstack becomes
empty, while it should not. This then causes local (eliminated) variables
to be put in the global scope, leading afterwards to evaluation errors
when describing any other variables.

The fix is to also push something on the varstack when
a CU that has low and high pc given but with 0 value.
This is similar to the varstack_push done for a CU that has
no low pc, no high pc and no range.
Despite considerable effort to make a small reproducer, the problem
could only be produced with a big executable.
After the fix, everything was working properly.

The wrong behaviour for dwarf entries produce the following trace:
     <2><2ff291a>: Abbrev Number: 23 (DW_TAG_formal_parameter)
         DW_AT_name        : AET	
         DW_AT_decl_file   : 1	
         DW_AT_decl_line   : 243	
         DW_AT_type        : <2ff2811>	
         DW_AT_location    : 18288554	
      Recording this variable, with 1 PC range(s)
    ....
    <2ff291a> addVar: level 0: AET :: EdgeTableEntry*
      Loc=GX(final){[0x0,0x8]=50,[0x9,0x1d]=53,[0x1e,0x26]=51,[0x27,0x29]=53,[0x2a,0x2f]=51,[0x44,0x4a]=53,[0x4d,0x5e]=51,[0x5f,0x62]=53}
      FrB=none
      declared at: gdkpolyreg-generic.c:243
      ACQUIRE for range(s) [0x0,0xffffffff] 

The AET is a formal parameter of a function, but is wrongly added
at level 0, with a PC range covering the full space. It has a Loc GX
which uses non biased program counters (e.g. 0x0,0x8).
This dwarf entry will require a FrB (and registers when evaluating)
but no such things are available (or given) when evaluating a variable
in the global scope.

The fix is to handle compilation units with lo and hi pc == 0x0
similarly to a CU that has no lo and hi pc.
With this fix, valgrind --read-var-info=yes could properly
handle a big application with plenty of eliminated functions.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13941
2014-05-07 21:09:16 +00:00
Philippe Waroquiers
0a4b0b50a8 For the following c program:
main(int argc)
{
   typedef
      struct {
      int before_name;
      char name[argc];
      int after_name;
   }
   namet;
  namet n;

}

compiled with gcc 4.7.4, the trunk --read-var-info=yes gives:
parse_type_DIE: confused by:
 <2><51>: DW_TAG_structure_type
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 4	
     DW_AT_sibling     : <83>	

This is because that dwarf entry defines a struct with no size.
This happens when the struct has a VLA array in the middle
of a struct. This is a C gcc extension, and is a standard
feature of Ada.
The proper solution would be to have the size calculated at runtime,
using the gnat extensions or dwarf entries (to be generated by
the compiler).


The patch fixes this problem by defining the size of such structure
as 1 byte.
Another approach tried was to put the max possible size.
This had the disadvantage that any address on the stack was seen
as belonging to this variable.
This allows the description to work for the 1st byte of the variable
but cannot properly describe the 2nd and following bytes :
    (gdb) p &n
    $9 = (namet *) 0xbefbc070
    (gdb) mo c d 0xbefbc070
    Address 0xBEFBC070 len 1 not defined:
    Uninitialised value at 0xBEFBC070
    ==1396==  Location 0xbefbc070 is 0 bytes inside n.before_name,
    ==1396==  declared at crec.c:10, in frame #0 of thread 1
    (gdb) mo c d 0xbefbc071
    Address 0xBEFBC071 len 1 not defined:
    Uninitialised value at 0xBEFBC071
    ==1396==  Address 0xbefbc071 is on thread 1's stack
    (gdb) 

A possible refinement would be to use a huge size but have the
logic of variable description understanding this and describing
all between this var and hte next var on the stack as being
in the VLA variable.

In the meantime, the size 1 avoids --read-var-info=yes to fail.


Also, the 'goto bad_DIE' have been replaced by a macro
goto_bad_DIE that ensures the line nr at which the bad DIE has
been detected is reported in the error msg.
This makes it easier to understand what is the problem.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13938
2014-05-06 20:15:55 +00:00
Dejan Jevtic
958717766b mips64: Add an extra case for mips64 in ML_(get_CFA).
This patch resolves the issue with the memcheck/tests/dw4 on mips64 platform.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13895
2014-04-14 11:54:36 +00:00
Dejan Jevtic
6cb9b78f0d mips32/64: According to DWARF version 4 in DW_TAG_structure_type we can
have DW_AT_signature attribute. That wasn't the case in DWARF version 3.

From DWARF version 4:
If the complete declaration of a type has been placed in a separate type unit, 
an incomplete declaration of that type in the compilation unit may provide the
unique 64-bit signature of the type using a DW_AT_signature attribute.

This patch adds an extra field in TyStOrUn structure (typeR). This field is 
reference to other TyEnt that is placed in separate type unit. Because of the new
field in TyStOrUn structure we need to add an extra case in parse_type_DIE
that will put the right reference to other TyEnt and an extra case in
ML_(describe_type) that will describe type when the ty->Te.TyStOrUn.typeR field
is used.

This patch is resolving the problem with memcheck/tests/dw4 test when it's 
compiled with compiler that will emit DW_AT_signature under the DW_TAG_structure_type.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13891
2014-04-04 10:20:03 +00:00
Dejan Jevtic
eb40633b9b mips32: Add an extra case for mips32 in ML_(get_CFA) in witch Valgrind will call
compute_cfa to get the call frame address.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13890
2014-04-04 10:02:03 +00:00
Julian Seward
68a2a4ce01 Initial implementation of CFI based stack unwinding for arm64-linux.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13774
2014-01-13 00:21:09 +00:00
Julian Seward
3f6d211236 Add support for ARMv8 AArch64 (the 64 bit ARM instruction set).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13770
2014-01-12 12:54:00 +00:00
Dejan Jevtic
423d0643b9 mips32: Adding mips32/Android support to Valgrind.
Necessary changes to Valgrind to support mips32 on Android.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13767
2013-12-27 09:06:55 +00:00
Mark Wielaard
98a63bf1d4 Bug 327916 - DW_TAG_typedef may have no name
We already accepted DW_TAG_typedef without a name for Ada. But g++ for
OpenMP can also emit such nameless DW_TAG_typedefs. Just accept them.
Also fix up anonymous enum and typedef printing in tytypes.c.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13718
2013-11-24 17:19:35 +00:00
Mark Wielaard
e622570ce0 dwz compressed alternate .debug_info and .debug_str not read correctly.
Bug #327837. The buildid from the .gnu_debugaltlink section was parsed
incorrectly (from the wrong offset). Causing the debug alt file not to
be found.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13715
2013-11-20 11:54:38 +00:00
Julian Seward
dbf9b63605 Update copyright dates (20XY-2012 ==> 20XY-2013)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13658
2013-10-18 14:27:36 +00:00
Julian Seward
5f16bea2a7 Fix "Assertion '!di->soname' failed" on weird files.
Fixes #320661.  (Jiří Hruška, jirka@fud.cz)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13640
2013-10-14 12:02:15 +00:00
Julian Seward
82b31476a3 Recent libxul.so on ARM has more than 5000 CIEs. Increase N_CIEs,
therefore.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13565
2013-09-19 09:14:56 +00:00
Florian Krohm
a6c7a2893c Fix coregrind header files such that they can be included without
having to worry what other header files may have to be included
beforehand.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13549
2013-09-15 13:54:34 +00:00
Florian Krohm
5c4ba95a27 Fix inclusion of header files in coregrind. No pub_tool_*.h should be
included here.
Added pub_core_poolalloc.h and renamed pub_tool_inner.h to pub_core_inner.h.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13548
2013-09-15 10:42:26 +00:00
Julian Seward
d13136fcee check_uuid_matches: fix infinite loop following rewrite of this
function during big overhaul of the debuginfo reader earlier this
year.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13529
2013-09-04 06:17:44 +00:00
Bart Van Assche
de32048275 coregrind/m_debuginfo: Add VG_(DebugInfo_get_bss_avma)() and VG_(DebugInfo_get_bss_size)()
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13510
2013-08-24 17:52:26 +00:00
Julian Seward
4fe9a30352 Merge r13421:HEAD from branches/DISRV. This merges the debuginfo-server
stuff into the trunk.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13440
2013-07-02 08:07:15 +00:00
Julian Seward
4506ba7258 Minor improvements in debug printing for stabs reading.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13439
2013-07-02 07:11:14 +00:00
Julian Seward
931af9d057 Make the ppc64-linux .opd-reading machinery work in the new framework.
git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13434
2013-06-29 08:38:37 +00:00
Mark Wielaard
efcfc55b37 Bug 289360 parse_type_DIE confused by DW_TAG_enumeration_type.
GCC allows incomplete enums as GNU extension.
http://gcc.gnu.org/onlinedocs/gcc/Incomplete-Enums.html
These are marked as DW_AT_declaration and won't have a size.
They can only be used in declaration or as pointer types.
You can't allocate variables or storage using such an enum type.
So don't require a size for such enum types.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13433
2013-06-28 14:03:58 +00:00
Julian Seward
a2e5d25994 Exit a bit more gracefully if a request to get part of an image
exceeds the allowable range.  With this change, it should be
essentially impossible to crash V by feeding it invalid ELF or Dwarf.



git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13432
2013-06-27 20:31:36 +00:00
Julian Seward
e3116970fd Minimal changes needed to make this suitable for trunk:
* add a new flag --allow-mismatched-debuginfo to override the
  CRC32/build-id checks, if needed

* tidy up logic for finding files on the --extra-debuginfo-path
  and at the --debuginfo-server

* don't assert if connection to the debuginfo server is lost;
  instead print a reasonable message and quit.



git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13431
2013-06-27 17:39:15 +00:00
Julian Seward
d14f385579 Connect up the Mach-O reader to the new DiImage abstractions.
git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13430
2013-06-25 12:42:52 +00:00
Julian Seward
5ab0775dc8 Improve performance of CRC32 computations for files in the local filesystem.
git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13425
2013-06-10 08:34:26 +00:00
Julian Seward
68c9403938 Initial code for remote debuginfo server. Handles all ELF/Dwarf{2,3,4}
on Linux.  No Dwarf1, no Stabs, and MacOSX probably won't build.


git-svn-id: svn://svn.valgrind.org/valgrind/branches/DISRV@13423
2013-06-07 16:15:48 +00:00
Philippe Waroquiers
ac56e88053 fix 320211 Stack buffer overflow in ./coregrind/m_main.c with huge TMPDIR
* Addition of a function to compute size of buffer needed for VG_(mkstemp)
* Use it to dimension buffers for all VG_(mkstemp) calls.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13409
2013-05-26 21:09:20 +00:00
Julian Seward
4811687de2 Increase size of the CIEs array to 5000.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13378
2013-04-26 08:59:40 +00:00
Petar Jovanovic
c159bbeb8a Calculate offsets in read_dwarf2_lineblock based on is64
Reading header length and values in external line info was incorrect at
some places as it used offsets based on dw64 that came from .debug_info.
Instead, offsets should be calculated based on is64 from .debug_line.
This issue surfaced in MIPS64 port, and it was discussed at:

https://bugs.kde.org/show_bug.cgi?id=313267#c20


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13373
2013-04-19 15:23:44 +00:00
Mark Wielaard
1156c98b80 Simplify read_unitinfo_dwarf2. Only try to read the first DIE.
Bug #305513. We should only read the first DIE of a compilation unit.
Each compilation unit header is followed by a single DW_TAG_compile_unit
(or DW_TAG_partial_unit, but those aren't important here) and its children.
There is no reason to read any of the children at this point. If the first
DIE isn't a DW_TAG_compile_unit we are done, none of the child DIEs will
provide any useful information.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13369
2013-04-17 13:48:29 +00:00
Mark Wielaard
7d0adfcedc read_unitinfo_dwarf2 DW_FORM_ref_addr is address size in DWARF version 2.
Bug #305513 contained a patch for some extra robustness checks. But
the real cause of crashing in the read_unitinfo_dwarf2 DWARF reader
seemed to have been this issue where DWARF version 2 DWZ partial_units
were read and DW_FORM_ref_addr had an unexpected size. This combination
is rare. DWARF version 4 is the current default version of GCC.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13367
2013-04-11 17:55:39 +00:00
Petar Jovanovic
5dd4c02e39 mips: adding MIPS64LE support to Valgrind
Necessary changes to Valgrind to support MIPS64LE on Linux.
Minor cleanup/style changes embedded in the patch as well.
The change corresponds to r2687 in VEX.
Patch written by Dejan Jevtic and Petar Jovanovic.

More information about this issue:
https://bugs.kde.org/show_bug.cgi?id=313267


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13292
2013-02-27 23:17:33 +00:00
Philippe Waroquiers
352b1d384c Improves stacktrace unwinding on x86
* other platforms (e.g. amd64) are first trying to unwind
  with cfi info, then with the fp chain.
* fp unwind when code is compiled without frame pointer can
  fail and give incomplete stack traces (often terminating
  with a random program counter, causing a huge amount of
  recorded stack traces).

This patch improves unwinding on x86 by:
* first time an IP is unwound, do the unwind both with
  CFI technique and with fp technique.
  If results are identical, IP is inserted in a cache of
  'fp unwindable' IP
* following unwind of the same IP are then done directly
  either with fp unwind or with cfi, depending on the
  cached result of the check done during first unwind.

The cache is needed so as to avoid as much as possible cfi unwind,
as this is significantly slower than fp unwind.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13280
2013-01-30 23:18:11 +00:00
Philippe Waroquiers
ac3eaed237 Change the size of the hash table used to cache IP -> debuginfo to a prime nr
This change is based on rumours/legends/oral transmission of experience/...
that prime nrs are good to use for hash table size :).

If someone has a (short) explanation about why this is useful, 
that will be welcome.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13237
2013-01-17 23:57:35 +00:00
Philippe Waroquiers
1fcd318239 Small comment fix: .h specifies "all frames", implementation uses 8.
Two fixes could be done:
Either we fix the comments
or we increase N_FRAMES to be rather VG_DEEPEST_BACKTRACE.

We fix the comment for the following reason:
This is (at least for the moment) not performance critical.
as this is only called when an error is reported.
However, searching for local vars is extremely costly.
It is unlikely that an error is reported for a stack variable
which is more than 8 frames deeper than theframe in which
it is detected.

So, fix the comment, waiting for a complaint that a deeper
variable is not properly described.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13235
2013-01-16 22:07:02 +00:00
Florian Krohm
66925ec149 Fix a few compiler warnings on Darwin.
Patch Guy Harris (guy@alum.mit.edu). Part of fixing BZ 312980.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13231
2013-01-15 03:19:54 +00:00
Julian Seward
5e1f44be3a Fix a const issue in r13154.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13165
2012-12-06 18:23:20 +00:00
Julian Seward
5f8c0ab7ca When looking for a separate debug object, tolerate mismatched phdrs by
instead checking the shdrs:

  The separate .debug file has wrong phdrs. This isn't normally fatal
  since .debug files are never directly loaded. But since valgrind
  uses the phdrs to locate the build-id it will fail. The attached
  patch makes it so that the code falls back to using the shdrs to
  locate the NOTE sections so that the buildid can be matched anyway.

Fixes #305431.  (Mark Wielaard, mjw@redhat.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13160
2012-12-06 16:27:18 +00:00
Julian Seward
4180623ef8 Add a new command line flag, --extra-debuginfo-path=path, that allows
specification of an extra directory in which to look for debuginfo
objects.  Fixes #310792.  (Alex Chiang, achiang@canonical.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13154
2012-12-05 22:15:14 +00:00
Philippe Waroquiers
35156f7ede fix 310424 --read-var-info does not properly describe static variables
This patch changes the way static variables are
recorded by readdwarf3.c (when giving --read-var-info=yes),
improving the way such variables are described.

Currently:
A static variable does not have the DW_AT_external tag.
So, readdwarf3.c does not consider it a global variable.
It is rather considered a "local" variable.
When it is recorded, it is associated to a range of program counters
(the functions in the file where it is visible).
However, even if the static variable is only visible
in the source file where it is declared, it can in reality
be used by any range of program counters, typically
by having the address of the local variable passed
to other functions.

Such local variable can then only be described
when the program counter is in the range of program
counters for which it has been recorded.
However, this (local) description is obtained
by a kludge in debuginfo.c (around line 3285).

This kludge then produces a strange description,
telling that the variable has been declared in
frame 0 of a thread (see second example below).

The kludge is not always able to describe
the address (if the IP of the tid is in another file than
where the variable has been declared).

I suspect the kludge can sometimes describe the var as being
declared in an unrelated thread
(e.g. if an error is triggered by tid 5, but tid1 is by
luck in an IP corresponding to the recorded range).


The patch changes the way a static variable is recorded:
if DW_AT_external tag is found, a variable is marked as global.
If a variable is not external, but is seen when level is 1,
then we record the variable as a global variable (i.e.
with a full IP range).
This improves the way such static variable are described:
* they are described even if being accessed by other files.
* their description is not in an artificial "thread frame".




First example:
**************
a variable cannot be described because it is
accessed by a function in another file:

with the trunk:
==20410== ----------------------------------------------------------------
==20410==
==20410== Possible data race during read of size 4 at 0x600F54 by thread #1
==20410== Locks held: none
==20410==    at 0x4007E4: a (abc.c:42)
==20410==    by 0x4006BC: main (mabc.c:24)
==20410==
==20410== This conflicts with a previous write of size 4 by thread #2
==20410== Locks held: none
==20410==    at 0x4007ED: a (abc.c:42)
==20410==    by 0x400651: brussels_fn (mabc.c:9)
==20410==    by 0x4C2B54E: mythread_wrapper (hg_intercepts.c:219)
==20410==    by 0x4E348C9: start_thread (pthread_create.c:300)
==20410==
==20410== ----------------------------------------------------------------


with the patch:
==4515== ----------------------------------------------------------------
==4515==
==4515== Possible data race during read of size 4 at 0x600F54 by thread #1
==4515== Locks held: none
==4515==    at 0x4007E4: a (abc.c:42)
==4515==    by 0x4006BC: main (mabc.c:24)
==4515==
==4515== This conflicts with a previous write of size 4 by thread #2
==4515== Locks held: none
==4515==    at 0x4007ED: a (abc.c:42)
==4515==    by 0x400651: brussels_fn (mabc.c:9)
==4515==    by 0x4C2B54E: mythread_wrapper (hg_intercepts.c:219)
==4515==    by 0x4E348C9: start_thread (pthread_create.c:300)
==4515==
==4515== Location 0x600f54 is 0 bytes inside global var "static_global"
==4515== declared at mabc.c:4
==4515==
==4515== ----------------------------------------------------------------


Second example:
***************
When the kludge can describe the variable, it is strangely described
as being declared in a frame of a thread, while for sure the declaration
has nothing to do with a thread
With the trunk:
==20410== Location 0x600f68 is 0 bytes inside local var "static_global_a"
==20410== declared at abc.c:3, in frame #0 of thread 1

With the patch:
==4515== Location 0x600f68 is 0 bytes inside global var "static_global_a"
==4515== declared at abc.c:3

#include <stdio.h>

static int static_global_a = 0; //// <<<< this is abc.c:3




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13153
2012-12-05 21:08:24 +00:00
Florian Krohm
e7f4d4f57f Fix some casts that removed const-ness as pointed out by
GCC's -Wcast-qual.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13138
2012-11-24 19:41:54 +00:00
Florian Krohm
af66466ce4 Changes to allow compilation with -Wwrite-strings. That compiler option
is not used for testcases, just for valgrind proper.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13137
2012-11-23 16:17:43 +00:00
Florian Krohm
117196ac6d Char/HChar fixups for m_debuginfo and m_gdbserver.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13122
2012-11-15 04:27:04 +00:00
Florian Krohm
d0aa69c331 Fix more Char/HChar mixups. Closing in...
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13119
2012-11-10 22:29:54 +00:00
Julian Seward
5bbaebd031 Ignore ELF sections that have zero size. Fixes #309600.
(Dragos Tatulea, dragos.tatulea@gmail.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13109
2012-11-08 15:45:16 +00:00
Florian Krohm
25b18b0aa1 Char/HChar and constness fixes. Mostly cost center
on allocators which is always a const HChar *


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13089
2012-10-27 23:07:42 +00:00
Tom Hughes
2ba34ab159 Implement some extra DW_OPs - more constants and some unary operators.
Patch from Mark Wielaard on BZ#307038.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13010
2012-09-21 09:12:30 +00:00
Tom Hughes
106fc73f9c Rename CfiOp to CfiBinop in preparation for adding unary operators.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13009
2012-09-21 09:04:27 +00:00
Tom Hughes
68757c25a3 When processing DW_OP_plus_uconst make sure we record an add, not
whatever binary operation we happened to see last.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13008
2012-09-21 08:57:46 +00:00
Bart Van Assche
7672eb4cb5 valgrind: Support Xen toolstack process ioctls
From: Ian Campbell <Ian.Campbell@citrix.com>

Under Xen the toolstack is responsible for managing the domains in
the system, e.g. creating, destroying, and otherwise manipulating
them.

To do this it uses a number of ioctls on the /proc/xen/privcmd
device. Most of these (the MMAPBATCH ones) simply set things up such
that a subsequenct mmap call will map the desired guest memory. Since
valgrind has no way of knowing what the memory contains we assume
that it is all initialised (to do otherwise would require valgrind to
be observing the complete state of the system and not just the given
process).

The most interesting ioctl is XEN_IOCTL_PRIVCMD_HYPERCALL which
allows the toolstack to make arbitrary hypercalls. Although the
mechanism here is specific to the OS of the guest running the
toolstack the hypercalls themselves are defined solely by the
hypervisor. Therefore I have split support for this ioctl into a part
in syswrap-linux.c which handles the ioctl itself and passes things
onto a new syswrap-xen.c which handles the specifics of the
hypercalls themselves. Porting this to another OS should just be a
matter of wiring up syswrap-$OS.c to decode the ioctl and call into
syswrap-xen.c. In the future we may want to split this into
syswrap-$ARCH-xen.c but for now this is x86 only.

The hypercall coverage here is pretty small but is enough to get
reasonable(-ish) results out of the xl toolstack when listing,
creating and destroying domains.

One issue is that the hypercalls which are exlusively used by the
toolstacks (as opposed to those used by guest operating systems) are
not considered a stable ABI, since the hypervisor and the lowlevel
tools are considered a matched pair. This covers the sysctl and
domctl hypercalls which are a fairly large chunk of the support
here. I'm not sure how to solve this without invoking a massive
amount of duplication. Right now this targets the Xen unstable
interface (which will shortly be released as Xen 4.2), perhaps I can
get away with deferring this problem until the first change .

On the plus side the vast majority of hypercalls are not of interest
to the toolstack (they are used by guests) so we can get away without
implementing them.

Note: a hypercall only reads as many words from the ioctl arg
struct as there are actual arguments to that hypercall and the
toolstack only initialises the arguments which are used. However
there is no space in the DEFN_PRE_TEMPLATE prototype to allow this to
be communicated from syswrap-xen.c back to syswrap-linux.c. Since a
hypercall can have at most 5 arguments I have hackily stolen ARG8 for
this purpose.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12963
2012-09-09 18:30:17 +00:00