History log of /haiku-fatelf/src/apps/debugger/dwarf/DwarfFile.cpp
Revision Date Author Comments
# 855f2c88 25-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Add some more information to CIE parsing failure messages.


# b83bece1 23-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Cleanups.

- Add clarifying comment.
- Slightly adjust handling of augmentation 'P' so it also handles
skipping LEB128-encoded values correctly.
- Remove unused code.


# 16b8573b 23-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Numerous fixes to stack unwinding for .eh_frame.

- Add address size parameter to EvaluateExpression since the compilation
unit may not be available (i.e. in non-debug code). Accordingly, also
add accessor for address size to DwarfExpressionEvaluationContext,
and adjust callers accordingly.

- Correctly handle augmentation 'P'. This one consists of a data byte
describing the address encoding, followed by the address of the
personality function encoded in the aforementioned format. Not
skipping this correctly was resulting in us retrieving the wrong
FDE address format in e.g. CIEs encoded with augmentation 'zPLR'.

- The address range should be retrieved as value only without accounting
for the relative offset portion of the address encoding format. Fixes
some issues where we'd pick the wrong FDE to use for unwinding due
to us misinterpreting it as covering a far larger PC range than it
in fact did.

- DW_CFA_set_loc also needs to respect the encoded address format.

Overall, these changes fix a number of regressions introduced by the
previous commits, and also mean that stack unwinding for x86-64 should
now work as expected in all cases where either debug information or
an exception table is available.


# e76262c8 22-Dec-2012 Stefano Ceccherini <stefano@shiryu.(none)>

Fix build.


# 83a52221 21-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Cleanup.

- Rename _ParseCIEAugmentation to _ParseCIEHeader since that more
accurately reflects what it does.

- Refactor a bit to avoid having to parse the header twice, and
simplify various places as a result.


# 96a4619b 21-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Make use of augmentation if available.

- Pull out a _ParseCIEAugmentation() from _ParseCIE().

- If .eh_frame is being used, do a quick parse of the CIE up front
in order to determine the augmentation (if any), and use it to
retrieve addresses in the appropriate format. This fixes stack
unwinding on x86-64, and possibly other cases where the address
encoding didn't correspond to architectural target size in absolute
address format.


# b5105244 21-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Resolve TODO.

- We now handle augmentation 'zR', which in the case of gcc's
.eh_frame format specifies how the addresses in the FDEs are
encoded. Not actually used yet though since that will require
some refactoring of _UnwindCallFrame(), since we currently parse
the CIE too late to apply the above address size rules to the
initial offset + range. This is also the reason x86-64 stack unwind
currently fails, since the addresses there are, for most current tests
actually being encoded in 32-bit format rather than architecture
address size as should be the case for a standard DWARF debug_frame.


# 5bda396e 16-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Refactor Dwarf*DebugInfo to be able to work with limited info.

- DwarfImageDebugInfo and DwarfFile will now allow us to construct
DWARF debug info objects even if the only section available for
use is .eh_frame. This essentially allows us to use CFI-based
unwinding even for release executables (assuming C++ is involved),
which means we can properly unwind the stack even for binaries
compiled with fomit-frame-pointer. This becomes more important
for x86-64, since omit is the ABI default there.

- Pull a GetFunctionsFromSymbols() out of DebuggerImageDebugInfo. This
is shared between DebuggerImageDebugInfo and DwarfImageDebugInfo for
creating debug information entries in the absence of debugging
information.


# 7483c98d 05-Aug-2012 Ingo Weinhold <ingo_weinhold@gmx.de>

Debugger (and some friends): 64 bit fixes


# 224f7510 29-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Implement support for separate debug info files.

- When loading an image, we now check if it has a .gnu_debuglink section.
If so, we try to load the linked file for our symbolic debugging information.
The file is searched for with the following rules:
1) If self-contained app, app image is looked for in ./debug while
library/add-on images are looked for in ../debug/.
2) If the image in question is in one of the global locations
(/boot/{common,system,home/config}/{lib,add-ons}), we search
in develop/debug for the corresponding global dir.

Implements #8135.


# 6faa3c97 13-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Fix #8729.

- If we're asked to generate an entry for a tag we don't recognize,
return an error so don't then attempt to add a null/invalid entry into the
compilation unit's entry list and later crash dereferencing it.


# c4120026 11-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Refactor previous commit.

- Keep knowledge of the existence and need to search the different
frame sections contained within DwarfFile.


# dfa21dfe 11-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Fix #8508.

- When attempting to unwind the call frame, we now search for the appropriate
FDE in both .debug_frame and .eh_frame. This mirrors gdb's behavior and
works around the ever-changing whims of the gcc developers as to which
section the requisite FDE/CIE resides in.


# f4ee2d04 28-May-2012 Rene Gollent <anevilyak@gmail.com>

Slight and cleanup and fix potential section leak.


# dbf07c84 28-May-2012 Rene Gollent <anevilyak@gmail.com>

Fix problems unwinding call frames.

Our more recent build of gcc4 appears to have switched to using
.eh_frame for almost all useful call frame information when built
with debugging. Use a somewhat crude heuristic (size) to determine
if the .debug_frame section we've been given might actually be of use
or not (assuming it exists at all, this was inconsistent in my tests.
Sometimes apps had no .debug_frame at all, other times it was present
but was only roundabouts 100 bytes).

Fixes ticket #8508.


# 4ee20b83 15-Jul-2011 Rene Gollent <anevilyak@gmail.com>

In the case where the .eh_frame section was used, Debugger was reading the
exception table address at the wrong location, leading to totally bogus values
for the alignment factors and return register, which ultimately resulted in
failing to reconstruct the CFI. (.eh_frame Format reference:
http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html )

Fixes #7818.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0573015d 20-Jun-2011 Rene Gollent <anevilyak@gmail.com>

Introduce a flag in ExpressionEvaluationContext in order to distinguish between
cases where no object pointer is available vs the object pointer being present
but NULL, which would previously not be pushed onto the stack, leading to
expression evaluation failures.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42274 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 521f1d05 22-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Add some extra methods to DataReader which obtain a new reader with additional restrictions.
- Use new methods to simplify a few places in DwarfFile.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39918 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3e066cf 16-Dec-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced uses of obsolescent BReference[able] API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39869 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87d85ea3 11-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Refactor setting up the default register rules to happen in the Architecture
class in order to allow us to set up architecture specific default rules
for registers that aren't explicitly set by the CFI program.
- Set up default rule for EIP on x86.
- Theoretically set up a default rule for the stack pointer. Disabled for the
time being though until I determine why that rule's not yielding the expected
values for ESP in anything other than the top frame, though the other location
offset rules work as expected.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c65d3d30 07-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39756 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abd313a5 06-Dec-2010 Rene Gollent <anevilyak@gmail.com>

When parsing the CIE, the offset being passed to _ParseFrameInfoInstructions() was not taking the initial CIE offset into account. This led to completely the wrong instructions being parsed, which in turn resulted in stack frames for some functions failing to unwind correctly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39754 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5f0c5d52 06-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Dump CIE offset in hex format so as to be more readily comparable with the offsets presented by readelf.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39753 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9119091a 02-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f07f493d 02-Dec-2010 Rene Gollent <anevilyak@gmail.com>

When unwinding the stack frame, correctly account for the number of
bytes of augmentation data that were skipped. Fixes some of the problems
seen with, e.g. StyledEdit in the Debugger, though it doesn't help
explain the corresponding problems seen with gdb as well.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a5bb78d 12-Nov-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup: store and retrieve the relocation delta from
the evaluation context instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a1ce93b 11-Nov-2010 Rene Gollent <anevilyak@gmail.com>

When computing absolute addresses, take the image relocation
delta into account. Fixes retrieving the addresses and
consequently values of static variables.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39407 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be649db0 02-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for reading gcc 4 generated .eh_frame sections. The main
difference to gcc 2 .eh_frame sections is the initial location field in the
FDEs, which is a relocated absolute address with gcc 2, but a relative address
with gcc 4.
* Recognize and skip the additional augmentations gcc 4 puts in the .eh_frame
sections contain. We might want/need to interpret some of them, but, since
I haven't found actual documentation for them yet, currently they are just
ignored.
* DwarfFile::UnwindCallFrame():
- Correctly support CIE offsets in .eh_frame sections. Unlike in .debug_frame
they are current position relative back offsets.
- Cleaned up some debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39276 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 99d56d5f 23-Oct-2010 Rene Gollent <anevilyak@gmail.com>

