[Lldb-commits] [PATCH] D22831: [LLDB] Documentation for SBAddress class

2017-04-04 Thread John Lindal via Phabricator via lldb-commits
jafl updated this revision to Diff 94112.
jafl added a comment.

Merged from master and ran clang-format


Repository:
  rL LLVM

https://reviews.llvm.org/D22831

Files:
  include/lldb/API/SBAddress.h

Index: include/lldb/API/SBAddress.h
===
--- include/lldb/API/SBAddress.h
+++ include/lldb/API/SBAddress.h
@@ -15,6 +15,97 @@
 
 namespace lldb {
 
+//--
+/// \class SBAddress
+///
+/// Represents an address.  An address may refer to code or data from an
+/// existing module (SBModule), or it may refer to something on the stack
+/// or heap.
+///
+/// SBAddress objects use two different kinds of addresses: file addresses
+/// and load addresses.
+///
+/// File addresses refer to the raw address as it is known in the object
+/// file that the module is using. File addresses will match the virtual
+/// addresses that are found in the object file, such as the address values
+/// in the symbols in the native symbol tables, unwind tables and any other
+/// data structures in the object file format (ELF, mach-o, COFF). File
+/// addresses are not unique across multiple modules as many modules might
+/// contain a file address of 0x0 (possibly the first function in the .text
+/// section) since many object files, like shared libraries, have their
+/// virtual addresses start at 0x0. Since file addresses are only unique
+/// within an SBModule, you must use a valid module object to resolve a
+/// file address into an SBAddress:
+///
+/// lldb::SBAddress SBModule::ResolveFileAddress (lldb::addr_t vm_addr);
+///
+/// File addresses are also useful in case you want to use other command
+/// line tools that know how to extract data from an object file, like
+/// objdump or many other tools that dump mach-o, ELF and COFF files.
+///
+/// Load addresses represent a unique location within a process' address
+/// space. A load address might represent a section/offset address within a
+/// process. In this case the SBAddress will have a valid section
+/// (lldb::SBAddress::GetSection() will return a SBSection that is valid),
+/// and a valid offset (lldb::addr_t lldb::SBAddress::GetOffset()) into
+/// that section. Or a load address might represent a unique location in
+/// the process' memory space that doesn't resolve to a section within an
+/// object file, like a location on the stack or heap. In this case the
+/// address will not have a valid section (lldb::SBSection
+/// lldb::SBAddress::GetSection() will return an SBSection that is *not*
+/// valid), and lldb::SBAddress::GetOffset() will return the value load
+/// address.  You can resolve a load address back into a SBAddress by using
+/// either of:
+///
+/// SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
+/// void SBAddress::SetLoadAddress (lldb::addr_t load_addr, lldb::SBTarget
+/// &target);
+///
+/// This will take the "load_addr" and figure out which section, if any,
+/// that the load address belongs to within the specified target. If
+/// "load_addr" belongs to a section, the resulting SBAddress objects will
+/// contain a valid section and offset (address that matches data in an
+/// object file's sections), otherwise it will have no section and the
+/// offset will match "load_addr" (stack or heap address).
+///
+/// If an address has a valid section, the address might refer to things
+/// found in the debug information:
+///
+/// SBModule - the module that contains the section
+/// SBCompileUnit - the source file that was compiled to create this code
+/// SBFunction - the function that contains this address
+/// SBBlock - the deepest lexical block that contains the address within the
+/// SBFucntion
+/// SBLineEntry - the file and line and column that contains the address
+/// SBVariable - the static/global variable that contains the address
+///
+/// If there is no debug information, then the address might also refer to
+/// a symbol from the symbol table:
+///
+/// SBSymbol - the symbol that contains the address
+///
+/// If an address comes from an existing module, then it will be resolved
+/// into an offset from its containing section in that module.  That way it
+/// can refer to the same logical location in the module that holds it even
+/// if the module is unloaded and loaded at different addresses.  Module
+/// based SBAddresses are not bound to a particular target or process, but
+/// you can ask the SBAddress where/if it has been loaded in a particular
+/// target.
+///
+/// The individual Get*() functions grab individual objects for a given
+/// address and are less efficient if you want more than one symbol related
+/// objects.  Use one of the following when you want multiple debug symbol
+/// related objects for an address:
+/// ~~~
+/// * lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t
+/// resolve_scope);
+/// * lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const
+/// SBA

[Lldb-commits] [PATCH] D32366: Set "success" status correctly

2017-04-21 Thread John Lindal via Phabricator via lldb-commits
jafl created this revision.
jafl added a project: LLDB.

In CommandObjectRegisterRead.DoExecute(), set the status to "success" when 
appropriate.


Repository:
  rL LLVM

https://reviews.llvm.org/D32366

Files:
  source/Commands/CommandObjectRegister.cpp


Index: source/Commands/CommandObjectRegister.cpp
===
--- source/Commands/CommandObjectRegister.cpp
+++ source/Commands/CommandObjectRegister.cpp
@@ -176,7 +176,9 @@
   set_idx = 
m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX,
  nullptr);
   if (set_idx < reg_ctx->GetRegisterSetCount()) {
-if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+if (DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
   if (errno)
 result.AppendErrorWithFormat("register read failed: %s\n",
  strerror(errno));
@@ -201,6 +203,7 @@
   // registers.
   DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx,
   !m_command_options.dump_all_sets.GetCurrentValue());
+  result.SetStatus(eReturnStatusSuccessFinishResult);
 }
   }
 } else {
@@ -225,7 +228,9 @@
   reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
 
   if (reg_info) {
-if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+if (DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+else
   strm.Printf("%-12s = error: unavailable\n", reg_info->name);
   } else {
 result.AppendErrorWithFormat("Invalid register name '%s'.\n",


Index: source/Commands/CommandObjectRegister.cpp
===
--- source/Commands/CommandObjectRegister.cpp
+++ source/Commands/CommandObjectRegister.cpp
@@ -176,7 +176,9 @@
   set_idx = m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX,
  nullptr);
   if (set_idx < reg_ctx->GetRegisterSetCount()) {
-if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+if (DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
   if (errno)
 result.AppendErrorWithFormat("register read failed: %s\n",
  strerror(errno));
@@ -201,6 +203,7 @@
   // registers.
   DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx,
   !m_command_options.dump_all_sets.GetCurrentValue());
+  result.SetStatus(eReturnStatusSuccessFinishResult);
 }
   }
 } else {
@@ -225,7 +228,9 @@
   reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
 
   if (reg_info) {
-if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+if (DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+else
   strm.Printf("%-12s = error: unavailable\n", reg_info->name);
   } else {
 result.AppendErrorWithFormat("Invalid register name '%s'.\n",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32366: Set "success" status correctly

2017-05-24 Thread John Lindal via Phabricator via lldb-commits
jafl added a comment.

Thanks for the suggestions.  I will get around to this - just swamped right now!


Repository:
  rL LLVM

https://reviews.llvm.org/D32366



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32366: Set "success" status correctly

2017-08-28 Thread John Lindal via Phabricator via lldb-commits
jafl added a comment.

I will try to ensure that the lldbassert gets tested, but right now, none of 
the tests work on my machine.  I emailed lldb-dev for help.


Repository:
  rL LLVM

https://reviews.llvm.org/D32366



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32366: Set "success" status correctly

2017-08-28 Thread John Lindal via Phabricator via lldb-commits
jafl updated this revision to Diff 112922.
jafl added a comment.

Added lldbassert


https://reviews.llvm.org/D32366

Files:
  source/Commands/CommandObjectRegister.cpp
  source/Interpreter/CommandInterpreter.cpp


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -68,6 +68,7 @@
 #include "lldb/Target/Thread.h"
 
 #include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/LLDBAssert.h"
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
@@ -1675,6 +1676,7 @@
   remainder.c_str());
 
 cmd_obj->Execute(remainder.c_str(), result);
+lldbassert(eReturnStatusStarted != result.GetStatus());
   } else {
 // We didn't find the first command object, so complete the first argument.
 Args command_args(command_string);
Index: source/Commands/CommandObjectRegister.cpp
===
--- source/Commands/CommandObjectRegister.cpp
+++ source/Commands/CommandObjectRegister.cpp
@@ -171,7 +171,9 @@
   set_idx = 
m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX,
  nullptr);
   if (set_idx < reg_ctx->GetRegisterSetCount()) {
-if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+if (DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
   if (errno)
 result.AppendErrorWithFormatv("register read failed: {0}\n",
   llvm::sys::StrError());
@@ -196,6 +198,7 @@
   // registers.
   DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx,
   !m_command_options.dump_all_sets.GetCurrentValue());
+  result.SetStatus(eReturnStatusSuccessFinishResult);
 }
   }
 } else {
@@ -220,7 +223,9 @@
   reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
 
   if (reg_info) {
-if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+if (DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+else
   strm.Printf("%-12s = error: unavailable\n", reg_info->name);
   } else {
 result.AppendErrorWithFormat("Invalid register name '%s'.\n",


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -68,6 +68,7 @@
 #include "lldb/Target/Thread.h"
 
 #include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/LLDBAssert.h"
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
@@ -1675,6 +1676,7 @@
   remainder.c_str());
 
 cmd_obj->Execute(remainder.c_str(), result);
+lldbassert(eReturnStatusStarted != result.GetStatus());
   } else {
 // We didn't find the first command object, so complete the first argument.
 Args command_args(command_string);
Index: source/Commands/CommandObjectRegister.cpp
===
--- source/Commands/CommandObjectRegister.cpp
+++ source/Commands/CommandObjectRegister.cpp
@@ -171,7 +171,9 @@
   set_idx = m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX,
  nullptr);
   if (set_idx < reg_ctx->GetRegisterSetCount()) {
-if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+if (DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
   if (errno)
 result.AppendErrorWithFormatv("register read failed: {0}\n",
   llvm::sys::StrError());
@@ -196,6 +198,7 @@
   // registers.
   DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx,
   !m_command_options.dump_all_sets.GetCurrentValue());
+  result.SetStatus(eReturnStatusSuccessFinishResult);
 }
   }
 } else {
@@ -220,7 +223,9 @@
   reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
 
   if (reg_info) {
-if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+if (DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info))
+  result.SetStatus(eReturnStatusSuccessFinishResult);
+else
   strm.Printf("%-12s = error: unavailable\n", reg_info->name);
   } else {
 result.AppendErrorWithFormat("Invalid register name '%s'.\n",
___
lldb-commits mailing list
lldb-commit

[Lldb-commits] [PATCH] D32366: Set "success" status correctly

2017-08-28 Thread John Lindal via Phabricator via lldb-commits
jafl added a comment.

Absolutely!


https://reviews.llvm.org/D32366



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits