History log of /haiku-fatelf/src/apps/debugger/arch/Architecture.cpp
Revision Date Author Comments
# 59fcd810 06-Jan-2013 Rene Gollent <anevilyak@gmail.com>

Return an error if no frames were created.


# 5745a40d 31-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Rework how return values are handled.

- ArchitectureX86 now hands off the work for GetInstructionInfo() to
DisassemblerX86, since the latter has all the information we need
to properly classify and evaluate instructions. Correspondingly a
CpuState is passed down to it in order to perform address calculations
for the instruction if it's a jump or call instruction. The latter's
targets are then stored on the thread for later retrieval when
constructing a stack trace. Adjust X86_64 accordingly for the
signature changes. This also fixes a bug where Step Over would
sometimes result in a Step Into instead due to the previous
implementation of GetInstructionInfo() occasionally failing to
classify call instructions correctly.

- Architecture::CreateStackTrace() now takes an argument specifying
the address of the last executed function if applicable. This is used
to decide who/where to decode a return value from. Adjust callers.

- DwarfImageDebugInfo::_CreateReturnValue() uses the above information
in order to know directly who the caller it needs to look up a return
value for is, rather than trying to walk backwards to find them.
Type resolution is now also a bit more sophisticated due to various
cases where the subprogram entry didn't directly contain the return
type but referred to another DIE that did. Retrieving return value
now appears to work properly in all cases except when position
independent code is involved. The latter however will require
resolving the appropriate function address in the PLT, which will
need some additional work.


# cf2e209b 29-Dec-2012 Rene Gollent <anevilyak@gmail.com>

More improvements to return value handling.

- Thread now has a data member indicating if a subroutine was
executed during the last set of steps.
- ThreadHandler now sets the aforementioned state appropriate during
Step Over/Step Out.
- Architecture::CreateStackTrace() now takes a parameter indicating
whether return value retrieval is desired (based on aforementioned
thread value). Adjust callers accordingly.
- DwarfImageDebugInfo: If return value retrieval is requested, loop
backwards from the current IP to find the call instruction.


# 1167ae52 25-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Some optimizations for ThreadHandler.

- CreateStackTrace() now takes a parameter indicating whether or not
to try and retrieve full frame information. This in turn is passed
on to SpecificImageDebugInfo, where e.g. DwarfImageDebugInfo can
use it to avoid constructing variables and parameters. This is
used by ThreadHandler since, when it requests the top frame for
its stepping calculations, this additional data/work is completely
unnecessary.


# 717f11d4 25-Dec-2012 Rene Gollent <anevilyak@gmail.com>

Fix regression introduced in hrev43513.

- A mistake in variable renaming resulted Architecture::UpdateStackFrameCpuState()
no longer being called.


# 0838236c 27-Nov-2012 Rene Gollent <anevilyak@gmail.com>

Remove check.

- It can actually happen that an app crashes due to being at IP 0.
The short circuit was consequently preventing us from unwinding the
stack properly in such a case.


# 973ec3b1 16-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Fix naming.


# 26334a8a 15-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Fix unwinding of partial stack traces.

- Architecture::CreateStackTrace() now uses the last frame's
PreviousCpuState() as the basis to continue unwinding when passed
a partial trace to continue from, rather than the (incorrect) actual
cpu state of that frame, which would have resulted in the last frame
being duplicated in the trace.

- Renamed variables to be more clear.


# 16875b8c 14-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Make CreateStackTrace() more flexible.

CreateStackTrace() can now optionally be asked to limit the maximum
number of frames it tries to unwind. In conjunction, it can also be
passed an already existing partial stack trace, and be asked to
unwind more frames from it.


# 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


# 411fe797 12-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Add definition for return address register type.
- Add TODO wrt default instruction pointer rule.



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


# 2e3906da 11-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Set up correct stack pointer rule (value offset, not location offset).
- Init all registers to same value by default. gcc doesn't set up explicit CFI
for same-value registers, so assume any register follows that rule until
explicitly told otherwise (c.f. gdb/dwarf2-frame.c:793).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39817 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


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

Added AddressSize(), IsBigEndian, IsHostEndian().


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


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

* Register:
- Added a type constant describing the format of the register value.
- Added flag "is callee-preserved" indicating whether the ABI requires the
register to be preserved by a called function.
* CpuState: Added SetRegisterValue(), made GetRegisterValue() const.
* Added RegisterMap interface for mapping register indices between different
models.
* Architecture:
- Added CreateCpuState() version to create a clean CpuState.
- Added GetDwarfRegisterMaps(), which returns to RegisterMaps, converting
from and to DWARF register indices.
- Added ReadValueFromMemory() reading a value from the target team's memory.
The value type is specified by a type constant and the value return via a
BVariant.
- CreateStackTrace: No longer decide whether to adjust the instruction pointer
of the previous CPU state depending on who created the CPU state. Instead
compare it with the return address of the next frame. If they are equal it
obviously has to be adjusted.


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


# f66bd625 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Very much work in progress, not in a particularly working state. Haiku munged
a good part of the source tree, so I rather get those changes into the
repository before continuing.
The general aim of the work is to deal with multiple instances of the same
function, e.g. inlined or non-inlined inline functions or those weird duplicates
gcc (4 at least) seems to be generating for no apparent reason.
* Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function.
FunctionInstance represents a physical instance of a function (e.g. inlined
function at a particular address). A Function collects all FunctionInstances
referring to the same source code location.
* Moved the SourceCode property from FunctionDebugInfo to Function accordingly.
* Since SourceCode is no longer associated with a concrete function instance,
several methods dealing with statements have been removed and the
functionality has been provided through other means (e.g. TeamDebugModel or
SpecificImageDebugModel). This part is not yet completed.
* Introduced UserBreakpoint and UserBreakpointInstance. The user sets a
breakpoint at a source code location, which is represented by a
UserBreakpoint. Since that source location can be mapped to one address per
instance of the respective function, UserBreakpoint has a
UserBreakpointInstance per such function instance, which in turn refers to a
Breakpoint (an actual breakpoint at an address).
* Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly.


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


# 671ef9b0 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Some moving and renaming.
* Added TeamDebugInfo which serves as factory for ImageDebugInfos.
* Added the DWARF code to the build again. It's not used yet, though.


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


# 125e089e 26-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

ImageDebugInfo does now gather function debug infos from all available sources
on init, keeping the most expressive one for each function. The interface
changed accordingly, i.e. it is now possible to iterate through the functions
and FindFunction() is now called FunctionAtAddress(), not returning a reference
anymore.


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


# 1c6fd17f 25-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Pulled interface TeamMemory out of DebuggerInterface to make the arch and model
packages indepent of the latter.


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


# 2460bf46 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changes that should already have been part of r31228: StackFrame and
SourceView.
* Fixed the information flow problem in Architecture::CreateStackTrace()/
ArchitectureX86::UpdateStackCpuState() by introducing a virtual
UpdateStackFrameCpuState() which allows the architecture to update the CPU
state it generated before after the function the state belongs to is known.
That's where moving the instruction pointer to the previous instruction
happens now.


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


# 840c7653 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added StackFrame classification as syscall frame and added correct
identification for x86.
* For non-top stack frames adjust the instruction pointer so that it points to
the calling function instead of the return address.
* SourceView: Consider a syscall frame a non-top frame (the arrow is drawn
differently).


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


# 0b60fa86 20-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added DebuggerInterface::GetSymbolInfos() to get the symbols for an image.
* Added the beginnings of the debug info abstraction. Currently we can only load
the symbols via the debugger.
* Added a job to retrieve debug info for an image. Extended the GetStackTraceJob
to support waiting for image debug info to be loaded.
* Extended ImageInfo by text/data address and size.
* Removed StackFrameX86 and made StackFrame a simple non-polymorphic class
featuring all the needed data. The really architecture-dependent is in the
referenced CpuState already. Added Image* and FunctionDebugInfo* attributes,
referring to the image respectively debug info for the function hit by the
instruction pointer.
* Switched StrackTrace's StackFrame management from DoublyLinkedList to
BObjectList. This makes it more comfortable to use.
* Changed the code for creating stack traces:
- The creation of the StackTrace object and the main loop to collect the
frames are now located in the no longer virtual
Architecture::CreateStackTrace().
- The decision how to create a StackFrame is based on the instruction pointer.
If it hit a function for which debug info is available, the respective
DebugInfo::CreateStackFrame() is used, otherwise we fall back to the new
virtual Architecture::CreateStackFrame().
* Adjusted the stack trace view to also show function names (mangled ATM).


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


# c42fe1eb 18-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

More work on the architecture abstraction, particularly regarding information
about what registers the architecture has and how to get them from the CpuState.
Implemented the respective x86 part.


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


# a81bb42a 18-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Beginnings of the architecture abstraction.


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


# 973ec3b1ac4cf562fac548f7107b9e505bd4a3c0 16-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Fix naming.


# 26334a8a66a1365b8fbd135a9dacc8fe897b6d38 15-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Fix unwinding of partial stack traces.

- Architecture::CreateStackTrace() now uses the last frame's
PreviousCpuState() as the basis to continue unwinding when passed
a partial trace to continue from, rather than the (incorrect) actual
cpu state of that frame, which would have resulted in the last frame
being duplicated in the trace.

- Renamed variables to be more clear.


# 16875b8c58c43e778fdf41b99134285052e5a5bb 14-Dec-2011 Rene Gollent <anevilyak@gmail.com>

Make CreateStackTrace() more flexible.

CreateStackTrace() can now optionally be asked to limit the maximum
number of frames it tries to unwind. In conjunction, it can also be
passed an already existing partial stack trace, and be asked to
unwind more frames from it.


# 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


# 411fe79789a9b36aa784870177586598954b8549 12-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Add definition for return address register type.
- Add TODO wrt default instruction pointer rule.



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


# 2e3906da98838da37ac068539ba86f0659908136 11-Dec-2010 Rene Gollent <anevilyak@gmail.com>

- Set up correct stack pointer rule (value offset, not location offset).
- Init all registers to same value by default. gcc doesn't set up explicit CFI
for same-value registers, so assume any register follows that rule until
explicitly told otherwise (c.f. gdb/dwarf2-frame.c:793).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39817 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


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

Added AddressSize(), IsBigEndian, IsHostEndian().


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


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

* Register:
- Added a type constant describing the format of the register value.
- Added flag "is callee-preserved" indicating whether the ABI requires the
register to be preserved by a called function.
* CpuState: Added SetRegisterValue(), made GetRegisterValue() const.
* Added RegisterMap interface for mapping register indices between different
models.
* Architecture:
- Added CreateCpuState() version to create a clean CpuState.
- Added GetDwarfRegisterMaps(), which returns to RegisterMaps, converting
from and to DWARF register indices.
- Added ReadValueFromMemory() reading a value from the target team's memory.
The value type is specified by a type constant and the value return via a
BVariant.
- CreateStackTrace: No longer decide whether to adjust the instruction pointer
of the previous CPU state depending on who created the CPU state. Instead
compare it with the return address of the next frame. If they are equal it
obviously has to be adjusted.


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


# f66bd6256a87005ccaa493859ede2ca1601b8560 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Very much work in progress, not in a particularly working state. Haiku munged
a good part of the source tree, so I rather get those changes into the
repository before continuing.
The general aim of the work is to deal with multiple instances of the same
function, e.g. inlined or non-inlined inline functions or those weird duplicates
gcc (4 at least) seems to be generating for no apparent reason.
* Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function.
FunctionInstance represents a physical instance of a function (e.g. inlined
function at a particular address). A Function collects all FunctionInstances
referring to the same source code location.
* Moved the SourceCode property from FunctionDebugInfo to Function accordingly.
* Since SourceCode is no longer associated with a concrete function instance,
several methods dealing with statements have been removed and the
functionality has been provided through other means (e.g. TeamDebugModel or
SpecificImageDebugModel). This part is not yet completed.
* Introduced UserBreakpoint and UserBreakpointInstance. The user sets a
breakpoint at a source code location, which is represented by a
UserBreakpoint. Since that source location can be mapped to one address per
instance of the respective function, UserBreakpoint has a
UserBreakpointInstance per such function instance, which in turn refers to a
Breakpoint (an actual breakpoint at an address).
* Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly.


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


# 671ef9b08426d9131bbea63d1ba4177c6f497d70 27-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Some moving and renaming.
* Added TeamDebugInfo which serves as factory for ImageDebugInfos.
* Added the DWARF code to the build again. It's not used yet, though.


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


# 125e089e1a1a17b89ea7537d9265634ea873333a 26-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

ImageDebugInfo does now gather function debug infos from all available sources
on init, keeping the most expressive one for each function. The interface
changed accordingly, i.e. it is now possible to iterate through the functions
and FindFunction() is now called FunctionAtAddress(), not returning a reference
anymore.


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


# 1c6fd17f75bd67d7135d31ffb138e19abec4de89 25-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Pulled interface TeamMemory out of DebuggerInterface to make the arch and model
packages indepent of the latter.


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


# 2460bf468bd81eb00457e5e0137c736ffa8ffda4 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changes that should already have been part of r31228: StackFrame and
SourceView.
* Fixed the information flow problem in Architecture::CreateStackTrace()/
ArchitectureX86::UpdateStackCpuState() by introducing a virtual
UpdateStackFrameCpuState() which allows the architecture to update the CPU
state it generated before after the function the state belongs to is known.
That's where moving the instruction pointer to the previous instruction
happens now.


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


# 840c76534f7caaca52752d147778a4929e66c361 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added StackFrame classification as syscall frame and added correct
identification for x86.
* For non-top stack frames adjust the instruction pointer so that it points to
the calling function instead of the return address.
* SourceView: Consider a syscall frame a non-top frame (the arrow is drawn
differently).


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


# 0b60fa86e977411b90631a7a177c4b93c18106e1 20-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added DebuggerInterface::GetSymbolInfos() to get the symbols for an image.
* Added the beginnings of the debug info abstraction. Currently we can only load
the symbols via the debugger.
* Added a job to retrieve debug info for an image. Extended the GetStackTraceJob
to support waiting for image debug info to be loaded.
* Extended ImageInfo by text/data address and size.
* Removed StackFrameX86 and made StackFrame a simple non-polymorphic class
featuring all the needed data. The really architecture-dependent is in the
referenced CpuState already. Added Image* and FunctionDebugInfo* attributes,
referring to the image respectively debug info for the function hit by the
instruction pointer.
* Switched StrackTrace's StackFrame management from DoublyLinkedList to
BObjectList. This makes it more comfortable to use.
* Changed the code for creating stack traces:
- The creation of the StackTrace object and the main loop to collect the
frames are now located in the no longer virtual
Architecture::CreateStackTrace().
- The decision how to create a StackFrame is based on the instruction pointer.
If it hit a function for which debug info is available, the respective
DebugInfo::CreateStackFrame() is used, otherwise we fall back to the new
virtual Architecture::CreateStackFrame().
* Adjusted the stack trace view to also show function names (mangled ATM).


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


# c42fe1eb572377d133cc3650e49de2ec76e965a2 18-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

More work on the architecture abstraction, particularly regarding information
about what registers the architecture has and how to get them from the CpuState.
Implemented the respective x86 part.


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


# a81bb42a9321a3b8ccf7f92623237826ff8767f4 18-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Beginnings of the architecture abstraction.


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