Remove a few no longer needed debug traces, and
add a TODO note regarding gcc4's eh_frame format.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39072 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fae65704 22-Oct-2010 Rene Gollent <anevilyak@gmail.com>

anevilyak+bonefish: Fix several instances of off-by-one errors when
computing the data block for CFA expressions. This fixes unwinding the
stack frame on gcc4.4.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39047 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9669d085 07-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

GCC 2 .eh_frame: The CIE offset in an FDE isn't always relative to the
beginning of the section, but probably relative to the beginning of the data
for the respective compilation unit (which might even make it useful again,
since it could be used as negative offset to the CIE). Relaxed the check even
more, so we always override the CIE offset when parsing .eh_frame sections.
This makes the variables appear in another test app Axel kindly provided.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33941 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4663f6d4 07-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed incorrect check. Spotted by Axel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33930 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ac8569f 06-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Handle the "eh" CIE augmentation which can appear in a .eh_frame section.
Hopefully the last hurdle gcc 2 has prepared for preventing variables to show
up.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 797aaa4b 06-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

gcc 2.95.3 doesn't generate a .debug_frame section. Fortunately it generates a
.eh_frame section which seems to have almost identical contents (haven't found
any specification). So now we use .eh_frame with minor tweaks, when
.debug_frame is not available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 71f75cdc 06-Oct-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* WIP regarding non comilation unit local types:
- Introduced GlobalTypeLookup interface and GlobalTypeLookupContext to look
up types by name and cache them.
- TeamDebugInfo implementes GlobalTypeLookup iterating through all
ImageDebugInfos, which in turn iterate through all SpecificImageDebugInfos.
- DwarfImageDebugInfo iterates through all compilation units, using
a temporary DwarfStackFrameDebugInfo to create the type.
- DwarfStackFrameDebugInfo no longer caches the types itself, but uses
GlobalTypeLookupContext. It uses GlobalTypeLookup to look up types not
defined in the compilation unit.
- DwarfFile: Made expression evaluation more robust, so that it also works,
when no subroutine entry, frame pointer, and instruction pointer are
available (and not used by the expression).
Basically works already, although the wrong compilation unit might be used
when resolving values for global types. It's also horribly slow, when there
are many types in the stack frame.
* DwarfStackFrameDebugInfo::ResolveArrayElementLocation(): The element location
piece size was set incorrectly (multiplied by 8, although bytes were
expected).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33477 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4401e833 04-Oct-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Use correct tracing macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d82c6dd 26-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Clarified the location expression evaluation semantics -- the ValueLocations
returned by the DWARF layer need to be translated to be usable in the generic
code.
* DwarfFile::EvaluateDynamicValue(): Added optional parameter to return the type
of the evaluated value, if available.
* Added source language info attribute to CompilationUnit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e72ebfc 20-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* More work on retrieving local variable values. Address and compound types can
now be inspected. Still work in progress -- bit fields and arrays don't work
correctly yet nor does type lookup beyond the current compilation unit.
* Made most of the debugger output configurable via a config header. By default
it's much less noisy now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33217 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 85363120 21-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* ExpressionEvaluationContext::GetFrameBaseAddress(): Fixed incorrect error
return values (bool vs. status_t).
* _FindLocationExpression(): The base address was completely ignored, thus
if one was needed, the correct location expression wouldn't be found.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b312b9ff 18-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the implementation of ExpressionEvaluationContext. No functional changed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31632 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d315bfd5 16-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added class ValueLocation to represent a location of a value on the target
machine.
* DWARF:
- Various additions to the DIE classes.
- DwarfExpressionEvaluationContext:
- Added support for location expressions and thus the missing DW_OP_piece
and DW_OP_bit_piece operations.
- Fixed some deviations from the specs.
- Added debug output.
- DwarfFile:
- Added missing evaluation of CFA expression rules.
- Added service methods to evaluate expressions, location expressions,
and constant and dynamic values.
* Added model classes for representing types and variables. Particularly the
types part is not finished yet.
* StackFrame does now contain parameters and local variables.
* Added DwarfInterfaceFactory, which creates implementation objects for the
types, as well as variables objects. It's even less finished.
* DwarfImageDebugInfo::CreateFrame(): Resolve function parameters and add them
to the stack frame. No local variables yet.
* Added the beginnings of a variables view. Only lists the names of parameters
and local variables (of understood types) ATM.
* Renamed RegisterView to RegistersView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c33a74c 14-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Rather resolve range lists lazily. We need them for all functions, but there
are a lot more DIEs that have range lists.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 106c4d40 13-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of dwarf_{addr,off,size}_t. Consequently use 64 bit types instead.
* Made the DWARF code fully 64 bit aware (hopefully).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7526300 13-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* DWARF: Implemented parsing the DWARF frame info and evaluating it (save for
DWARF expressions). Several related new classes: CfaRule[Set], CfaContext,
DwarfTargetInterface (for accessing target registers and memory).
* Implemented DwarfImageDebugInfo::CreateFrame(), so the DWARF frame info is
used for unwinding the stack.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a07918f 03-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Work-around for gcc 2 output. It can produce DW_AT_sibling attributes
pointing to the end of the list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31386 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c93db3c1 03-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't require the .debug_str section. It's only needed for DW_FORM_strp
attributes, but apparently those aren't generated by gcc 2.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 593fa677 02-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* DWARF:
- DwarfUtils::GetDeclarationLocation(): Line/column numbers are one-based.
- Added line number program interpretation (LineNumberProgram).
* FunctionDebugInfo: Return the source file (LocatableFile) instead of the
file name.
* FileManager/LocatableEntry: Fixed handling when a LocatableEntry is
unreferenced. There was a race condition before, since an unreferenced entry
could be referenced and unreferenced again before removing it from the hash
table, which could lead to double deletion. Now we never reuse an unreferenced
entry and just remove it from the hash table when encountering one.
* FileManager/SourceFile: Added class SourceFile which loads a source file from
disk and slices it into lines. Managed by FileManager.
* Added class FileSourceCode, a SourceCode implementation using a SourceFile as
line provider. The statement management works pretty much exactly as in
DissassembledCode.
* DwarfImageDebugInfo: Implemented LoadSourceCode for real. It creates a
FileSourceCode and uses the DWARF line number information for the statement
information. This basically gets the source level view going, though there
are still several problems -- stepping doesn't work perfectly yet, the source
isn't found for all functions, there's no handling of duplicate functions (no
idea why gcc generates them in the first place), etc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7413cdde 30-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Add the compilation unit's compilation dir to the directories for the
compilation unit. It can be referenced by the file entries in the line info
header, too (index 0).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31331 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91c6759f 29-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added parsing the .debug_line header for each compilation unit and attaching
the include directory and source file names to CompilationUnit.
* Added DwarfUtils::GetDeclarationLocation() which retrieves the respective
source file name and line/column index for a given DIE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31325 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b60969c 29-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed ArchitectureTypes.h to Types.h.
* Created "types" subdirectory for basic types and moved Types.h,
SourceLocation, TargetAddressRange there.
* Added TargetAddressRangeList, representing a list of address ranges.
* Array: Added copy constructor and assignment operator.
* Added DwarfFunctionDebugInfo.
* ElfFile: Also read the program headers and provide access to the segment
information.
* DWARF:
- Some work on DIECompileUnitBase and DIESubprogram to handle attributes we
need.
- Added DwarfUtils class which provides static utility methods. Currently some
to get DIE names. Only provisionally implemented yet.
- Read range list attribute values from the .debug_ranges section. Extended
AttributeValue to handle them correctly (ref-counting).
* DwarfImageDebugInfo:
- Implemented GetFunctions() for real, i.e. we return functions for all
subprogram debug info entries we find (those that refer to actual
functions, that is).
- Implemented the fallback part of LoadSourceCode() (reading the code from the
file and disassembling it).

Things should hopefully work as before, just a bit slower and with less accurate
function names, if DWARF debug info is available. Promising, eh? ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31321 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c3612f4 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Manage CompilationUnits in a BObjectList instead of a DoublyLinkedList for
nicer access.
* A CompilationUnit does now know its debug info entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a7112b3 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renaming and coding moving.
* Added locking to DwarfManager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7483c98dece8f3606fc5d3fd746c0544f7e4b6dd 05-Aug-2012 Ingo Weinhold <ingo_weinhold@gmx.de>

Debugger (and some friends): 64 bit fixes


# 224f75100b15ee71dce0b0e551efd40236ca8b54 29-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Implement support for separate debug info files.

- When loading an image, we now check if it has a .gnu_debuglink section.
If so, we try to load the linked file for our symbolic debugging information.
The file is searched for with the following rules:
1) If self-contained app, app image is looked for in ./debug while
library/add-on images are looked for in ../debug/.
2) If the image in question is in one of the global locations
(/boot/{common,system,home/config}/{lib,add-ons}), we search
in develop/debug for the corresponding global dir.

Implements #8135.


# 6faa3c97662c81aaea1bfa5b6803bb33d733f6af 13-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Fix #8729.

- If we're asked to generate an entry for a tag we don't recognize,
return an error so don't then attempt to add a null/invalid entry into the
compilation unit's entry list and later crash dereferencing it.


