[Lldb-commits] [lldb] r150990 - in /lldb/trunk/examples/lookup: Makefile main.cpp
Johnny Chen
johnny.chen at apple.com
Mon Feb 20 13:39:22 PST 2012
Author: johnny
Date: Mon Feb 20 15:39:21 2012
New Revision: 150990
URL: http://llvm.org/viewvc/llvm-project?rev=150990&view=rev
Log:
Fix examples/lookup/main.cpp.
Patch to fix the main.cpp compile error submitted by Dmitry Vyukov <dvyukov at google.com>.
Also add a Makefile, plus some modification to main.cpp.
Added:
lldb/trunk/examples/lookup/Makefile
Modified:
lldb/trunk/examples/lookup/main.cpp
Added: lldb/trunk/examples/lookup/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/lookup/Makefile?rev=150990&view=auto
==============================================================================
--- lldb/trunk/examples/lookup/Makefile (added)
+++ lldb/trunk/examples/lookup/Makefile Mon Feb 20 15:39:21 2012
@@ -0,0 +1,13 @@
+LEVEL = ../../test/make
+
+CXX_SOURCES := main.cpp
+
+MY_OS = $(shell uname -s)
+ifeq "$(MY_OS)" "Darwin"
+ LD_EXTRAS ?= -framework LLDB
+ FRAMEWORK_INCLUDES=-F/Volumes/data/lldb/svn/trunk/build/Debug
+else
+ LD_EXTRAS ?= $(LLDB_BUILD_DIR)/_lldb.so
+endif
+
+include $(LEVEL)/Makefile.rules
Modified: lldb/trunk/examples/lookup/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/lookup/main.cpp?rev=150990&r1=150989&r2=150990&view=diff
==============================================================================
--- lldb/trunk/examples/lookup/main.cpp (original)
+++ lldb/trunk/examples/lookup/main.cpp Mon Feb 20 15:39:21 2012
@@ -10,15 +10,15 @@
#include <stdint.h>
#include <stdlib.h>
-#include "lldb/API/SBBlock.h"
-#include "lldb/API/SBCompileUnit.h"
-#include "lldb/API/SBDebugger.h"
-#include "lldb/API/SBFunction.h"
-#include "lldb/API/SBModule.h"
-#include "lldb/API/SBSymbol.h"
-#include "lldb/API/SBTarget.h"
-#include "lldb/API/SBThread.h"
-#include "lldb/API/SBProcess.h"
+#include "LLDB/SBBlock.h"
+#include "LLDB/SBCompileUnit.h"
+#include "LLDB/SBDebugger.h"
+#include "LLDB/SBFunction.h"
+#include "LLDB/SBModule.h"
+#include "LLDB/SBSymbol.h"
+#include "LLDB/SBTarget.h"
+#include "LLDB/SBThread.h"
+#include "LLDB/SBProcess.h"
using namespace lldb;
@@ -29,6 +29,14 @@
// and find all symbol context objects (if any) for that address:
// compile unit, function, deepest block, line table entry and the
// symbol.
+//
+// To build the program, type (while in this directory):
+//
+// $ make
+//
+// then:
+//
+// $ DYLD_FRAMEWORK_PATH=/Volumes/data/lldb/svn/ToT/build/Debug ./a.out executable_path file_address
//----------------------------------------------------------------------
int
main (int argc, char const *argv[])
@@ -44,9 +52,6 @@
// The second argument in the address that we want to lookup
lldb::addr_t file_addr = strtoull (argv[2], NULL, 0);
- // Make a file spec out of our executable path
- SBFileSpec exe_file_spec (exe_file_path);
-
// Create a debugger instance so we can create a target
SBDebugger debugger (SBDebugger::Create());
@@ -57,12 +62,14 @@
if (target.IsValid())
{
// Find the executable module so we can do a lookup inside it
+ SBFileSpec exe_file_spec (exe_file_path, true);
SBModule module (target.FindModule (exe_file_spec));
- SBAddress addr;
// Take a file virtual address and resolve it to a section offset
// address that can be used to do a symbol lookup by address
- if (module.ResolveFileAddress (file_addr, addr))
+ SBAddress addr = module.ResolveFileAddress (file_addr);
+ if (addr.IsValid())
+
{
// We can resolve a section offset address in the module
// and only ask for what we need. You can logical or together
More information about the lldb-commits
mailing list