# c4120026a5c8c365a57917ea923779c07df9aea0 11-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Refactor previous commit.

- Keep knowledge of the existence and need to search the different
frame sections contained within DwarfFile.


# dfa21dfeabe22cd7df5de50e21bf1ad3678454b8 11-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Fix #8508.

- When attempting to unwind the call frame, we now search for the appropriate
FDE in both .debug_frame and .eh_frame. This mirrors gdb's behavior and
works around the ever-changing whims of the gcc developers as to which
section the requisite FDE/CIE resides in.


# f4ee2d048e0d4e754b94ec1e5c271c2d3ecf96ec 28-May-2012 Rene Gollent <anevilyak@gmail.com>

Slight and cleanup and fix potential section leak.


# dbf07c84a22f5b395d00d66e7d3b0e1160cb2f13 28-May-2012 Rene Gollent <anevilyak@gmail.com>

Fix problems unwinding call frames.

Our more recent build of gcc4 appears to have switched to using
.eh_frame for almost all useful call frame information when built
with debugging. Use a somewhat crude heuristic (size) to determine
if the .debug_frame section we've been given might actually be of use
or not (assuming it exists at all, this was inconsistent in my tests.
Sometimes apps had no .debug_frame at all, other times it was present
but was only roundabouts 100 bytes).

Fixes ticket #8508.


# 4ee20b83b4a00bc90c97201695caab2f2a2d0385 15-Jul-2011 Rene Gollent <anevilyak@gmail.com>

In the case where the .eh_frame section was used, Debugger was reading the
exception table address at the wrong location, leading to totally bogus values
for the alignment factors and return register, which ultimately resulted in
failing to reconstruct the CFI. (.eh_frame Format reference:
http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html )

Fixes #7818.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0573015d14887ade1a081baa04dcb7f8da8d19b7 20-Jun-2011 Rene Gollent <anevilyak@gmail.com>

Introduce a flag in ExpressionEvaluationContext in order to distinguish between
cases where no object pointer is available vs the object pointer being present
but NULL, which would previously not be pushed onto the stack, leading to
expression evaluation failures.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42274 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 521f1d058d89a669cd62ab584379b15c48c8a944 22-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Add some extra methods to DataReader which obtain a new reader with additional restrictions.
- Use new methods to simplify a few places in DwarfFile.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39918 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3e066cf6d35a86d29396d4e740f9811e506b66c 16-Dec-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced uses of obsolescent BReference[able] API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39869 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87d85ea382bac0d2c83b5944ef807d4ec31fc111 11-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Refactor setting up the default register rules to happen in the Architecture
class in order to allow us to set up architecture specific default rules
for registers that aren't explicitly set by the CFI program.
- Set up default rule for EIP on x86.
- Theoretically set up a default rule for the stack pointer. Disabled for the
time being though until I determine why that rule's not yielding the expected
values for ESP in anything other than the top frame, though the other location
offset rules work as expected.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c65d3d305d2e80934144b7d7fba89f4f329b9724 07-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39756 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abd313a55cc6a8b448acc06367620f4e1fe0be06 06-Dec-2010 Rene Gollent <anevilyak@gmail.com>

When parsing the CIE, the offset being passed to _ParseFrameInfoInstructions() was not taking the initial CIE offset into account. This led to completely the wrong instructions being parsed, which in turn resulted in stack frames for some functions failing to unwind correctly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39754 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5f0c5d527ccc643ac1679c2ed14a95ef79510f22 06-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Dump CIE offset in hex format so as to be more readily comparable with the offsets presented by readelf.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39753 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9119091a714b37bcb07d076f15bf9e347bfd5bf7 02-Dec-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f07f493d2632dfd889c2bd03c95f6f92ad225adb 02-Dec-2010 Rene Gollent <anevilyak@gmail.com>

When unwinding the stack frame, correctly account for the number of
bytes of augmentation data that were skipped. Fixes some of the problems
seen with, e.g. StyledEdit in the Debugger, though it doesn't help
explain the corresponding problems seen with gdb as well.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a5bb78d9e1648a8f662d7baf8ee58133f95810e 12-Nov-2010 Rene Gollent <anevilyak@gmail.com>

Cleanup: store and retrieve the relocation delta from
the evaluation context instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a1ce93bc72bfa23e0f46642c256aa735fb80426 11-Nov-2010 Rene Gollent <anevilyak@gmail.com>

When computing absolute addresses, take the image relocation
delta into account. Fixes retrieving the addresses and
consequently values of static variables.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39407 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be649db06f135822fc89b2d3f22ecda51c3a4171 02-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for reading gcc 4 generated .eh_frame sections. The main
difference to gcc 2 .eh_frame sections is the initial location field in the
FDEs, which is a relocated absolute address with gcc 2, but a relative address
with gcc 4.
* Recognize and skip the additional augmentations gcc 4 puts in the .eh_frame
sections contain. We might want/need to interpret some of them, but, since
I haven't found actual documentation for them yet, currently they are just
ignored.
* DwarfFile::UnwindCallFrame():
- Correctly support CIE offsets in .eh_frame sections. Unlike in .debug_frame
they are current position relative back offsets.
- Cleaned up some debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39276 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 99d56d5f78a4ee0d0dcda6f9b168f50c53334408 23-Oct-2010 Rene Gollent <anevilyak@gmail.com>

Remove a few no longer needed debug traces, and
add a TODO note regarding gcc4's eh_frame format.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39072 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fae657041d430f82d0a414df31d84d2aec20b664 22-Oct-2010 Rene Gollent <anevilyak@gmail.com>

anevilyak+bonefish: Fix several instances of off-by-one errors when
computing the data block for CFA expressions. This fixes unwinding the
stack frame on gcc4.4.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39047 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9669d0859b38b41692fd48129fb43a1fb6d9df0e 07-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

GCC 2 .eh_frame: The CIE offset in an FDE isn't always relative to the
beginning of the section, but probably relative to the beginning of the data
for the respective compilation unit (which might even make it useful again,
since it could be used as negative offset to the CIE). Relaxed the check even
more, so we always override the CIE offset when parsing .eh_frame sections.
This makes the variables appear in another test app Axel kindly provided.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33941 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4663f6d46a94e09f20ed5a9c74c6f2700bf8a1b6 07-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed incorrect check. Spotted by Axel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33930 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ac8569f3cfc9557e2b4b793889364c1988eee36 06-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Handle the "eh" CIE augmentation which can appear in a .eh_frame section.
Hopefully the last hurdle gcc 2 has prepared for preventing variables to show
up.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 797aaa4bde26f541c4bfe77c0308e32ba513326b 06-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

gcc 2.95.3 doesn't generate a .debug_frame section. Fortunately it generates a
.eh_frame section which seems to have almost identical contents (haven't found
any specification). So now we use .eh_frame with minor tweaks, when
.debug_frame is not available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 71f75cdcdee748eb5e0841f8868ab8f477c0ee75 06-Oct-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* WIP regarding non comilation unit local types:
- Introduced GlobalTypeLookup interface and GlobalTypeLookupContext to look
up types by name and cache them.
- TeamDebugInfo implementes GlobalTypeLookup iterating through all
ImageDebugInfos, which in turn iterate through all SpecificImageDebugInfos.
- DwarfImageDebugInfo iterates through all compilation units, using
a temporary DwarfStackFrameDebugInfo to create the type.
- DwarfStackFrameDebugInfo no longer caches the types itself, but uses
GlobalTypeLookupContext. It uses GlobalTypeLookup to look up types not
defined in the compilation unit.
- DwarfFile: Made expression evaluation more robust, so that it also works,
when no subroutine entry, frame pointer, and instruction pointer are
available (and not used by the expression).
Basically works already, although the wrong compilation unit might be used
when resolving values for global types. It's also horribly slow, when there
are many types in the stack frame.
* DwarfStackFrameDebugInfo::ResolveArrayElementLocation(): The element location
piece size was set incorrectly (multiplied by 8, although bytes were
expected).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33477 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4401e83384d2ad44abbe0c7c30c5f451921a923f 04-Oct-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Use correct tracing macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d82c6dd73468afbd2eb531ff0decd283ac18061 26-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Clarified the location expression evaluation semantics -- the ValueLocations
returned by the DWARF layer need to be translated to be usable in the generic
code.
* DwarfFile::EvaluateDynamicValue(): Added optional parameter to return the type
of the evaluated value, if available.
* Added source language info attribute to CompilationUnit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e72ebfce3cb4969f9b27b4210d7631ba16948fa 20-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* More work on retrieving local variable values. Address and compound types can
now be inspected. Still work in progress -- bit fields and arrays don't work
correctly yet nor does type lookup beyond the current compilation unit.
* Made most of the debugger output configurable via a config header. By default
it's much less noisy now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33217 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8536312038bdfbf44510c8f3713741b675b7c3ef 21-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* ExpressionEvaluationContext::GetFrameBaseAddress(): Fixed incorrect error
return values (bool vs. status_t).
* _FindLocationExpression(): The base address was completely ignored, thus
if one was needed, the correct location expression wouldn't be found.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b312b9ff83533db4180541c13e9d3867b5661734 18-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the implementation of ExpressionEvaluationContext. No functional changed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31632 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d315bfd510d1dba20fe05a39ac455fe354ca1a96 16-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added class ValueLocation to represent a location of a value on the target
machine.
* DWARF:
- Various additions to the DIE classes.
- DwarfExpressionEvaluationContext:
- Added support for location expressions and thus the missing DW_OP_piece
and DW_OP_bit_piece operations.
- Fixed some deviations from the specs.
- Added debug output.
- DwarfFile:
- Added missing evaluation of CFA expression rules.
- Added service methods to evaluate expressions, location expressions,
and constant and dynamic values.
* Added model classes for representing types and variables. Particularly the
types part is not finished yet.
* StackFrame does now contain parameters and local variables.
* Added DwarfInterfaceFactory, which creates implementation objects for the
types, as well as variables objects. It's even less finished.
* DwarfImageDebugInfo::CreateFrame(): Resolve function parameters and add them
to the stack frame. No local variables yet.
* Added the beginnings of a variables view. Only lists the names of parameters
and local variables (of understood types) ATM.
* Renamed RegisterView to RegistersView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c33a74c011ff3b8d49c8d2aa199bc9113dfe16b 14-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Rather resolve range lists lazily. We need them for all functions, but there
are a lot more DIEs that have range lists.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 106c4d40208b9cddbc35e7492857e76cbb7f4460 13-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of dwarf_{addr,off,size}_t. Consequently use 64 bit types instead.
* Made the DWARF code fully 64 bit aware (hopefully).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7526300d9f03efec9b84583130db2d4d425fcef 13-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* DWARF: Implemented parsing the DWARF frame info and evaluating it (save for
DWARF expressions). Several related new classes: CfaRule[Set], CfaContext,
DwarfTargetInterface (for accessing target registers and memory).
* Implemented DwarfImageDebugInfo::CreateFrame(), so the DWARF frame info is
used for unwinding the stack.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a07918f6d4b1f910972dd41594b3b9212843159 03-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Work-around for gcc 2 output. It can produce DW_AT_sibling attributes
pointing to the end of the list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31386 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c93db3c16a199c33378d75d544da7a93df001cb9 03-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't require the .debug_str section. It's only needed for DW_FORM_strp
attributes, but apparently those aren't generated by gcc 2.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 593fa6776aecf8e722941718824b08338991555d 02-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* DWARF:
- DwarfUtils::GetDeclarationLocation(): Line/column numbers are one-based.
- Added line number program interpretation (LineNumberProgram).
* FunctionDebugInfo: Return the source file (LocatableFile) instead of the
file name.
* FileManager/LocatableEntry: Fixed handling when a LocatableEntry is
unreferenced. There was a race condition before, since an unreferenced entry
could be referenced and unreferenced again before removing it from the hash
table, which could lead to double deletion. Now we never reuse an unreferenced
entry and just remove it from the hash table when encountering one.
* FileManager/SourceFile: Added class SourceFile which loads a source file from
disk and slices it into lines. Managed by FileManager.
* Added class FileSourceCode, a SourceCode implementation using a SourceFile as
line provider. The statement management works pretty much exactly as in
DissassembledCode.
* DwarfImageDebugInfo: Implemented LoadSourceCode for real. It creates a
FileSourceCode and uses the DWARF line number information for the statement
information. This basically gets the source level view going, though there
are still several problems -- stepping doesn't work perfectly yet, the source
isn't found for all functions, there's no handling of duplicate functions (no
idea why gcc generates them in the first place), etc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7413cddee672f653c2fedf421c6bfa9f8a3d5467 30-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Add the compilation unit's compilation dir to the directories for the
compilation unit. It can be referenced by the file entries in the line info
header, too (index 0).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31331 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91c6759f30951d992778f67e76836d6a1cf52fe7 29-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added parsing the .debug_line header for each compilation unit and attaching
the include directory and source file names to CompilationUnit.
* Added DwarfUtils::GetDeclarationLocation() which retrieves the respective
source file name and line/column index for a given DIE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31325 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b60969c5cd42c27295bb89746ef6882c0559a7a 29-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed ArchitectureTypes.h to Types.h.
* Created "types" subdirectory for basic types and moved Types.h,
SourceLocation, TargetAddressRange there.
* Added TargetAddressRangeList, representing a list of address ranges.
* Array: Added copy constructor and assignment operator.
* Added DwarfFunctionDebugInfo.
* ElfFile: Also read the program headers and provide access to the segment
information.
* DWARF:
- Some work on DIECompileUnitBase and DIESubprogram to handle attributes we
need.
- Added DwarfUtils class which provides static utility methods. Currently some
to get DIE names. Only provisionally implemented yet.
- Read range list attribute values from the .debug_ranges section. Extended
AttributeValue to handle them correctly (ref-counting).
* DwarfImageDebugInfo:
- Implemented GetFunctions() for real, i.e. we return functions for all
subprogram debug info entries we find (those that refer to actual
functions, that is).
- Implemented the fallback part of LoadSourceCode() (reading the code from the
file and disassembling it).

Things should hopefully work as before, just a bit slower and with less accurate
function names, if DWARF debug info is available. Promising, eh? ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31321 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c3612f47db2deda55fca88459998e562ff97de4 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Manage CompilationUnits in a BObjectList instead of a DoublyLinkedList for
nicer access.
* A CompilationUnit does now know its debug info entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a7112b32d3c8f51a0e89ef2fc9d20a6a4c04159 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renaming and coding moving.
* Added locking to DwarfManager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31279 a95241bf-73f2-0310-859d-f6bbb57e9c96