[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 92768.
nitesh.jain added a comment.

In case of MIPS, The ELFLinuxPrPsInfo.pr_uid and ELFLinuxPrPsInfo.pr_gid is 
always 32 bit irrespective of platforms


https://reviews.llvm.org/D30457

Files:
  source/Core/ArchSpec.cpp
  source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
  source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
  source/Plugins/Process/elf-core/ThreadElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.h

Index: source/Plugins/Process/elf-core/ThreadElfCore.h
===
--- source/Plugins/Process/elf-core/ThreadElfCore.h
+++ source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -65,18 +65,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxPrStatus);
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 72;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
@@ -97,18 +86,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(const lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxSigInfo);
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 12;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(const lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxSigInfo) == 12,
@@ -143,18 +121,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxPrPsInfo);
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 124;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxPrPsInfo) == 136,
Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -18,6 +18,8 @@
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@@ -118,6 +120,14 @@
   case llvm::Triple::aarch64:
 reg_interface = new RegisterInfoPOSIX_arm64(arch);
 break;
+  case llvm::Triple::mipsel:
+  case llvm::Triple::mips:
+reg_interface = new RegisterContextLinux_mips(arch);
+break;
+  case llvm::Triple::mips64el:
+  case llvm::Triple::mips64:
+reg_interface = new RegisterContextLinux_mips64(arch);
+break;
   case llvm::Triple::systemz:
 reg_interface = new RegisterContextLinux_s390x(arch);
 break;
@@ -153,7 +163,13 @@
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
+case llvm::Triple::mipsel:
+case llvm::Triple::mips:
+  m_thread_reg_

[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.
Herald added a subscriber: sdardis.

The MIPS core file doesn't contain any Architecture revision, OS and ABI 
information. Hence we need to relied on executable to get that information. 
This patch also add core file test cases for MIPS.

Patch By:- Bhushan


Repository:
  rL LLVM

https://reviews.llvm.org/D31280

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp

Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -214,9 +214,12 @@
   // Even if the architecture is set in the target, we need to override
   // it to match the core file which is always single arch.
   ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
 
+  // In case of MIPS, Core file doesn't have architecture revision and ABI
+  // information. Hence we need to relied on target architecture for that.
+  if (arch.IsValid() && !arch.IsMIPS())
+GetTarget().SetArchitecture(arch);
+ 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -370,6 +373,10 @@
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
+  // Don't proceed if core file doesn't contain the actual data for this address range.
+  if (file_start == file_end)
+return 0;
+
   // Figure out how many on-disk bytes remain in this segment
   // starting at the given offset
   if (file_end > file_start + offset)
@@ -588,6 +595,8 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
   thread_data->fpregset = note_data;
+else if(arch.IsMIPS())
+  thread_data->fpregset = note_data;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -655,6 +664,18 @@
   (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
   core_file->GetArchitecture(arch);
+
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  
+  if (target_arch.IsMIPS()) {
+// This is the case when executable doesn't contain any OS information.
+// Hence fall back to host triple OS.
+if (target_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) {
+  llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
+  target_arch.GetTriple().setOS(host_triple.getOS());
+}
+return target_arch;
+  }
   return arch;
 }
 
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -287,10 +287,26 @@
   return kal_arch_variant;
 }
 
-static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
-uint32_t endian) {
-  const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH;
+static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
+  const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
+  uint32_t endian = header.e_ident[EI_DATA];
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+
+  // If there aren't any elf flags available (e.g core elf file) then return default 
+  // 32 or 64 bit arch (without any architecture revision) based on object file's class.
+  if (header.e_type == ET_CORE) {
+switch (fileclass) {
+case llvm::ELF::ELFCLASS32:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el
+ : ArchSpec::eMIPSSubType_mips32;
+case llvm::ELF::ELFCLASS64:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el
+ : ArchSpec::eMIPSSubType_mips64;
+default:
+  return arch_variant;
+}
+  }
 
   switch (mips_arch) {
   case llvm::ELF::EF_MIPS_ARCH_1:
@@ -325,7 +341,7 @@
 
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF

[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Added test case for MIPS in https://reviews.llvm.org/D31280


https://reviews.llvm.org/D30457



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

They are around ~28KB


Repository:
  rL LLVM

https://reviews.llvm.org/D31280



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:675
+  llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
+  target_arch.GetTriple().setOS(host_triple.getOS());
+}

labath wrote:
> I'm not terribly happy with the default-to-host mode here, particularly as we 
> already have some code which detects linux in 
> ObjectFileELF::RefineModuleDetailsFromNote. I'm not terribly happy about that 
> either, but I hope we could at least have just one dodgy detection code.
> 
> Did you check whether it's possible to extend that function to cover mips as 
> well (probably the NT_FILE part, which searches for some `i386-linux-gnu` 
> paths in the binary) ?
In our case , files path doesn't contain any Linux string. 

nin@debian-co3-1:~/LLVM-new/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core$
 readelf -a linux-mips64el-gnuabi64.core
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, little endian
  Version:   1 (current)
  OS/ABI:UNIX - System V
  ABI Version:   0
  Type:  CORE (Core file)
  Machine:   MIPS R3000
  Version:   0x1
  Entry point address:   0x0
  Start of program headers:  64 (bytes into file)
  Start of section headers:  0 (bytes into file)
  Flags: 0x0
  Size of this header:   64 (bytes)
  Size of program headers:   56 (bytes)
  Number of program headers: 6
  Size of section headers:   0 (bytes)
  Number of section headers: 0
  Section header string table index: 0

There are no sections in this file.

There are no sections to group in this file.

Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
  NOTE   0x0190 0x 0x
 0x0644 0x 0x0
  LOAD   0x1000 0x00012000 0x
 0x1000 0x1000  R E0x1000
  LOAD   0x2000 0x00fff2a6 0x
 0x1000 0x1000  R  0x1000
  LOAD   0x3000 0x00fff2a61000 0x
 0x1000 0x1000  R E0x1000
  LOAD   0x4000 0x00c01000 0x
 0x2000 0x2000  RWE0x1000
  LOAD   0x6000 0x00fff000 0x
 0x 0x1000  RWE0x1000

There is no dynamic section in this file.

There are no relocations in this file.

The decoding of unwind sections for machine type MIPS R3000 is not currently 
supported.

Dynamic symbol information is not available for displaying symbols.

No version information found in this file.

Displaying notes found at file offset 0x0190 with length 0x0644:
  Owner Data size   Description
  CORE 0x01e0   NT_PRSTATUS (prstatus structure)
  CORE 0x0088   NT_PRPSINFO (prpsinfo structure)
  CORE 0x0080   NT_SIGINFO (siginfo_t data)
  CORE 0x0130   NT_AUXV (auxiliary vector)
  CORE 0x00aa   NT_FILE (mapped files)
Page size: 4096
 Start End Page Offset
0x00012000  0x000120001000  0x

/home/nin/LLVM-new/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out



Repository:
  rL LLVM

https://reviews.llvm.org/D31280



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:675
+  llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
+  target_arch.GetTriple().setOS(host_triple.getOS());
+}

labath wrote:
> nitesh.jain wrote:
> > labath wrote:
> > > I'm not terribly happy with the default-to-host mode here, particularly 
> > > as we already have some code which detects linux in 
> > > ObjectFileELF::RefineModuleDetailsFromNote. I'm not terribly happy about 
> > > that either, but I hope we could at least have just one dodgy detection 
> > > code.
> > > 
> > > Did you check whether it's possible to extend that function to cover mips 
> > > as well (probably the NT_FILE part, which searches for some 
> > > `i386-linux-gnu` paths in the binary) ?
> > In our case , files path doesn't contain any Linux string. 
> > 
> > nin@debian-co3-1:~/LLVM-new/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core$
> >  readelf -a linux-mips64el-gnuabi64.core
> > ELF Header:
> >   Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
> >   Class: ELF64
> >   Data:  2's complement, little endian
> >   Version:   1 (current)
> >   OS/ABI:UNIX - System V
> >   ABI Version:   0
> >   Type:  CORE (Core file)
> >   Machine:   MIPS R3000
> >   Version:   0x1
> >   Entry point address:   0x0
> >   Start of program headers:  64 (bytes into file)
> >   Start of section headers:  0 (bytes into file)
> >   Flags: 0x0
> >   Size of this header:   64 (bytes)
> >   Size of program headers:   56 (bytes)
> >   Number of program headers: 6
> >   Size of section headers:   0 (bytes)
> >   Number of section headers: 0
> >   Section header string table index: 0
> > 
> > There are no sections in this file.
> > 
> > There are no sections to group in this file.
> > 
> > Program Headers:
> >   Type   Offset VirtAddr   PhysAddr
> >  FileSizMemSiz  Flags  Align
> >   NOTE   0x0190 0x 0x
> >  0x0644 0x 0x0
> >   LOAD   0x1000 0x00012000 0x
> >  0x1000 0x1000  R E0x1000
> >   LOAD   0x2000 0x00fff2a6 0x
> >  0x1000 0x1000  R  0x1000
> >   LOAD   0x3000 0x00fff2a61000 0x
> >  0x1000 0x1000  R E0x1000
> >   LOAD   0x4000 0x00c01000 0x
> >  0x2000 0x2000  RWE0x1000
> >   LOAD   0x6000 0x00fff000 0x
> >  0x 0x1000  RWE0x1000
> > 
> > There is no dynamic section in this file.
> > 
> > There are no relocations in this file.
> > 
> > The decoding of unwind sections for machine type MIPS R3000 is not 
> > currently supported.
> > 
> > Dynamic symbol information is not available for displaying symbols.
> > 
> > No version information found in this file.
> > 
> > Displaying notes found at file offset 0x0190 with length 0x0644:
> >   Owner Data size   Description
> >   CORE 0x01e0   NT_PRSTATUS (prstatus structure)
> >   CORE 0x0088   NT_PRPSINFO (prpsinfo structure)
> >   CORE 0x0080   NT_SIGINFO (siginfo_t data)
> >   CORE 0x0130   NT_AUXV (auxiliary vector)
> >   CORE 0x00aa   NT_FILE (mapped files)
> > Page size: 4096
> >  Start End Page Offset
> > 0x00012000  0x000120001000  0x
> > 
> > /home/nin/LLVM-new/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
> > 
> That's a good point. In fact that is the case on the x86 core files as well 
> we have checked in as well, as their executables were linked statically. 
> Only, I guess in the x86 case we don't rely on the os that much.
> 
> Will this affect the ability of the tests to run reproducibly (on windows for 
> example), or will the os be picked up from the executable if it is present? 
> If it won't then we'll need to think hard about how to make the tests 
> deterministic.
If Host OS is windows then this test case will fail. The MIPS support freeBSD, 
Linux and Android.  The note.n_name == LLDB_NT_OWNER_GNU i

[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 92808.
nitesh.jain added a comment.

updated diff as per suggestion


https://reviews.llvm.org/D31280

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp

Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -214,9 +214,12 @@
   // Even if the architecture is set in the target, we need to override
   // it to match the core file which is always single arch.
   ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
 
+  // In case of MIPS, Core file doesn't have architecture revision and ABI
+  // information. Hence we need to relied on target architecture for that.
+  if (arch.IsValid() && !arch.IsMIPS())
+GetTarget().SetArchitecture(arch);
+ 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -370,6 +373,10 @@
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
+  // Don't proceed if core file doesn't contain the actual data for this address range.
+  if (file_start == file_end)
+return 0;
+
   // Figure out how many on-disk bytes remain in this segment
   // starting at the given offset
   if (file_end > file_start + offset)
@@ -588,6 +595,8 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
   thread_data->fpregset = note_data;
+else if(arch.IsMIPS())
+  thread_data->fpregset = note_data;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -655,6 +664,12 @@
   (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
   core_file->GetArchitecture(arch);
+
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  
+  if (target_arch.IsMIPS())
+return target_arch;
+
   return arch;
 }
 
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -287,10 +287,26 @@
   return kal_arch_variant;
 }
 
-static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
-uint32_t endian) {
-  const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH;
+static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
+  const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
+  uint32_t endian = header.e_ident[EI_DATA];
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+
+  // If there aren't any elf flags available (e.g core elf file) then return default 
+  // 32 or 64 bit arch (without any architecture revision) based on object file's class.
+  if (header.e_type == ET_CORE) {
+switch (fileclass) {
+case llvm::ELF::ELFCLASS32:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el
+ : ArchSpec::eMIPSSubType_mips32;
+case llvm::ELF::ELFCLASS64:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el
+ : ArchSpec::eMIPSSubType_mips64;
+default:
+  return arch_variant;
+}
+  }
 
   switch (mips_arch) {
   case llvm::ELF::EF_MIPS_ARCH_1:
@@ -325,7 +341,7 @@
 
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
-return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]);
+return mipsVariantFromElfFlags(header);
 
   return llvm::ELF::EM_CSR_KALIMBA == header.e_machine
  ? kalimbaVariantFromElfFlags(header.e_flags)
@@ -1348,6 +1364,10 @@
 }
 break;
   }
+  if (arch_spec.IsMIPS() &&
+  arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS)
+// The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
+arch_spec.GetTriple().setOS(llvm:

[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:220
+  // information. Hence we need to relied on target architecture for that.
+  if (arch.IsValid() && !arch.IsMIPS())
+GetTarget().SetArchitecture(arch);

labath wrote:
> Here you copy the architecture from core to target.
Actually we are skipping it , if the arch is MIPS ( ! arch.IsMIPS()).  


https://reviews.llvm.org/D31280



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-23 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

The core architecture doesn't have any revision, os and ABI information. Hence 
we need to relied on target architecture.


https://reviews.llvm.org/D31280



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 93130.
nitesh.jain added a comment.

Update diff as per suggestion.

Thanks


https://reviews.llvm.org/D31280

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp

Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -214,9 +214,12 @@
   // Even if the architecture is set in the target, we need to override
   // it to match the core file which is always single arch.
   ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
 
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  ArchSpec core_arch(m_core_module_sp->GetArchitecture());
+  target_arch.MergeFrom(core_arch);
+  GetTarget().SetArchitecture(target_arch);
+ 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -370,6 +373,10 @@
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
+  // Don't proceed if core file doesn't contain the actual data for this address range.
+  if (file_start == file_end)
+return 0;
+
   // Figure out how many on-disk bytes remain in this segment
   // starting at the given offset
   if (file_end > file_start + offset)
@@ -588,6 +595,8 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
   thread_data->fpregset = note_data;
+else if(arch.IsMIPS())
+  thread_data->fpregset = note_data;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -655,6 +664,12 @@
   (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
   core_file->GetArchitecture(arch);
+
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  
+  if (target_arch.IsMIPS())
+return target_arch;
+
   return arch;
 }
 
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -287,10 +287,26 @@
   return kal_arch_variant;
 }
 
-static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
-uint32_t endian) {
-  const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH;
+static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
+  const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
+  uint32_t endian = header.e_ident[EI_DATA];
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+
+  // If there aren't any elf flags available (e.g core elf file) then return default 
+  // 32 or 64 bit arch (without any architecture revision) based on object file's class.
+  if (header.e_type == ET_CORE) {
+switch (fileclass) {
+case llvm::ELF::ELFCLASS32:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el
+ : ArchSpec::eMIPSSubType_mips32;
+case llvm::ELF::ELFCLASS64:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el
+ : ArchSpec::eMIPSSubType_mips64;
+default:
+  return arch_variant;
+}
+  }
 
   switch (mips_arch) {
   case llvm::ELF::EF_MIPS_ARCH_1:
@@ -325,7 +341,7 @@
 
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
-return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]);
+return mipsVariantFromElfFlags(header);
 
   return llvm::ELF::EM_CSR_KALIMBA == header.e_machine
  ? kalimbaVariantFromElfFlags(header.e_flags)
@@ -1348,6 +1364,10 @@
 }
 break;
   }
+  if (arch_spec.IsMIPS() &&
+  arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS)
+// The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
+arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
 

[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Check if memory_info.GetName() is empty before finding corresponding module.

2017-03-31 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299196: [LLDB][MIPS] Check if memory_info.GetName() is empty 
before finding… (authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D30454?vs=91855&id=93614#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30454

Files:
  lldb/trunk/source/Core/DynamicLoader.cpp


Index: lldb/trunk/source/Core/DynamicLoader.cpp
===
--- lldb/trunk/source/Core/DynamicLoader.cpp
+++ lldb/trunk/source/Core/DynamicLoader.cpp
@@ -189,7 +189,8 @@
 MemoryRegionInfo memory_info;
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
-memory_info.GetRange().GetRangeBase() == base_addr) {
+memory_info.GetRange().GetRangeBase() == base_addr && 
+!(memory_info.GetName().IsEmpty())) {
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());


Index: lldb/trunk/source/Core/DynamicLoader.cpp
===
--- lldb/trunk/source/Core/DynamicLoader.cpp
+++ lldb/trunk/source/Core/DynamicLoader.cpp
@@ -189,7 +189,8 @@
 MemoryRegionInfo memory_info;
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
-memory_info.GetRange().GetRangeBase() == base_addr) {
+memory_info.GetRange().GetRangeBase() == base_addr && 
+!(memory_info.GetName().IsEmpty())) {
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-31 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299199: [LLDB][MIPS] Fix Core file Architecture and OS 
information. (authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D31280?vs=93130&id=93615#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31280

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -21,10 +21,14 @@
 _i386_pid = 32306
 _x86_64_pid = 32259
 _s390x_pid = 1045
+_mips64_n64_pid = 25619
+_mips64_n32_pid = 3670
+_mips_o32_pid = 3532
 
 _i386_regions = 4
 _x86_64_regions = 5
 _s390x_regions = 2
+_mips_regions = 5
 
 def setUp(self):
 super(LinuxCoreTestCase, self).setUp()
@@ -40,6 +44,18 @@
 """Test that lldb can read the process information from an i386 linux core file."""
 self.do_test("linux-i386", self._i386_pid, self._i386_regions)
 
+def test_mips_o32(self):
+"""Test that lldb can read the process information from an MIPS O32 linux core file."""
+self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions)
+
+def test_mips_n32(self):
+"""Test that lldb can read the process information from an MIPS N32 linux core file """
+self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions)
+
+def test_mips_n64(self):
+"""Test that lldb can read the process information from an MIPS N64 linux core file """
+self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions)
+
 @skipIf(oslist=['windows'])
 @skipIf(triple='^mips')
 def test_x86_64(self):
Index: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -214,9 +214,12 @@
   // Even if the architecture is set in the target, we need to override
   // it to match the core file which is always single arch.
   ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
 
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  ArchSpec core_arch(m_core_module_sp->GetArchitecture());
+  target_arch.MergeFrom(core_arch);
+  GetTarget().SetArchitecture(target_arch);
+ 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -370,6 +373,10 @@
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
+  // Don't proceed if core file doesn't contain the actual data for this address range.
+  if (file_start == file_end)
+return 0;
+
   // Figure out how many on-disk bytes remain in this segment
   // starting at the given offset
   if (file_end > file_start + offset)
@@ -652,6 +659,8 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
   thread_data->fpregset = note_data;
+else if(arch.IsMIPS())
+  thread_data->fpregset = note_data;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -719,6 +728,12 @@
   (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
   core_file->GetArchitecture(arch);
+
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  
+  if (target_arch.IsMIPS())
+return target_arch;
+
   return arch;
 }
 
Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins

[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-31 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299200: [LLDB][MIPS] Core Dump Support. (authored by 
nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D30457?vs=92768&id=93616#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30457

Files:
  lldb/trunk/source/Core/ArchSpec.cpp
  
lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
  lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
  lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
  lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
  lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp
  lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h

Index: lldb/trunk/source/Core/ArchSpec.cpp
===
--- lldb/trunk/source/Core/ArchSpec.cpp
+++ lldb/trunk/source/Core/ArchSpec.cpp
@@ -1380,7 +1380,7 @@
   if (core2 >= ArchSpec::kCore_mips32el_first &&
   core2 <= ArchSpec::kCore_mips32el_last)
 return true;
-  try_inverse = false;
+  try_inverse = true;
 }
 break;
 
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
@@ -22,6 +22,10 @@
 
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
+  const lldb_private::RegisterSet *GetRegisterSet(size_t set) const;
+
+  size_t GetRegisterSetCount() const;
+
   uint32_t GetRegisterCount() const override;
 
   uint32_t GetUserRegisterCount() const override;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
@@ -9,11 +9,33 @@
 
 #include "RegisterContextFreeBSD_mips64.h"
 #include "RegisterContextPOSIX_mips64.h"
+#include "lldb-mips-freebsd-register-enums.h"
 #include 
 
 using namespace lldb_private;
 using namespace lldb;
 
+static const uint32_t g_gpr_regnums[] = {
+gpr_zero_mips64,  gpr_r1_mips64,gpr_r2_mips64,gpr_r3_mips64,
+gpr_r4_mips64,gpr_r5_mips64,gpr_r6_mips64,gpr_r7_mips64,
+gpr_r8_mips64,gpr_r9_mips64,gpr_r10_mips64,   gpr_r11_mips64,
+gpr_r12_mips64,   gpr_r13_mips64,   gpr_r14_mips64,   gpr_r15_mips64,
+gpr_r16_mips64,   gpr_r17_mips64,   gpr_r18_mips64,   gpr_r19_mips64,
+gpr_r20_mips64,   gpr_r21_mips64,   gpr_r22_mips64,   gpr_r23_mips64,
+gpr_r24_mips64,   gpr_r25_mips64,   gpr_r26_mips64,   gpr_r27_mips64,
+gpr_gp_mips64,gpr_sp_mips64,gpr_r30_mips64,   gpr_ra_mips64,
+gpr_sr_mips64,gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
+gpr_cause_mips64, gpr_pc_mips64,gpr_ic_mips64,gpr_dummy_mips64};
+
+// Number of register sets provided by this context.
+constexpr size_t k_num_register_sets = 1;
+
+static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
+{"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
+ g_gpr_regnums},
+};
+
+
 // http://svnweb.freebsd.org/base/head/sys/mips/include/regnum.h
 typedef struct _GPR {
   uint64_t zero;
@@ -74,6 +96,19 @@
   return sizeof(GPR_freebsd_mips);
 }
 
+const RegisterSet *
+RegisterContextFreeBSD_mips64::GetRegisterSet(size_t set) const {
+   // Check if RegisterSet is available
+   if (set < k_num_register_sets)
+ return &g_reg_sets_mips64[set];
+   return nullptr;
+}
+
+size_t
+RegisterContextFreeBSD_mips64::GetRegisterSetCount() const {
+  return k_num_register_sets;
+}
+
 const RegisterInfo *RegisterContextFreeBSD_mips64::GetRegisterInfo() const {
   assert(m_target_arch.GetCore() == ArchSpec::eCore_mips64);
   return g_register_infos_mips64;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
@@ -7,8 +

[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-17 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.
Herald added subscribers: arichardson, mgorny.

Fix is to define _LARGEFILE_SOURCE and _FILE_OFFSET_BITS=64. This fix will 
cause llvm::sys::fs::file_size() to return correct object size.


Repository:
  rL LLVM

https://reviews.llvm.org/D32125

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -458,6 +458,12 @@
   option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
 endif()
 
+# If building on a 32-bit system, make sure off_t can store offsets > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 # Define the default arguments to use with 'lit', and an option for the user to
 # override.
 set(LIT_ARGS_DEFAULT "-sv")


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -458,6 +458,12 @@
   option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
 endif()
 
+# If building on a 32-bit system, make sure off_t can store offsets > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 # Define the default arguments to use with 'lit', and an option for the user to
 # override.
 set(LIT_ARGS_DEFAULT "-sv")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-18 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 95573.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D32125

Files:
  cmake/modules/HandleLLVMOptions.cmake


Index: cmake/modules/HandleLLVMOptions.cmake
===
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -222,6 +222,12 @@
   endif( LLVM_BUILD_32_BITS )
 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
 
+# If building on a 32-bit system, make sure off_t can store offsets > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 if( XCODE )
   # For Xcode enable several build settings that correspond to
   # many warnings that are on by default in Clang but are


Index: cmake/modules/HandleLLVMOptions.cmake
===
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -222,6 +222,12 @@
   endif( LLVM_BUILD_32_BITS )
 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
 
+# If building on a 32-bit system, make sure off_t can store offsets > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 if( XCODE )
   # For Xcode enable several build settings that correspond to
   # many warnings that are on by default in Clang but are
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-18 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D32125#728166, @krytarowski wrote:

> Is this just GNU specific? BSD moved to 64-bit off_t on 32-bit platforms 20+ 
> years ago.
>
> It's perhaps no-op, but it might be noted in the commit message what 
> platforms are supposed to be improved.


Yes.


https://reviews.llvm.org/D32125



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


[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure

2017-04-18 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.
Herald added a subscriber: arichardson.

In case of MIPS, we never add breakpoint in the delay slot. Hence while doing 
stepping, the delay slot instruction will be skipped.


https://reviews.llvm.org/D32168

Files:
  
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py


Index: 
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
===
--- 
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ 
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,12 +62,19 @@
 instructions = function.GetInstructions(self.target)
 addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
 addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
+delay_slot = 0
+addr_1_load_address = addr_1.GetLoadAddress(self.target)
+addr_4_load_address = addr_4.GetLoadAddress(self.target)
 for i in range(instructions.GetSize()) :
 addr = instructions.GetInstructionAtIndex(i).GetAddress()
+addr_load_address = addr.GetLoadAddress(self.target)
 if (addr == addr_1) : index_1 = i
-if (addr == addr_4) : index_4 = i 
+if (addr == addr_4) : index_4 = i
+if (addr_1_load_address <= addr_load_address <= 
addr_4_load_address):
+if (instructions.GetInstructionAtIndex(i).HasDelaySlot()) :
+delay_slot = delay_slot + 1
 
-steps_expected = index_4 - index_1
+steps_expected = index_4 - index_1 - delay_slot
 step_count = 0
 # Step from breakpoint_1 to breakpoint_4
 while True:


Index: packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
===
--- packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,12 +62,19 @@
 instructions = function.GetInstructions(self.target)
 addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
 addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
+delay_slot = 0
+addr_1_load_address = addr_1.GetLoadAddress(self.target)
+addr_4_load_address = addr_4.GetLoadAddress(self.target)
 for i in range(instructions.GetSize()) :
 addr = instructions.GetInstructionAtIndex(i).GetAddress()
+addr_load_address = addr.GetLoadAddress(self.target)
 if (addr == addr_1) : index_1 = i
-if (addr == addr_4) : index_4 = i 
+if (addr == addr_4) : index_4 = i
+if (addr_1_load_address <= addr_load_address <= addr_4_load_address):
+if (instructions.GetInstructionAtIndex(i).HasDelaySlot()) :
+delay_slot = delay_slot + 1
 
-steps_expected = index_4 - index_1
+steps_expected = index_4 - index_1 - delay_slot
 step_count = 0
 # Step from breakpoint_1 to breakpoint_4
 while True:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-21 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.
Herald added subscribers: arichardson, ki.stfu.

Call to s_MyFunction may not follow immediately after g_MyFunction. There might 
be some instructions in between to restore caller-saved registers. We need to 
get past these instructions with a step to reach call to s_MyFunction.


https://reviews.llvm.org/D32340

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
  packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
@@ -26,8 +26,8 @@
 main(int argc, char const *argv[])
 {
 printf("start");
-g_MyFunction();
-s_MyFunction();
+g_MyFunction(); // function_line_1
+s_MyFunction(); // function_line_2
 printf("exit");
 return 0;
 }
Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -284,6 +284,9 @@
 self.runCmd("-file-exec-and-symbols %s" % self.myexe)
 self.expect("\^done")
 
+self.g_MyFunction_line_no = line_number('main.cpp', "function_line_1")
+self.s_MyFunction_line_no = line_number('main.cpp', "function_line_2")
+
 # Run to main
 self.runCmd("-break-insert -f main")
 self.expect("\^done,bkpt={number=\"1\"")
@@ -320,7 +323,17 @@
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
 self.expect(
-
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(30|29)\"")
+
+finish_status = self.child.after
+string_to_match = 'line="{0}"'.format(self.g_MyFunction_line_no)
+
+# Call to s_MyFunction may not follow immediately after g_MyFunction.
+# There might be some instructions in between to restore caller-saved 
registers.
+# We need to get past these instructions with a step to reach call to 
s_MyFunction.
+
+if (finish_status.find(string_to_match) >= 0):
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
@@ -26,8 +26,8 @@
 main(int argc, char const *argv[])
 {
 printf("start");
-g_MyFunction();
-s_MyFunction();
+g_MyFunction(); // function_line_1
+s_MyFunction(); // function_line_2
 printf("exit");
 return 0;
 }
Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -284,6 +284,9 @@
 self.runCmd("-file-exec-and-symbols %s" % self.myexe)
 self.expect("\^done")
 
+self.g_MyFunction_line_no = line_number('main.cpp', "function_line_1")
+self.s_MyFunction_line_no = line_number('main.cpp', "function_line_2")
+
 # Run to main
 self.runCmd("-break-insert -f main")
 self.expect("\^done,bkpt={number=\"1\"")
@@ -320,7 +323,17 @@
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
 self.expect(
-"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(30|29)\"")
+
+finish_status = self.child.after
+string_to_match = 'line="{0}"'.format(self.g_MyFunction_line_no)
+
+# Call to s_MyFunction may not follow immediately after g_MyFunction.
+# There might be some instructions in between to restore caller-saved registers.
+# We need to get past these instructions with a step to reach call to s_MyFunction.
+
+if (finish_status.find(string_to_match) >= 0):
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-24 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 96368.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D32340

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -319,8 +319,14 @@
 # -exec-step can keep us in the g_MyFunction for gcc
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
-self.expect(
-
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+it = 
self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"",
+ 
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""])
+
+if it == 1:
+# Call to s_MyFunction may not follow immediately after 
g_MyFunction.
+# There might be some instructions in between to restore 
caller-saved registers.
+# We need to get past these instructions with a step to reach call 
to s_MyFunction.
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -319,8 +319,14 @@
 # -exec-step can keep us in the g_MyFunction for gcc
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
-self.expect(
-"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"",
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""])
+
+if it == 1:
+# Call to s_MyFunction may not follow immediately after g_MyFunction.
+# There might be some instructions in between to restore caller-saved registers.
+# We need to get past these instructions with a step to reach call to s_MyFunction.
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-24 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain marked an inline comment as done.
nitesh.jain added a comment.

In https://reviews.llvm.org/D32340#733387, @ki.stfu wrote:

> Thanks for catching this! Could you update this CL to let me commit it?


Yes , Please commit it.


https://reviews.llvm.org/D32340



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


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-24 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D32125#734500, @emaste wrote:

> In https://reviews.llvm.org/D32125#728166, @krytarowski wrote:
>
> > Is this just GNU specific? BSD moved to 64-bit off_t on 32-bit platforms 
> > 20+ years ago.
> >
> > It's perhaps no-op, but it might be noted in the commit message what 
> > platforms are supposed to be improved.
>
>
> I'd say it's better to put a comment in the source where it's set.


Added comment in the source.


https://reviews.llvm.org/D32125



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


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-24 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301171: [LLVM][MIPS] Fix different definition of off_t in 
LLDB and LLVM. (authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D32125?vs=95573&id=96374#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32125

Files:
  llvm/trunk/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
@@ -222,6 +222,13 @@
   endif( LLVM_BUILD_32_BITS )
 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
 
+# If building on a GNU specific 32-bit system, make sure off_t is 64 bits
+# so that off_t can stored offset > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 if( XCODE )
   # For Xcode enable several build settings that correspond to
   # many warnings that are on by default in Clang but are


Index: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
@@ -222,6 +222,13 @@
   endif( LLVM_BUILD_32_BITS )
 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
 
+# If building on a GNU specific 32-bit system, make sure off_t is 64 bits
+# so that off_t can stored offset > 2GB
+if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+  add_definitions( -D_LARGEFILE_SOURCE )
+  add_definitions( -D_FILE_OFFSET_BITS=64 )
+endif()
+
 if( XCODE )
   # For Xcode enable several build settings that correspond to
   # many warnings that are on by default in Clang but are
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-25 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D32125#736543, @sdardis wrote:

> Hi Nitesh,
>
> this commit broke clang-cmake-mips. Can you investigate?
>
> http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/3189
>
> Thanks,
> Simon


Hi Simon,

The assertion has been fixed.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D32125



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


[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure

2017-04-26 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 96722.
nitesh.jain added a comment.

Update diff as per suggestion


https://reviews.llvm.org/D32168

Files:
  include/lldb/API/SBAddress.h
  include/lldb/API/SBInstructionList.h
  
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  scripts/interface/SBInstructionList.i
  source/API/SBAddress.cpp
  source/API/SBInstructionList.cpp

Index: source/API/SBInstructionList.cpp
===
--- source/API/SBInstructionList.cpp
+++ source/API/SBInstructionList.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
@@ -49,6 +50,34 @@
   return inst;
 }
 
+size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
+  const SBAddress &end, 
+  bool canSetBreakpoint) {
+  size_t num_instructions = GetSize();
+  size_t i = 0;
+  SBAddress addr;
+  size_t lower_index = 0;
+  size_t upper_index = 0;
+  size_t instructions_to_skip = 0;
+  for (i = 0; i < num_instructions; ++i) {
+addr = GetInstructionAtIndex(i).GetAddress();
+if (start == addr)
+  lower_index = i;
+if (end == addr)
+  upper_index = i;
+  }
+  if (canSetBreakpoint)
+for (i = lower_index; i <= upper_index; ++i) {
+  if (!CanSetBreakpoint(i))
+++instructions_to_skip;
+}
+  return upper_index - lower_index - instructions_to_skip;
+}
+
+bool SBInstructionList::CanSetBreakpoint(size_t index) {
+  return !GetInstructionAtIndex(index).HasDelaySlot();
+}
+
 void SBInstructionList::Clear() { m_opaque_sp.reset(); }
 
 void SBInstructionList::AppendInstruction(SBInstruction insn) {}
Index: source/API/SBAddress.cpp
===
--- source/API/SBAddress.cpp
+++ source/API/SBAddress.cpp
@@ -55,6 +55,12 @@
   return *this;
 }
 
+bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
+  if (lhs.IsValid() && rhs.IsValid())
+return lhs.ref() == rhs.ref();
+  return false;
+}
+
 bool SBAddress::IsValid() const {
   return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
 }
Index: scripts/interface/SBInstructionList.i
===
--- scripts/interface/SBInstructionList.i
+++ scripts/interface/SBInstructionList.i
@@ -44,6 +44,11 @@
 lldb::SBInstruction
 GetInstructionAtIndex (uint32_t idx);
 
+size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+bool canSetBreakpoint);
+
+bool CanSetBreakpoint(size_t index);
+
 void
 Clear ();
 
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
===
--- packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,19 +62,11 @@
 instructions = function.GetInstructions(self.target)
 addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
 addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
-delay_slot = 0
-addr_1_load_address = addr_1.GetLoadAddress(self.target)
-addr_4_load_address = addr_4.GetLoadAddress(self.target)
-for i in range(instructions.GetSize()) :
-addr = instructions.GetInstructionAtIndex(i).GetAddress()
-addr_load_address = addr.GetLoadAddress(self.target)
-if (addr == addr_1) : index_1 = i
-if (addr == addr_4) : index_4 = i
-if (addr_1_load_address <= addr_load_address <= addr_4_load_address):
-if (instructions.GetInstructionAtIndex(i).HasDelaySlot()) :
-delay_slot = delay_slot + 1
-
-steps_expected = index_4 - index_1 - delay_slot
+
+# if third argument is true then the count correspond to the 
+# number of instructions on which breakpoint can be set.
+# start = addr_1, end = addr_4, canSetBreakpoint = True
+steps_expected = instructions.GetInstructionsCount(addr_1, addr_4, True)
 step_count = 0
 # Step from breakpoint_1 to breakpoint_4
 while True:
Index: include/lldb/API/SBInstructionList.h
===
--- include/lldb/API/SBInstructionList.h
+++ include/lldb/API/SBInstructionList.h
@@ -32,6 +32,12 @@
 
   lldb::SBInstruction GetInstructionAtIndex(uint32_t idx);
 
+  size_t GetInstructionsCount(const SBAddress &start,
+ const SBAddress &end,
+ b

[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-27 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301530: [LLDB][MIPS] Fix TestMiExec.py failure. (authored by 
nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D32340?vs=96368&id=96890#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32340

Files:
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py


Index: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -319,8 +319,14 @@
 # -exec-step can keep us in the g_MyFunction for gcc
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
-self.expect(
-
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+it = 
self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"",
+ 
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""])
+
+if it == 1:
+# Call to s_MyFunction may not follow immediately after 
g_MyFunction.
+# There might be some instructions in between to restore 
caller-saved registers.
+# We need to get past these instructions with a step to reach call 
to s_MyFunction.
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)


Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -319,8 +319,14 @@
 # -exec-step can keep us in the g_MyFunction for gcc
 self.runCmd("-exec-finish --frame 0")
 self.expect("\^running")
-self.expect(
-"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"",
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""])
+
+if it == 1:
+# Call to s_MyFunction may not follow immediately after g_MyFunction.
+# There might be some instructions in between to restore caller-saved registers.
+# We need to get past these instructions with a step to reach call to s_MyFunction.
+self.runCmd("-exec-step --thread 1")
 
 # Test that -exec-step steps into s_MyFunction
 # (and that --frame is optional)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure

2017-04-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 96891.
nitesh.jain added a comment.

Update Diff as per suggestion


https://reviews.llvm.org/D32168

Files:
  include/lldb/API/SBAddress.h
  include/lldb/API/SBInstruction.h
  include/lldb/API/SBInstructionList.h
  include/lldb/Core/Disassembler.h
  
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  scripts/interface/SBInstruction.i
  scripts/interface/SBInstructionList.i
  source/API/SBAddress.cpp
  source/API/SBInstruction.cpp
  source/API/SBInstructionList.cpp
  source/Core/Disassembler.cpp

Index: source/Core/Disassembler.cpp
===
--- source/Core/Disassembler.cpp
+++ source/Core/Disassembler.cpp
@@ -759,6 +759,10 @@
   return false;
 }
 
+bool Instruction::CanSetBreakpoint () {
+  return !HasDelaySlot();
+}
+
 bool Instruction::HasDelaySlot() {
   // Default is false.
   return false;
Index: source/API/SBInstructionList.cpp
===
--- source/API/SBInstructionList.cpp
+++ source/API/SBInstructionList.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
@@ -49,6 +50,31 @@
   return inst;
 }
 
+size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
+  const SBAddress &end, 
+  bool canSetBreakpoint) {
+  size_t num_instructions = GetSize();
+  size_t i = 0;
+  SBAddress addr;
+  size_t lower_index = 0;
+  size_t upper_index = 0;
+  size_t instructions_to_skip = 0;
+  for (i = 0; i < num_instructions; ++i) {
+addr = GetInstructionAtIndex(i).GetAddress();
+if (start == addr)
+  lower_index = i;
+if (end == addr)
+  upper_index = i;
+  }
+  if (canSetBreakpoint)
+for (i = lower_index; i <= upper_index; ++i) {
+  SBInstruction insn = GetInstructionAtIndex(i);
+  if (!insn.CanSetBreakpoint())
+++instructions_to_skip;
+}
+  return upper_index - lower_index - instructions_to_skip;
+}
+
 void SBInstructionList::Clear() { m_opaque_sp.reset(); }
 
 void SBInstructionList::AppendInstruction(SBInstruction insn) {}
Index: source/API/SBInstruction.cpp
===
--- source/API/SBInstruction.cpp
+++ source/API/SBInstruction.cpp
@@ -176,6 +176,13 @@
   return false;
 }
 
+bool SBInstruction::CanSetBreakpoint () {
+  lldb::InstructionSP inst_sp(GetOpaque());
+  if (inst_sp)
+return inst_sp->CanSetBreakpoint();
+  return false;
+}
+
 lldb::InstructionSP SBInstruction::GetOpaque() {
   if (m_opaque_sp)
 return m_opaque_sp->GetSP();
Index: source/API/SBAddress.cpp
===
--- source/API/SBAddress.cpp
+++ source/API/SBAddress.cpp
@@ -55,6 +55,12 @@
   return *this;
 }
 
+bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
+  if (lhs.IsValid() && rhs.IsValid())
+return lhs.ref() == rhs.ref();
+  return false;
+}
+
 bool SBAddress::IsValid() const {
   return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
 }
Index: scripts/interface/SBInstructionList.i
===
--- scripts/interface/SBInstructionList.i
+++ scripts/interface/SBInstructionList.i
@@ -44,6 +44,9 @@
 lldb::SBInstruction
 GetInstructionAtIndex (uint32_t idx);
 
+size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+bool canSetBreakpoint);
+
 void
 Clear ();
 
Index: scripts/interface/SBInstruction.i
===
--- scripts/interface/SBInstruction.i
+++ scripts/interface/SBInstruction.i
@@ -54,6 +54,9 @@
 bool
 HasDelaySlot ();
 
+bool
+CanSetBreakpoint ();
+
 void
 Print (FILE *out);
 
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
===
--- packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,19 +62,11 @@
 instructions = function.GetInstructions(self.target)
 addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
 addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
-delay_slot = 0
-addr_1_load_address = addr_1.GetLoadAddress(self.target)
-addr_4_load_address = addr_4.GetLoadAddress(self.target)
-for i in range(instructions.GetSize()) :
-addr = instructions.GetInstructionAtIndex(i).GetAddress()
-   

[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py:329
+# We need to get past these instructions with a step to reach call 
to s_MyFunction.
+self.runCmd("-exec-step --thread 1")
 

ki.stfu wrote:
> I mistyped there should be -exec-next,, and why you are not checking that it 
> has stopped at the right line (as I suggested)?
ohh. i just forgot to do that . I will update it


Repository:
  rL LLVM

https://reviews.llvm.org/D32340



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


[Lldb-commits] [PATCH] D32340: [LLDB][MIPS] Fix TestMiExec.py failure

2017-04-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Hi Ki,

The changes has been committed (https://reviews.llvm.org/rL301537).

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D32340



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


[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure

2017-05-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 97415.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D32168

Files:
  include/lldb/API/SBAddress.h
  include/lldb/API/SBInstruction.h
  include/lldb/API/SBInstructionList.h
  include/lldb/Core/Disassembler.h
  
packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  scripts/interface/SBInstruction.i
  scripts/interface/SBInstructionList.i
  source/API/SBAddress.cpp
  source/API/SBInstruction.cpp
  source/API/SBInstructionList.cpp
  source/Core/Disassembler.cpp

Index: source/Core/Disassembler.cpp
===
--- source/Core/Disassembler.cpp
+++ source/Core/Disassembler.cpp
@@ -759,6 +759,10 @@
   return false;
 }
 
+bool Instruction::CanSetBreakpoint () {
+  return !HasDelaySlot();
+}
+
 bool Instruction::HasDelaySlot() {
   // Default is false.
   return false;
Index: source/API/SBInstructionList.cpp
===
--- source/API/SBInstructionList.cpp
+++ source/API/SBInstructionList.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
@@ -49,6 +50,31 @@
   return inst;
 }
 
+size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
+  const SBAddress &end, 
+  bool canSetBreakpoint) {
+  size_t num_instructions = GetSize();
+  size_t i = 0;
+  SBAddress addr;
+  size_t lower_index = 0;
+  size_t upper_index = 0;
+  size_t instructions_to_skip = 0;
+  for (i = 0; i < num_instructions; ++i) {
+addr = GetInstructionAtIndex(i).GetAddress();
+if (start == addr)
+  lower_index = i;
+if (end == addr)
+  upper_index = i;
+  }
+  if (canSetBreakpoint)
+for (i = lower_index; i <= upper_index; ++i) {
+  SBInstruction insn = GetInstructionAtIndex(i);
+  if (!insn.CanSetBreakpoint())
+++instructions_to_skip;
+}
+  return upper_index - lower_index - instructions_to_skip;
+}
+
 void SBInstructionList::Clear() { m_opaque_sp.reset(); }
 
 void SBInstructionList::AppendInstruction(SBInstruction insn) {}
Index: source/API/SBInstruction.cpp
===
--- source/API/SBInstruction.cpp
+++ source/API/SBInstruction.cpp
@@ -176,6 +176,13 @@
   return false;
 }
 
+bool SBInstruction::CanSetBreakpoint () {
+  lldb::InstructionSP inst_sp(GetOpaque());
+  if (inst_sp)
+return inst_sp->CanSetBreakpoint();
+  return false;
+}
+
 lldb::InstructionSP SBInstruction::GetOpaque() {
   if (m_opaque_sp)
 return m_opaque_sp->GetSP();
Index: source/API/SBAddress.cpp
===
--- source/API/SBAddress.cpp
+++ source/API/SBAddress.cpp
@@ -55,6 +55,12 @@
   return *this;
 }
 
+bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
+  if (lhs.IsValid() && rhs.IsValid())
+return lhs.ref() == rhs.ref();
+  return false;
+}
+
 bool SBAddress::IsValid() const {
   return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
 }
Index: scripts/interface/SBInstructionList.i
===
--- scripts/interface/SBInstructionList.i
+++ scripts/interface/SBInstructionList.i
@@ -44,6 +44,9 @@
 lldb::SBInstruction
 GetInstructionAtIndex (uint32_t idx);
 
+size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+bool canSetBreakpoint);
+
 void
 Clear ();
 
Index: scripts/interface/SBInstruction.i
===
--- scripts/interface/SBInstruction.i
+++ scripts/interface/SBInstruction.i
@@ -54,6 +54,9 @@
 bool
 HasDelaySlot ();
 
+bool
+CanSetBreakpoint ();
+
 void
 Print (FILE *out);
 
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
===
--- packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,19 +62,11 @@
 instructions = function.GetInstructions(self.target)
 addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
 addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
-delay_slot = 0
-addr_1_load_address = addr_1.GetLoadAddress(self.target)
-addr_4_load_address = addr_4.GetLoadAddress(self.target)
-for i in range(instructions.GetSize()) :
-addr = instructions.GetInstructionAtIndex(i).GetAddress()
-  

[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure

2017-05-04 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302139: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure. 
(authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D32168?vs=97415&id=97811#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32168

Files:
  lldb/trunk/include/lldb/API/SBAddress.h
  lldb/trunk/include/lldb/API/SBInstruction.h
  lldb/trunk/include/lldb/API/SBInstructionList.h
  lldb/trunk/include/lldb/Core/Disassembler.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/trunk/scripts/interface/SBInstruction.i
  lldb/trunk/scripts/interface/SBInstructionList.i
  lldb/trunk/source/API/SBAddress.cpp
  lldb/trunk/source/API/SBInstruction.cpp
  lldb/trunk/source/API/SBInstructionList.cpp
  lldb/trunk/source/Core/Disassembler.cpp

Index: lldb/trunk/source/API/SBInstructionList.cpp
===
--- lldb/trunk/source/API/SBInstructionList.cpp
+++ lldb/trunk/source/API/SBInstructionList.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
@@ -49,6 +50,31 @@
   return inst;
 }
 
+size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
+  const SBAddress &end, 
+  bool canSetBreakpoint) {
+  size_t num_instructions = GetSize();
+  size_t i = 0;
+  SBAddress addr;
+  size_t lower_index = 0;
+  size_t upper_index = 0;
+  size_t instructions_to_skip = 0;
+  for (i = 0; i < num_instructions; ++i) {
+addr = GetInstructionAtIndex(i).GetAddress();
+if (start == addr)
+  lower_index = i;
+if (end == addr)
+  upper_index = i;
+  }
+  if (canSetBreakpoint)
+for (i = lower_index; i <= upper_index; ++i) {
+  SBInstruction insn = GetInstructionAtIndex(i);
+  if (!insn.CanSetBreakpoint())
+++instructions_to_skip;
+}
+  return upper_index - lower_index - instructions_to_skip;
+}
+
 void SBInstructionList::Clear() { m_opaque_sp.reset(); }
 
 void SBInstructionList::AppendInstruction(SBInstruction insn) {}
Index: lldb/trunk/source/API/SBAddress.cpp
===
--- lldb/trunk/source/API/SBAddress.cpp
+++ lldb/trunk/source/API/SBAddress.cpp
@@ -55,6 +55,12 @@
   return *this;
 }
 
+bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
+  if (lhs.IsValid() && rhs.IsValid())
+return lhs.ref() == rhs.ref();
+  return false;
+}
+
 bool SBAddress::IsValid() const {
   return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
 }
Index: lldb/trunk/source/API/SBInstruction.cpp
===
--- lldb/trunk/source/API/SBInstruction.cpp
+++ lldb/trunk/source/API/SBInstruction.cpp
@@ -176,6 +176,13 @@
   return false;
 }
 
+bool SBInstruction::CanSetBreakpoint () {
+  lldb::InstructionSP inst_sp(GetOpaque());
+  if (inst_sp)
+return inst_sp->CanSetBreakpoint();
+  return false;
+}
+
 lldb::InstructionSP SBInstruction::GetOpaque() {
   if (m_opaque_sp)
 return m_opaque_sp->GetSP();
Index: lldb/trunk/source/Core/Disassembler.cpp
===
--- lldb/trunk/source/Core/Disassembler.cpp
+++ lldb/trunk/source/Core/Disassembler.cpp
@@ -759,6 +759,10 @@
   return false;
 }
 
+bool Instruction::CanSetBreakpoint () {
+  return !HasDelaySlot();
+}
+
 bool Instruction::HasDelaySlot() {
   // Default is false.
   return false;
Index: lldb/trunk/scripts/interface/SBInstruction.i
===
--- lldb/trunk/scripts/interface/SBInstruction.i
+++ lldb/trunk/scripts/interface/SBInstruction.i
@@ -54,6 +54,9 @@
 bool
 HasDelaySlot ();
 
+bool
+CanSetBreakpoint ();
+
 void
 Print (FILE *out);
 
Index: lldb/trunk/scripts/interface/SBInstructionList.i
===
--- lldb/trunk/scripts/interface/SBInstructionList.i
+++ lldb/trunk/scripts/interface/SBInstructionList.i
@@ -44,6 +44,9 @@
 lldb::SBInstruction
 GetInstructionAtIndex (uint32_t idx);
 
+size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+bool canSetBreakpoint);
+
 void
 Clear ();
 
Index: lldb/trunk/include/lldb/Core/Disassembler.h
===
--- lldb/trunk/include/lldb/Core/Disassembler.h
+++ lldb/trunk/include/lldb/Core/Disassembler.h
@@ -173,6 +173,8 @@
 
   virtual bool HasDelaySlot();
 
+  bool CanSetBreakpoint ();
+
   virtual size_t Decode(const Disassembler &disassembler,
 const DataExtractor 

[Lldb-commits] [PATCH] D35784: [LLD][MIPS] Fix Address::GetAddressClass() to return correct AddressClass based on the load address

2017-07-24 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.
Herald added subscribers: arichardson, sdardis.

The implementation of Address::GetAddressClass() is based on file address. 
Those it will give incorrect result if there are more than one section for a 
particular file address. For example (see attach log), there are two sections 
(.text and .debug_ranges) for the file address 0xbcf0. Hence the 
Address::GetAddressClass() will return "eAddressClassDebug" instead of 
"eAddressClassCode". This will cause breakpoint failure and incorrect 
disassembly view. In these patch, the Address::GetAddressClass() will return 
AddressClass based on the loaded Section and fall back to file address if its 
failed.

F3765058: log 


https://reviews.llvm.org/D35784

Files:
  include/lldb/Symbol/ObjectFile.h
  include/lldb/lldb-enumerations.h
  source/Core/Address.cpp
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -315,6 +315,65 @@
   return false;
 }
 
+AddressClass ObjectFile::SectionTypeToAddressClass(const SectionType st) {
+  switch (st) {
+  case eSectionTypeInvalid:
+return eAddressClassUnknown;
+  case eSectionTypeCode:
+return eAddressClassCode;
+  case eSectionTypeContainer:
+return eAddressClassUnknown;
+  case eSectionTypeData:
+  case eSectionTypeDataCString:
+  case eSectionTypeDataCStringPointers:
+  case eSectionTypeDataSymbolAddress:
+  case eSectionTypeData4:
+  case eSectionTypeData8:
+  case eSectionTypeData16:
+  case eSectionTypeDataPointers:
+  case eSectionTypeZeroFill:
+  case eSectionTypeDataObjCMessageRefs:
+  case eSectionTypeDataObjCCFStrings:
+  case eSectionTypeGoSymtab:
+return eAddressClassData;
+  case eSectionTypeDebug:
+  case eSectionTypeDWARFDebugAbbrev:
+  case eSectionTypeDWARFDebugAddr:
+  case eSectionTypeDWARFDebugAranges:
+  case eSectionTypeDWARFDebugFrame:
+  case eSectionTypeDWARFDebugInfo:
+  case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugMacInfo:
+  case eSectionTypeDWARFDebugMacro:
+  case eSectionTypeDWARFDebugPubNames:
+  case eSectionTypeDWARFDebugPubTypes:
+  case eSectionTypeDWARFDebugRanges:
+  case eSectionTypeDWARFDebugStr:
+  case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFAppleNames:
+  case eSectionTypeDWARFAppleTypes:
+  case eSectionTypeDWARFAppleNamespaces:
+  case eSectionTypeDWARFAppleObjC:
+return eAddressClassDebug;
+  case eSectionTypeEHFrame:
+  case eSectionTypeARMexidx:
+  case eSectionTypeARMextab:
+  case eSectionTypeCompactUnwind:
+return eAddressClassRuntime;
+  case eSectionTypeELFSymbolTable:
+  case eSectionTypeELFDynamicSymbols:
+  case eSectionTypeELFRelocationEntries:
+  case eSectionTypeELFDynamicLinkInfo:
+  case eSectionTypeOther:
+return eAddressClassUnknown;
+  case eSectionTypeAbsoluteAddress:
+return eAddressClassTypeAbsoluteAddress;
+  default:
+return eAddressClassUnknown;
+  }
+}
+
 AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
   Symtab *symtab = GetSymtab();
   if (symtab) {
@@ -324,68 +383,15 @@
 const SectionSP section_sp(symbol->GetAddressRef().GetSection());
 if (section_sp) {
   const SectionType section_type = section_sp->GetType();
-  switch (section_type) {
-  case eSectionTypeInvalid:
-return eAddressClassUnknown;
-  case eSectionTypeCode:
-return eAddressClassCode;
-  case eSectionTypeContainer:
-return eAddressClassUnknown;
-  case eSectionTypeData:
-  case eSectionTypeDataCString:
-  case eSectionTypeDataCStringPointers:
-  case eSectionTypeDataSymbolAddress:
-  case eSectionTypeData4:
-  case eSectionTypeData8:
-  case eSectionTypeData16:
-  case eSectionTypeDataPointers:
-  case eSectionTypeZeroFill:
-  case eSectionTypeDataObjCMessageRefs:
-  case eSectionTypeDataObjCCFStrings:
-  case eSectionTypeGoSymtab:
-return eAddressClassData;
-  case eSectionTypeDebug:
-  case eSectionTypeDWARFDebugAbbrev:
-  case eSectionTypeDWARFDebugAddr:
-  case eSectionTypeDWARFDebugAranges:
-  case eSectionTypeDWARFDebugFrame:
-  case eSectionTypeDWARFDebugInfo:
-  case eSectionTypeDWARFDebugLine:
-  case eSectionTypeDWARFDebugLoc:
-  case eSectionTypeDWARFDebugMacInfo:
-  case eSectionTypeDWARFDebugMacro:
-  case eSectionTypeDWARFDebugPubNames:
-  case eSectionTypeDWARFDebugPubTypes:
-  case eSectionTypeDWARFDebugRanges:
-  case eSectionTypeDWARFDebugStr:
-  case eSectionTypeDWARFDebugStrOffsets:
-  case eSectionTypeDWARFAppleNames:
-  case eSectionTypeDWARFAppleTypes:
-  case eSectionTypeDWARFAppleNamespaces:

[Lldb-commits] [PATCH] D35784: [LLD][MIPS] Fix Address::GetAddressClass() to return correct AddressClass based on the load address

2017-07-26 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D35784#820237, @clayborg wrote:

> Looking at an ELF file with DWARF, I see:
>
>   (lldb) image dump sections 
>   Dumping sections for 1 modules.
>   Sections for 
> '/Volumes/android/aosp/out/target/product/generic/symbols/system/lib/libart.so'
>  (arm):
> SectID Type File Address Perm 
> File Off.  File Size  Flags  Section Name
> --  ---   
> -- -- -- 
> 0x0001 regular   ---  
> 0x 0x 0x libart.so.
> 0x0002 regular  [0x0154-0x0167)  r--  
> 0x0154 0x0013 0x0002 libart.so..interp
> 0x0003 elf-dynamic-symbols [0x0168-0x00010d18)  
> r--  0x0168 0x00010bb0 0x0002 libart.so..dynsym
> 0x0004 regular  [0x00010d18-0x0005228f)  r--  
> 0x00010d18 0x00041577 0x0002 libart.so..dynstr
> 0x0005 regular  [0x00052290-0x0005a590)  r--  
> 0x00052290 0x8300 0x0002 libart.so..hash
> 0x0006 elf-relocation-entries [0x0005a590-0x00067870) 
>  r--  0x0005a590 0xd2e0 0x0002 libart.so..rel.dyn
> 0x0007 elf-relocation-entries [0x00067870-0x00068398) 
>  r--  0x00067870 0x0b28 0x0002 libart.so..rel.plt
> 0x0008 regular  [0x00068398-0x00069468)  r-x  
> 0x00068398 0x10d0 0x0006 libart.so..plt
> 0x0009 code [0x00069470-0x002a94f8)  r-x  
> 0x00069470 0x00240088 0x0006 libart.so..text
> 0x000a ARM.exidx[0x002a94f8-0x002b12d0)  r--  
> 0x002a94f8 0x7dd8 0x0082 libart.so..ARM.exidx
> 0x000b ARM.extab[0x002b12d0-0x002b1e44)  r--  
> 0x002b12d0 0x0b74 0x0002 libart.so..ARM.extab
> 0x000c regular  [0x002b1e48-0x002e39e4)  r--  
> 0x002b1e48 0x00031b9c 0x0002 libart.so..rodata
> 0x000d eh-frame [0x002e39e4-0x002e5fa8)  r--  
> 0x002e39e4 0x25c4 0x0002 libart.so..eh_frame
> 0x000e regular  [0x002e5fa8-0x002e63d4)  r--  
> 0x002e5fa8 0x042c 0x0002 libart.so..eh_frame_hdr
> 0x000f regular  [0x002e7e38-0x002eaa24)  rw-  
> 0x002e6e38 0x2bec 0x0003 libart.so..data.rel.ro.local
> 0x0010 regular  [0x002eaa24-0x002eaa28)  rw-  
> 0x002e9a24 0x0004 0x0003 libart.so..fini_array
> 0x0011 regular  [0x002eaa28-0x002ee370)  rw-  
> 0x002e9a28 0x3948 0x0003 libart.so..data.rel.ro
> 0x0012 regular  [0x002ee370-0x002ee3c0)  rw-  
> 0x002ed370 0x0050 0x0003 libart.so..init_array
> 0x0013 elf-dynamic-link-info [0x002ee3c0-0x002ee4f0)  
> rw-  0x002ed3c0 0x0130 0x0003 libart.so..dynamic
> 0x0014 regular  [0x002ee4f4-0x002ef000)  rw-  
> 0x002ed4f4 0x0b0c 0x0003 libart.so..got
> 0x0015 data [0x002ef000-0x002ef8c4)  rw-  
> 0x002ee000 0x08c4 0x0003 libart.so..data
> 0x0016 zero-fill[0x002ef8c8-0x002f11fc)  rw-  
> 0x002ee8c8 0x 0x0003 libart.so..bss
> 0x0017 regular   ---  
> 0x002ee8c4 0x0010 0x0030 libart.so..comment
> 0x0018 dwarf-line---  
> 0x002ee8d4 0x002c10eb 0x libart.so..debug_line
> 0x0019 dwarf-info---  
> 0x005af9bf 0x054eb22a 0x libart.so..debug_info
> 0x001a dwarf-abbrev  ---  
> 0x05a9abe9 0x000f5e5b 0x libart.so..debug_abbrev
> 0x001b dwarf-aranges ---  
> 0x05b90a48 0x00011960 0x libart.so..debug_aranges
> 0x001c dwarf-loc ---  
> 0x05ba23a8 0x00a0d623 0x libart.so..debug_loc
> 0x001d dwarf-ranges  ---  
> 0x065af9cb 0x0029c7b0 0x libart.so..debug_ranges
> 0x001e dwarf-macro   ---  
> 0x0684c17b 0x000ada15 0x libart.so..debug_macro
> 0x001f dwarf-str ---  
> 0x068f9b90 0x004a45e9 0x0030 libart.so..debug_str
> 0x0020 dwarf-frame   ---  
> 0x06d9e17c 0x0003fc6c 0x libart.so..debug_frame
> 0x0021 regular   

[Lldb-commits] [PATCH] D11465: Fix "process load/unload" on android

2017-07-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp:389
+   struct __lldb_dlopen_result { void *image_ptr; const char 
*error_str; } the_result;
+   the_result.image_ptr = __dl_dlopen ("%s", 2);
+   if (the_result.image_ptr == (void*)0x0)

Hi Tamas,

When I run "process load libloadunload_a.so --install" its fail with error 
Couldn't lookup symbols: __dl_dlerror, __dl_dlopen.  

Symbol table contains 13 entries:
   Num:Value  Size TypeBind   Vis  Ndx Name
 0:  0 NOTYPE  LOCAL  DEFAULT  UND
 1: 0304 5 FUNCGLOBAL DEFAULT5 android_dlopen_ext
 2: 0309 5 FUNCGLOBAL DEFAULT5 android_get_LD_LIBRARY_PA
 3: 030e 5 FUNCGLOBAL DEFAULT5 android_update_LD_LIBRARY
 4: 0313 5 FUNCGLOBAL DEFAULT5 dl_iterate_phdr
 5: 0318 5 FUNCGLOBAL DEFAULT5 **dladdr**
 6: 031d 5 FUNCGLOBAL DEFAULT5 **dlclose**
 7: 0322 5 FUNCGLOBAL DEFAULT5 **dlerror**
 8: 0327 5 FUNCGLOBAL DEFAULT5 **dlopen**
 9: 032c 5 FUNCGLOBAL DEFAULT5 dlsym
10: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS _edata
11: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
12: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS _end

The symbols are not prefix with "__dl_" . We are using SDK version 25 for 
MIP64r6 target. 

generic_mips64:/ # getprop ro.build.version.sdk
25

Even we are not seeing prefix "__dl_" added to X86-64 dynamic symbol
Symbol table '.dynsym' contains 12 entries:
   Num:Value  Size TypeBind   Vis  Ndx Name
 0:  0 NOTYPE  LOCAL  DEFAULT  UND
 1: 0442 6 FUNCGLOBAL DEFAULT7 dl_iterate_phdr@@LIBC
 2: 043c 6 FUNCGLOBAL DEFAULT7 
android_dlopen_ext@@LIBC
 3: 044e 6 FUNCGLOBAL DEFAULT7 dlclose@@LIBC
 4: 0448 6 FUNCGLOBAL DEFAULT7 dladdr@@LIBC
 5: 045a 6 FUNCGLOBAL DEFAULT7 dlopen@@LIBC
 6: 0454 6 FUNCGLOBAL DEFAULT7 dlerror@@LIBC
 7: 0460 6 FUNCGLOBAL DEFAULT7 dlsym@@LIBC
 8: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS _edata
 9: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
10: 2000 0 NOTYPE  GLOBAL DEFAULT  ABS _end
11:  0 OBJECT  GLOBAL DEFAULT  ABS LIBC

Symbol table '.symtab' contains 14 entries:
   Num:Value  Size TypeBind   Vis  Ndx Name
 0:  0 NOTYPE  LOCAL  DEFAULT  UND
 1:  0 FILELOCAL  DEFAULT  ABS tmp-platform.c
 2: 1ee0   288 OBJECT  LOCAL  HIDDEN10 _DYNAMIC
 3:  0 OBJECT  GLOBAL DEFAULT  ABS LIBC
 4: 0442 6 FUNCGLOBAL DEFAULT7 dl_iterate_phdr
 5: 043c 6 FUNCGLOBAL DEFAULT7 android_dlopen_ext
 6: 044e 6 FUNCGLOBAL DEFAULT7 dlclose
 7: 0448 6 FUNCGLOBAL DEFAULT7 dladdr
 8: 045a 6 FUNCGLOBAL DEFAULT7 dlopen



Repository:
  rL LLVM

https://reviews.llvm.org/D11465



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


[Lldb-commits] [PATCH] D35784: [LLD][MIPS] Fix Address::GetAddressClass() to return correct AddressClass based on the load address

2017-07-31 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D35784#823131, @clayborg wrote:

> So the issue is with the ObjectFileELF when it makes its symbol table. It is 
> taking this symbols:
>
>   49686: bcf0 0 NOTYPE LOCAL DEFAULT 40 $debug_ranges627
>
>
> And saying it is a code symbol. This symbols has a NOTYPE on it, not FUNC 
> like the main symbol. Fix the ObjectFileELF to give an appropriate 
> lldb::SymbolType value for it. It shouldn't be 
> lldb::SymbolType::eSymbolTypeCode. So set all NOTYPE to 
> lldb::SymbolType::eSymbolTypeInvalid or add a new enum that makes sense.


For the $debug_ranges627 we are getting correct symbol type i.e 
lldb::SymbolType::eSymbolTypeInvalid.  The function 
Symbol::FindSymbolAtFileAddress(lldb::addr_t file_addr) search for the symbol 
with file_addr. These return symbol $debug_ranges627 
lldb::SymbolType::eSymbolTypeInvalid . Actual symbol what we want for address 
**//0xbcf0//** was main symbol but RangeDataVector::FindEntryThatContains(B 
addr) return $debug_ranges627 .

**//bcc4//** 1664 FUNC GLOBAL DEFAULT 10 main

Should we add  FindSymbolContainingFileAddressAndType() which will return 
correct symbol based on Type ?

The ObjectFile::GetAddressClass(addr_t file_addr) {

  Symtab *symtab = GetSymtab();
  if (symtab) {
Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr); // 
symtab->FindSymbolContainingFileAddressAndType(file_addr, eSymbolTypeCode)
if (symbol) {
...
...
...
}
  ...
  ...
  ...

}
...
...
...
}


https://reviews.llvm.org/D35784



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


[Lldb-commits] [PATCH] D36046: Improve the posix core file triple detection

2017-07-31 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added inline comments.



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:733-735
+  if (target_arch.IsMIPS()) {
 return target_arch;
+  }

tberghammer wrote:
> Hi Nitesh,
> 
> I tried to remove this MIPS specific code as it shouldn't be necessary if I 
> add the above MergeFrom for all architecture but if I do it fails LinuxCore
> TestCase.test_mips_n32.
> 
> The issue is that in that case the tripe we get from the core file is 
> "mipsel--" ("mipsel--linux" after the merge) and the one we get from the 
> binary is "mips64el--linux". Is it normal to have a seemingly 32bit core file 
> with a 64bit binary on mips? If not then can I ask you to help me figure out 
> which one is incorrect?
> 
> If it is then I don't see any better short term solution then leaving this 
> condition here but it feels like a quite big hack what might backfire when 
> somebody tries to use a core file with a completely incompatible binary.
> 
> Thanks,
> Tamas
Hi Tamas,

In MIPS , the core file doesn't contain any Architecture information . It's 
just specify the generic MIPS architecture. Hence we need to relied on 
target_arch for correct architecture informations.

TestCase.test_mips_n32 is "32 bit binary" with triple "mips64el-linux". This 
binary can only run on 64 bit target as compared to O32 which can run on 32/64 
bit target.


https://reviews.llvm.org/D36046



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


[Lldb-commits] [PATCH] D11465: Fix "process load/unload" on android

2017-07-31 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Hi Tamas,

> Run "target modules list"

(lldb) target modules list
[  0] E6A47987----
/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/a.out
[  1] C2298D9F-41E0-1ED4-C9BF-D5B416CBE38F
/home/nin/.lldb/module_cache/remote-android/.cache/C2298D9F-41E0-1ED4-C9BF-D5B416CBE38F/libstdc++.so
[  2] D178E966-9342-8A56-CE34-35C9359886A4
/home/nin/.lldb/module_cache/remote-android/.cache/D178E966-9342-8A56-CE34-35C9359886A4/libm.so
[  3] 6F226DD0-EFC1-AC63-647D-374F43AB9CC6
/home/nin/.lldb/module_cache/remote-android/.cache/6F226DD0-EFC1-AC63-647D-374F43AB9CC6/libc.so
[  4] DF63F23A-2C91-BA01-EC7D-7CCA4FA1A55D
/home/nin/.lldb/module_cache/remote-android/.cache/DF63F23A-2C91-BA01-EC7D-7CCA4FA1A55D/libdl.so
[  5] 0466B0A0-00B3-88DA-55F1-1DA6D42D2C36
/home/nin/.lldb/module_cache/remote-android/.cache/0466B0A0-00B3-88DA-55F1-1DA6D42D2C36/ld-android.so
[  6] 3FD33902-2A3B-6F33-0890-CDF6A434045E
/home/nin/.lldb/module_cache/remote-android/.cache/3FD33902-2A3B-6F33-0890-CDF6A434045E/linker64
[  7] D738489C-460B-25A5-B3B1-0D9BBC7CB8D6
/home/nin/.lldb/module_cache/remote-android/.cache/D738489C-460B-25A5-B3B1-0D9BBC7CB8D6/libnetd_client.so
[  8] 84239230-A38E-687A-7EC5-FA40CD52D25F
/home/nin/.lldb/module_cache/remote-android/.cache/84239230-A38E-687A-7EC5-FA40CD52D25F/libcutils.so
[  9] 38725D15-41E9-AB20-70A0-16012C5B9DAD
/home/nin/.lldb/module_cache/remote-android/.cache/38725D15-41E9-AB20-70A0-16012C5B9DAD/libc++.so
[ 10] 72DDCA8E-D724-7089-17EF-0703F4CA12E4
/home/nin/.lldb/module_cache/remote-android/.cache/72DDCA8E-D724-7089-17EF-0703F4CA12E4/liblog.so

> Run "target modules lookup -n dlopen"

(lldb) target modules lookup -n dlopen
1 match found in 
/home/nin/.lldb/module_cache/remote-android/.cache/DF63F23A-2C91-BA01-EC7D-7CCA4FA1A55D/libdl.so:

  Address: libdl.so[0x10a0] (libdl.so..text + 352)
  Summary: libdl.so`dlopen

> target modules lookup -n __dl_dlopen

(lldb) target modules lookup -n __dl_dlopen
(lldb)

I have attach the output of /system/bin/linker64.F3829045: linker_64.log 
.


Repository:
  rL LLVM

https://reviews.llvm.org/D11465



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


[Lldb-commits] [PATCH] D11465: Fix "process load/unload" on android

2017-07-31 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

The android version am using for testing is "O".

generic_mips64:/ # getprop ro.build.version.release
O


Repository:
  rL LLVM

https://reviews.llvm.org/D11465



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


[Lldb-commits] [PATCH] D35784: [LLD][MIPS] Fix Address::GetAddressClass() to return correct AddressClass based on the load address

2017-08-04 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

ping


https://reviews.llvm.org/D35784



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


[Lldb-commits] [PATCH] D11465: Fix "process load/unload" on android

2017-08-04 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D11465#826132, @tberghammer wrote:

> Thanks for all of the data. Based on this I think you are using a preview 
> version of android O what reports SDK 25 but the linker works the way an SDK 
> 26 system linker would do.
>
> I think the proper fix for the problem is to do something like what Greg 
> suggested to detect the correct function name based on the list of available 
> symbols instead of based on the SDK version. I will try to create a CL to fix 
> it in the next couple of days (unless you are happy to do it), but not sure 
> when I will have time for that and it is a bit tricky to test it.
>
> Until then you can try to do either update to a newer version of the system 
> image what reports SDK 26 (and make sure you are using a sufficiently new 
> LLDB) or locally hack the "PlatformAndroid::LoadImage" function to use the 
> SDK 26 version in case of SDK 25 as well (possibly with a check for 
> ro.build.version.release)


Thanks. As suggested by Greg will submit a  patch for that


Repository:
  rL LLVM

https://reviews.llvm.org/D11465



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


[Lldb-commits] [PATCH] D35784: [LLDB][MIPS] The symbol with NOTYPE doesn't contain any valid address

2017-08-09 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 110364.
nitesh.jain retitled this revision from "[LLD][MIPS] Fix 
Address::GetAddressClass() to return correct AddressClass based on the load 
address" to "[LLDB][MIPS] The symbol with NOTYPE doesn't contain any valid 
address".

https://reviews.llvm.org/D35784

Files:
  source/Symbol/Symbol.cpp


Index: source/Symbol/Symbol.cpp
===
--- source/Symbol/Symbol.cpp
+++ source/Symbol/Symbol.cpp
@@ -113,6 +113,8 @@
 }
 
 bool Symbol::ValueIsAddress() const {
+  if (m_type == eSymbolTypeInvalid)
+return false;
   return m_addr_range.GetBaseAddress().GetSection().get() != nullptr;
 }
 


Index: source/Symbol/Symbol.cpp
===
--- source/Symbol/Symbol.cpp
+++ source/Symbol/Symbol.cpp
@@ -113,6 +113,8 @@
 }
 
 bool Symbol::ValueIsAddress() const {
+  if (m_type == eSymbolTypeInvalid)
+return false;
   return m_addr_range.GetBaseAddress().GetSection().get() != nullptr;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D35784: [LLDB][MIPS] The symbol with NOTYPE and having section type dwarf doesn't contain any valid address

2017-08-11 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 110698.
nitesh.jain retitled this revision from "[LLDB][MIPS] The symbol with NOTYPE 
doesn't contain any valid address" to "[LLDB][MIPS] The symbol with NOTYPE and 
having section type dwarf doesn't contain any valid address".
Herald added a subscriber: emaste.

https://reviews.llvm.org/D35784

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2154,6 +2154,12 @@
   break;
 default:
   symbol_section_sp = section_list->GetSectionAtIndex(section_idx);
+  // If symbol type is Invalid then check for symbol section type
+  if (symbol.getType() == STT_NOTYPE && symbol_section_sp &&
+  symbol_section_sp->GetType() > eSectionTypeDataObjCCFStrings &&
+  symbol_section_sp->GetType() < eSectionTypeELFSymbolTable)
+  symbol_section_sp = nullptr;
+
   break;
 }
 


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2154,6 +2154,12 @@
   break;
 default:
   symbol_section_sp = section_list->GetSectionAtIndex(section_idx);
+  // If symbol type is Invalid then check for symbol section type
+  if (symbol.getType() == STT_NOTYPE && symbol_section_sp &&
+  symbol_section_sp->GetType() > eSectionTypeDataObjCCFStrings &&
+  symbol_section_sp->GetType() < eSectionTypeELFSymbolTable)
+  symbol_section_sp = nullptr;
+
   break;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D35784: [LLDB][MIPS] The symbol with NOTYPE and having section type debug doesn't contain any valid address

2017-08-11 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

The $debug_rangesN symbols are added by linker. These symbols are not used 
anywhere We can skip these type of symbols (where symbol type is STT_NOTYPE and 
its section is Debug)


https://reviews.llvm.org/D35784



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


[Lldb-commits] [PATCH] D35784: [LLDB][MIPS] Set the Section's file address for ELF section to LLDB_INVALID_ADDRESS if SHF_ALLOC is not set

2017-08-14 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 110924.
nitesh.jain retitled this revision from "[LLDB][MIPS] The symbol with NOTYPE 
and having section type debug doesn't contain any valid address" to 
"[LLDB][MIPS] Set the Section's file address for ELF section to 
LLDB_INVALID_ADDRESS if SHF_ALLOC is not set".
nitesh.jain edited the summary of this revision.
nitesh.jain added a comment.

Update diff as per suggestion. Thanks Greg for your suggestion.

Thanks,
Nitesh


https://reviews.llvm.org/D35784

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1987,7 +1987,9 @@
   ? m_arch_spec.GetDataByteSize()
   : eSectionTypeCode == sect_type ? m_arch_spec.GetCodeByteSize()
   : 1;
-
+  const addr_t sect_file_addr = header.sh_flags & SHF_ALLOC
+? header.sh_addr
+: LLDB_INVALID_ADDRESS;
   elf::elf_xword log2align =
   (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign);
   SectionSP section_sp(new Section(
@@ -1997,7 +1999,7 @@
   SectionIndex(I), // Section ID.
   name,// Section name.
   sect_type,   // Section type.
-  header.sh_addr,  // VM address.
+  sect_file_addr,  // VM address.
   vm_size, // VM size in bytes of this section.
   header.sh_offset,// Offset of this section in the file.
   file_size,   // Size of the section as found in the file.


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1987,7 +1987,9 @@
   ? m_arch_spec.GetDataByteSize()
   : eSectionTypeCode == sect_type ? m_arch_spec.GetCodeByteSize()
   : 1;
-
+  const addr_t sect_file_addr = header.sh_flags & SHF_ALLOC
+? header.sh_addr
+: LLDB_INVALID_ADDRESS;
   elf::elf_xword log2align =
   (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign);
   SectionSP section_sp(new Section(
@@ -1997,7 +1999,7 @@
   SectionIndex(I), // Section ID.
   name,// Section name.
   sect_type,   // Section type.
-  header.sh_addr,  // VM address.
+  sect_file_addr,  // VM address.
   vm_size, // VM size in bytes of this section.
   header.sh_offset,// Offset of this section in the file.
   file_size,   // Size of the section as found in the file.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D35784: [LLDB][MIPS] Set the Section's file address for ELF section to LLDB_INVALID_ADDRESS if SHF_ALLOC is not set

2017-08-14 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310855: [LLDB][MIPS] Set the Section's file address for 
(authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D35784?vs=110924&id=111006#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35784

Files:
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1987,7 +1987,9 @@
   ? m_arch_spec.GetDataByteSize()
   : eSectionTypeCode == sect_type ? m_arch_spec.GetCodeByteSize()
   : 1;
-
+  const addr_t sect_file_addr = header.sh_flags & SHF_ALLOC
+? header.sh_addr
+: LLDB_INVALID_ADDRESS;
   elf::elf_xword log2align =
   (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign);
   SectionSP section_sp(new Section(
@@ -1997,7 +1999,7 @@
   SectionIndex(I), // Section ID.
   name,// Section name.
   sect_type,   // Section type.
-  header.sh_addr,  // VM address.
+  sect_file_addr,  // VM address.
   vm_size, // VM size in bytes of this section.
   header.sh_offset,// Offset of this section in the file.
   file_size,   // Size of the section as found in the file.


Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1987,7 +1987,9 @@
   ? m_arch_spec.GetDataByteSize()
   : eSectionTypeCode == sect_type ? m_arch_spec.GetCodeByteSize()
   : 1;
-
+  const addr_t sect_file_addr = header.sh_flags & SHF_ALLOC
+? header.sh_addr
+: LLDB_INVALID_ADDRESS;
   elf::elf_xword log2align =
   (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign);
   SectionSP section_sp(new Section(
@@ -1997,7 +1999,7 @@
   SectionIndex(I), // Section ID.
   name,// Section name.
   sect_type,   // Section type.
-  header.sh_addr,  // VM address.
+  sect_file_addr,  // VM address.
   vm_size, // VM size in bytes of this section.
   header.sh_offset,// Offset of this section in the file.
   file_size,   // Size of the section as found in the file.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27124: [LLDB][MIPS] Fix TestWatchpointIter failure

2016-11-30 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated the summary for this revision.
nitesh.jain updated this revision to Diff 79864.
nitesh.jain added a comment.

Updated diff as per suggestion.


https://reviews.llvm.org/D27124

Files:
  source/Target/StopInfo.cpp


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,9 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +712,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,9 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +712,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 79881.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D27088

Files:
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in 
range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self.fr_flag = 1
+self.fr_flag = (sr_value >> 26) & self.fr_flag
+
+if reg_info["format"] == "float" and (self.fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self.fr_flag = 1
+self.fr_flag = (sr_value >> 26) & self.fr_flag
+
+if reg_info["format"] == "float" and (self.fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop
__

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 79890.
nitesh.jain added a comment.

Update diff as per suggestion.

Thanks


https://reviews.llvm.org/D27088

Files:
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+_mips_fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in 
range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self._mips_fr_flag = 1
+self._mips_fr_flag = (sr_value >> 26) & self._mips_fr_flag
+
+if reg_info["format"] == "float" and (self._mips_fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+_mips_fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self._mips_fr_flag = 1
+self._mips_fr_flag = (sr_value >> 26) & self._mips_fr_flag
+
+if reg_info["format"] == "float" and (self._mips_fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsiz

[Lldb-commits] [PATCH] D27124: [LLDB][MIPS] Fix TestWatchpointIter failure

2016-12-06 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 80414.
nitesh.jain added a comment.

Update diff as per suggestion


https://reviews.llvm.org/D27124

Files:
  source/Target/StopInfo.cpp


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,13 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+// We need to preserve the watch_index before watchpoint 
+// is disable. Since Watchpoint::SetEnabled will clear the
+// watch index.
+// This will fix TestWatchpointIter failure
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +716,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,13 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+// We need to preserve the watch_index before watchpoint 
+// is disable. Since Watchpoint::SetEnabled will clear the
+// watch index.
+// This will fix TestWatchpointIter failure
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +716,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-06 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Hi Greg,

I am not sure whether this approach will work in Multithreaded application. 
Since if any thread modify the SR.FR bit then the change will get reflect in 
all copy of SR.FR of all other threads. So if we stop at thread A and thread B 
(running) try to modify SR.FR bit then the above approach will give incorrect 
register size.

Let me check this case and get back to you

Thanks


https://reviews.llvm.org/D27088



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


[Lldb-commits] [PATCH] D26542: [LLDB][MIPS] Fix some test case failures due to "elf_abi" field of qprocessInfo packet

2016-12-09 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289209: [LLDB][MIPS] Fix some test case failures due to 
elf_abi field of qprocessInfo… (authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D26542?vs=77603&id=80892#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26542

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py


Index: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -663,6 +663,7 @@
 "triple",
 "vendor",
 "endian",
+"elf_abi",
 "ptrsize"
 ]
 


Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -663,6 +663,7 @@
 "triple",
 "vendor",
 "endian",
+"elf_abi",
 "ptrsize"
 ]
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27085: [LLDB][MIPS] Fix TestMultipleHits for MIPS

2016-12-09 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289210: [LLDB][MIPS] Fix TestMultipleHits for MIPS (authored 
by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D27085?vs=79038&id=80893#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27085

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
@@ -8,9 +8,7 @@
 
//===--===//
 #include 
 #include 
-
 alignas(16) uint8_t buf[32];
-
 // This uses inline assembly to generate an instruction that writes to a large
 // block of memory. If it fails on your compiler/architecture, please add
 // appropriate code to generate a large write to "buf". If you cannot write at
@@ -24,6 +22,8 @@
   asm volatile ("stm %0, { r0, r1, r2, r3 }" : : "r"(buf));
 #elif defined(__aarch64__)
   asm volatile ("stp x0, x1, %0" : : "m"(buf));
+#elif defined(__mips__)
+  asm volatile ("lw $2, %0" : : "m"(buf));
 #endif
   return 0;
 }


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp
@@ -8,9 +8,7 @@
 //===--===//
 #include 
 #include 
-
 alignas(16) uint8_t buf[32];
-
 // This uses inline assembly to generate an instruction that writes to a large
 // block of memory. If it fails on your compiler/architecture, please add
 // appropriate code to generate a large write to "buf". If you cannot write at
@@ -24,6 +22,8 @@
   asm volatile ("stm %0, { r0, r1, r2, r3 }" : : "r"(buf));
 #elif defined(__aarch64__)
   asm volatile ("stp x0, x1, %0" : : "m"(buf));
+#elif defined(__mips__)
+  asm volatile ("lw $2, %0" : : "m"(buf));
 #endif
   return 0;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27124: [LLDB][MIPS] Fix TestWatchpointIter failure

2016-12-09 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289211: [LLDB][MIPS] Fix TestWatchpointIter failure 
(authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D27124?vs=80414&id=80895#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27124

Files:
  lldb/trunk/source/Target/StopInfo.cpp


Index: lldb/trunk/source/Target/StopInfo.cpp
===
--- lldb/trunk/source/Target/StopInfo.cpp
+++ lldb/trunk/source/Target/StopInfo.cpp
@@ -692,7 +692,13 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+// We need to preserve the watch_index before watchpoint 
+// is disable. Since Watchpoint::SetEnabled will clear the
+// watch index.
+// This will fix TestWatchpointIter failure
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +716,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }


Index: lldb/trunk/source/Target/StopInfo.cpp
===
--- lldb/trunk/source/Target/StopInfo.cpp
+++ lldb/trunk/source/Target/StopInfo.cpp
@@ -692,7 +692,13 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+// We need to preserve the watch_index before watchpoint 
+// is disable. Since Watchpoint::SetEnabled will clear the
+// watch index.
+// This will fix TestWatchpointIter failure
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +716,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-09 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Hi Greg,

The patch https://reviews.llvm.org/D20357 evaluated the DwarfExpression and 
update the floating point register size. So should we implement 
SBRegisterContext and SBArchSpec  to evaluate dwarf expression and update the 
floating point register size accordingly for python test cases ?

OR

Should we implement above approach ?

Thanks


https://reviews.llvm.org/D27088



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


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2017-01-03 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 83012.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D27088

Files:
  include/lldb/API/SBDwarf.h
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
  scripts/lldb.swig

Index: scripts/lldb.swig
===
--- scripts/lldb.swig
+++ scripts/lldb.swig
@@ -66,6 +66,7 @@
 #include "lldb/API/SBCommunication.h"
 #include "lldb/API/SBCompileUnit.h"
 #include "lldb/API/SBData.h"
+#include "lldb/API/SBDwarf.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBError.h"
@@ -133,6 +134,7 @@
 %include "lldb/lldb-enumerations.h"
 %include "lldb/lldb-forward.h"
 %include "lldb/lldb-types.h"
+%include "lldb/API/SBDwarf.h"
 
 /* Forward declaration of SB classes. */
 %include "lldb/API/SBDefines.h"
Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -541,6 +541,10 @@
 self.assertIsNotNone(reg_infos)
 self.assertTrue(len(reg_infos) > 0)
 
+inferior_exe_path = os.path.abspath("a.out")
+Target = self.dbg.CreateTarget(inferior_exe_path)
+byte_order = Target.GetByteOrder()
+
 # Read value for each register.
 reg_index = 0
 for reg_info in reg_infos:
@@ -565,6 +569,9 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+
+if "dynamic_size_dwarf_expr_bytes" in reg_info:
+self.updateRegInfoBitsize(reg_info, byte_order)
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop
Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1260,6 +1260,94 @@
 
 return self.lldbArchitecture
 
+def updateRegInfoBitsize(self, reg_info, byte_order):
+""" Update the regInfo bit size. """
+
+# Evaluate Dwarf Expression
+expr_result = self.evaluateDwarfExpression(reg_info["dynamic_size_dwarf_expr_bytes"],
+byte_order)
+
+if expr_result == 0:
+reg_info["bitsize"] = 32
+elif expr_result == 1:
+reg_info["bitsize"] = 64
+
+def evaluateDwarfExpression(self, dwarf_opcode, byte_order):
+"""Evaluate Dwarf Expression. """
+
+dwarf_opcode = [dwarf_opcode[i:i+2] for i in range(0,len(dwarf_opcode),2)]
+dwarf_data = []
+for index in range(len(dwarf_opcode)):
+
+if index < len(dwarf_opcode):
+val = int(dwarf_opcode[index], 16)
+else:
+break
+
+if val == lldb.DW_OP_regx:
+# Read register number 
+self.assertTrue(len(dwarf_opcode) > (index + 1))
+reg_no = int(dwarf_opcode.pop(index + 1), 16)
+
+self.reset_test_sequence()
+# Read register value
+self.test_sequence.add_log_lines(
+ ["read packet: $p{0:x}#00".format(reg_no),
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#",
+ "capture": {1: "p_response"}}],True)
+
+Context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(Context)
+p_response = Context.get("p_response")
+self.assertIsNotNone(p_response)
+
+if byte_order == lldb.eByteOrderLittle:
+   # In case of little endian
+   # first decode the HEX ASCII bytes and then reverse it
+   # to get actual value of SR register
+   p_response = "".join(reversed([p_response[i:i+2] for i in range(0,
+  len(p_response),2)]))
+# Push register value
+dwarf_data.append(int(p_response,16))
+
+elif val == lldb.DW_OP_lit1:
+# Push literal 1
+dwarf_data.append(1)
+   
+elif val == lldb.DW_OP_lit26:
+# Push literal 26
+dwarf_data.append(26)
+
+elif val == lldb.DW_OP_shl:
+# left shift and push the result back
+self.assertTrue(len(dwarf_data) > 1)
+shift_amount = dwarf_data.pop()
+val_to_shift = dwarf_data.pop()
+result = val_to_shift << shift_amount
+dwa

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2017-01-03 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Instead of creating header SBDwarf.h, is it possible that python can reuse llvm 
Dwarf.h ?

Thanks


https://reviews.llvm.org/D27088



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


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2017-01-06 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 83520.
nitesh.jain added a comment.

Update diff as per suggestion


https://reviews.llvm.org/D27088

Files:
  packages/Python/lldbsuite/test/lldbdwarf.py
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py

Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -20,10 +20,11 @@
 import signal
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbdwarf import *
 from lldbsuite.test import lldbutil
 
 
-class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
+class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcodeParser):
 
 mydir = TestBase.compute_mydir(__file__)
 
@@ -541,6 +542,10 @@
 self.assertIsNotNone(reg_infos)
 self.assertTrue(len(reg_infos) > 0)
 
+inferior_exe_path = os.path.abspath("a.out")
+Target = self.dbg.CreateTarget(inferior_exe_path)
+byte_order = Target.GetByteOrder()
+
 # Read value for each register.
 reg_index = 0
 for reg_info in reg_infos:
@@ -565,6 +570,9 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+
+if "dynamic_size_dwarf_expr_bytes" in reg_info:
+self.updateRegInfoBitsize(reg_info, byte_order)
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop
Index: packages/Python/lldbsuite/test/lldbdwarf.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/lldbdwarf.py
@@ -0,0 +1,256 @@
+""" This module implement Dwarf expression opcode parser. """
+
+import lldb
+
+# DWARF Expression operators.
+DW_OP_addr  = 0x03
+DW_OP_deref = 0x06
+DW_OP_const1u   = 0x08
+DW_OP_const1s   = 0x09
+DW_OP_const2u   = 0x0A
+DW_OP_const2s   = 0x0B
+DW_OP_const4u   = 0x0C
+DW_OP_const4s   = 0x0D
+DW_OP_const8u   = 0x0E
+DW_OP_const8s   = 0x0F
+DW_OP_constu= 0x10
+DW_OP_consts= 0x11
+DW_OP_dup   = 0x12
+DW_OP_drop  = 0x13
+DW_OP_over  = 0x14
+DW_OP_pick  = 0x15
+DW_OP_swap  = 0x16
+DW_OP_rot   = 0x17
+DW_OP_xderef= 0x18
+DW_OP_abs   = 0x19
+DW_OP_and   = 0x1A
+DW_OP_div   = 0x1B
+DW_OP_minus = 0x1C
+DW_OP_mod   = 0x1D
+DW_OP_mul   = 0x1E
+DW_OP_neg   = 0x1F
+DW_OP_not   = 0x20
+DW_OP_or= 0x21
+DW_OP_plus  = 0x22
+DW_OP_plus_uconst   = 0x23
+DW_OP_shl   = 0x24
+DW_OP_shr   = 0x25
+DW_OP_shra  = 0x26
+DW_OP_xor   = 0x27
+DW_OP_skip  = 0x2F
+DW_OP_bra   = 0x28
+DW_OP_eq= 0x29
+DW_OP_ge= 0x2A
+DW_OP_gt= 0x2B
+DW_OP_le= 0x2C
+DW_OP_lt= 0x2D
+DW_OP_ne= 0x2E
+DW_OP_lit0  = 0x30
+DW_OP_lit1  = 0x31
+DW_OP_lit2  = 0x32
+DW_OP_lit3  = 0x33
+DW_OP_lit4  = 0x34
+DW_OP_lit5  = 0x35
+DW_OP_lit6  = 0x36
+DW_OP_lit7  = 0x37
+DW_OP_lit8  = 0x38
+DW_OP_lit9  = 0x39
+DW_OP_lit10 = 0x3A
+DW_OP_lit11 = 0x3B
+DW_OP_lit12 = 0x3C
+DW_OP_lit13 = 0x3D
+DW_OP_lit14 = 0x3E
+DW_OP_lit15 = 0x3F
+DW_OP_lit16 = 0x40
+DW_OP_lit17 = 0x41
+DW_OP_lit18 = 0x42
+DW_OP_lit19 = 0x43
+DW_OP_lit20 = 0x44
+DW_OP_lit21 = 0x45
+DW_OP_lit22 = 0x46
+DW_OP_lit23 = 0x47
+DW_OP_lit24 = 0x48

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2017-01-10 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291549: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS 
(authored by nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D27088?vs=83520&id=83781#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27088

Files:
  lldb/trunk/Python/lldbsuite/test/lldbdwarf.py
  
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py

Index: lldb/trunk/Python/lldbsuite/test/lldbdwarf.py
===
--- lldb/trunk/Python/lldbsuite/test/lldbdwarf.py
+++ lldb/trunk/Python/lldbsuite/test/lldbdwarf.py
@@ -0,0 +1,256 @@
+""" This module implement Dwarf expression opcode parser. """
+
+import lldb
+
+# DWARF Expression operators.
+DW_OP_addr  = 0x03
+DW_OP_deref = 0x06
+DW_OP_const1u   = 0x08
+DW_OP_const1s   = 0x09
+DW_OP_const2u   = 0x0A
+DW_OP_const2s   = 0x0B
+DW_OP_const4u   = 0x0C
+DW_OP_const4s   = 0x0D
+DW_OP_const8u   = 0x0E
+DW_OP_const8s   = 0x0F
+DW_OP_constu= 0x10
+DW_OP_consts= 0x11
+DW_OP_dup   = 0x12
+DW_OP_drop  = 0x13
+DW_OP_over  = 0x14
+DW_OP_pick  = 0x15
+DW_OP_swap  = 0x16
+DW_OP_rot   = 0x17
+DW_OP_xderef= 0x18
+DW_OP_abs   = 0x19
+DW_OP_and   = 0x1A
+DW_OP_div   = 0x1B
+DW_OP_minus = 0x1C
+DW_OP_mod   = 0x1D
+DW_OP_mul   = 0x1E
+DW_OP_neg   = 0x1F
+DW_OP_not   = 0x20
+DW_OP_or= 0x21
+DW_OP_plus  = 0x22
+DW_OP_plus_uconst   = 0x23
+DW_OP_shl   = 0x24
+DW_OP_shr   = 0x25
+DW_OP_shra  = 0x26
+DW_OP_xor   = 0x27
+DW_OP_skip  = 0x2F
+DW_OP_bra   = 0x28
+DW_OP_eq= 0x29
+DW_OP_ge= 0x2A
+DW_OP_gt= 0x2B
+DW_OP_le= 0x2C
+DW_OP_lt= 0x2D
+DW_OP_ne= 0x2E
+DW_OP_lit0  = 0x30
+DW_OP_lit1  = 0x31
+DW_OP_lit2  = 0x32
+DW_OP_lit3  = 0x33
+DW_OP_lit4  = 0x34
+DW_OP_lit5  = 0x35
+DW_OP_lit6  = 0x36
+DW_OP_lit7  = 0x37
+DW_OP_lit8  = 0x38
+DW_OP_lit9  = 0x39
+DW_OP_lit10 = 0x3A
+DW_OP_lit11 = 0x3B
+DW_OP_lit12 = 0x3C
+DW_OP_lit13 = 0x3D
+DW_OP_lit14 = 0x3E
+DW_OP_lit15 = 0x3F
+DW_OP_lit16 = 0x40
+DW_OP_lit17 = 0x41
+DW_OP_lit18 = 0x42
+DW_OP_lit19 = 0x43
+DW_OP_lit20 = 0x44
+DW_OP_lit21 = 0x45
+DW_OP_lit22 = 0x46
+DW_OP_lit23 = 0x47
+DW_OP_lit24 = 0x48
+DW_OP_lit25 = 0x49
+DW_OP_lit26 = 0x4A
+DW_OP_lit27 = 0x4B
+DW_OP_lit28 = 0x4C
+DW_OP_lit29 = 0x4D
+DW_OP_lit30 = 0x4E
+DW_OP_lit31 = 0x4F
+DW_OP_reg0  = 0x50
+DW_OP_reg1  = 0x51
+DW_OP_reg2  = 0x52
+DW_OP_reg3  = 0x53
+DW_OP_reg4  = 0x54
+DW_OP_reg5  = 0x55
+DW_OP_reg6  = 0x56
+DW_OP_reg7  = 0x57
+DW_OP_reg8  = 0x58
+DW_OP_reg9  = 0x59
+DW_OP_reg10 = 0x5A
+DW_OP_reg11 = 0x5B
+DW_OP_reg12 = 0x5C
+DW_OP_reg13 = 0x5D
+DW_OP_reg14 = 0x5E
+DW_OP_reg15 = 0x5F
+DW_OP_reg16 = 0x60
+DW_OP_reg17 = 0x61
+DW_OP_reg18 = 0x62
+DW_OP_reg19 = 0x63
+DW_OP_reg20 = 0x64
+DW_OP_re

[Lldb-commits] [PATCH] D29215: [LLDB][MIPS] Fix TestMiniDumpNew

2017-01-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.

In case of a core file, if the core file architecture(like x86_64) is 
incompatible with that of Host architecture(like Mips64) then platform is set 
to remote-platform. If the remote-platform is not connected then 
SBPlatform::GetTriple() will return none. Hence we assume target platform is 
same as the host platform.

(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.

>>> import lldb
>>>  dbg = lldb.SBDebugger.Create()
>>>  print dbg.GetSelectedPlatform().GetName()

host

>>> print dbg.GetSelectedPlatform().GetTriple()

mips64el--linux-gnu

>>> dbg.CreateTarget("linux-x86_64")

 >

>>> print dbg.GetSelectedPlatform().GetName()

remote-linux

>>> print dbg.GetSelectedPlatform().GetTriple()

None

>>> print dbg.GetSelectedPlatform().IsConnected()

False

>>> 




Repository:
  rL LLVM

https://reviews.llvm.org/D29215

Files:
  packages/Python/lldbsuite/test/lldbplatformutil.py


Index: packages/Python/lldbsuite/test/lldbplatformutil.py
===
--- packages/Python/lldbsuite/test/lldbplatformutil.py
+++ packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -127,7 +127,15 @@
 
 def getPlatform():
 """Returns the target platform which the tests are running on."""
-platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+if lldb.DBG.GetSelectedPlatform().GetTriple():
+platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+else:
+# In case of a core file, if the core file architecture(like x86_64)
+# is incompatible with that of Host architecture(like Mips64)
+# then platform is set to remote-platform. If the remote-platform is
+# not connected then SBPlatform::GetTriple() will return none.
+# Hence we assume target platform is same as the host platform.
+platform = sys.platform
 if platform.startswith('freebsd'):
 platform = 'freebsd'
 elif platform.startswith('netbsd'):


Index: packages/Python/lldbsuite/test/lldbplatformutil.py
===
--- packages/Python/lldbsuite/test/lldbplatformutil.py
+++ packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -127,7 +127,15 @@
 
 def getPlatform():
 """Returns the target platform which the tests are running on."""
-platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+if lldb.DBG.GetSelectedPlatform().GetTriple():
+platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+else:
+# In case of a core file, if the core file architecture(like x86_64)
+# is incompatible with that of Host architecture(like Mips64)
+# then platform is set to remote-platform. If the remote-platform is
+# not connected then SBPlatform::GetTriple() will return none.
+# Hence we assume target platform is same as the host platform.
+platform = sys.platform
 if platform.startswith('freebsd'):
 platform = 'freebsd'
 elif platform.startswith('netbsd'):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29215: [LLDB][MIPS] Fix TestMiniDumpNew

2017-01-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Hi Labath,

I think on window ur host architecture is x86_64 hence when 
TargetList::CreateTargetInternal(..)  is call, at line 269 the code is

  if (!prefer_platform_arch && arch.IsValid()) {
if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
  platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
  if (!is_dummy_target && platform_sp)
debugger.GetPlatformList().SetSelectedPlatform(platform_sp);

The line platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch) 
will be true , if ur host architecture is x86(which is ur case). In our case 
since host architecture is Mips it will return false. hence 
Platform::GetPlatformForArchitecture(arch, &platform_arch) will be set platform 
to remote-linux


Repository:
  rL LLVM

https://reviews.llvm.org/D29215



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


[Lldb-commits] [PATCH] D29215: [LLDB][MIPS] Fix TestMiniDumpNew

2017-01-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

ERROR: test_two_cores_same_pid (TestMiniDumpNew.MiniDumpNewTestCase)

  Test that we handle the situation if we have two core files with the same PID

--

Traceback (most recent call last):

  File 
"/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1884, in setUp
Base.setUp(self)
  File 
"/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 835, in setUp
self.darwinWithFramework = self.platformIsDarwin()
  File 
"/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1300, in platformIsDarwin
return lldbplatformutil.platformIsDarwin()
  File 
"/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py",
 line 140, in platformIsDarwin
return getPlatform() in getDarwinOSTriples()
  File 
"/export/tmp/nin/LLVM/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py",
 line 130, in getPlatform
platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]

AttributeError: 'NoneType' object has no attribute 'split'


Repository:
  rL LLVM

https://reviews.llvm.org/D29215



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


[Lldb-commits] [PATCH] D29215: [LLDB][MIPS] Fix TestMiniDumpNew

2017-01-30 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 86268.
nitesh.jain added a comment.

Added setUp/tearDown code, which saves and restores the original platform after 
each run. Thanks


https://reviews.llvm.org/D29215

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py


Index: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@
 _linux_x86_64_not_crashed_pid = 29939
 _linux_x86_64_not_crashed_pid_offset = 0xD967
 
+def setUp(self):
+super(MiniDumpNewTestCase, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(MiniDumpNewTestCase, self).tearDown()
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp


Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@
 _linux_x86_64_not_crashed_pid = 29939
 _linux_x86_64_not_crashed_pid_offset = 0xD967
 
+def setUp(self):
+super(MiniDumpNewTestCase, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(MiniDumpNewTestCase, self).tearDown()
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29215: [LLDB][MIPS] Fix TestMiniDumpNew

2017-02-07 Thread Nitesh Jain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294415: [LLDB][MIPS] Fix TestMiniDumpNew (authored by 
nitesh.jain).

Changed prior to commit:
  https://reviews.llvm.org/D29215?vs=86268&id=87598#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29215

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@
 _linux_x86_64_not_crashed_pid = 29939
 _linux_x86_64_not_crashed_pid_offset = 0xD967
 
+def setUp(self):
+super(MiniDumpNewTestCase, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(MiniDumpNewTestCase, self).tearDown()
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the 
Minidump."""
 # target create -c linux-x86_64.dmp


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@
 _linux_x86_64_not_crashed_pid = 29939
 _linux_x86_64_not_crashed_pid_offset = 0xD967
 
+def setUp(self):
+super(MiniDumpNewTestCase, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(MiniDumpNewTestCase, self).tearDown()
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Fix typo in MatchesModuleSpec()

2017-02-28 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.

The MatchesModuleSpec() should return false if module_ref is not found.


https://reviews.llvm.org/D30454

Files:
  source/Core/Module.cpp


Index: source/Core/Module.cpp
===
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1615,10 +1615,10 @@
 
   const ConstString &object_name = module_ref.GetObjectName();
   if (object_name) {
-if (object_name != GetObjectName())
-  return false;
+if (object_name == GetObjectName())
+  return true;
   }
-  return true;
+  return false;
 }
 
 bool Module::FindSourceFile(const FileSpec &orig_spec,


Index: source/Core/Module.cpp
===
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1615,10 +1615,10 @@
 
   const ConstString &object_name = module_ref.GetObjectName();
   if (object_name) {
-if (object_name != GetObjectName())
-  return false;
+if (object_name == GetObjectName())
+  return true;
   }
-  return true;
+  return false;
 }
 
 bool Module::FindSourceFile(const FileSpec &orig_spec,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-02-28 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain created this revision.

This patch add support for core file. This patch includes

- Separation of register context which was earlier share between Linux and 
FreeBSD.



- Add support to analyse Linux core file for all three ABI (N32, N64 and O32)




https://reviews.llvm.org/D30457

Files:
  source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
  source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
  source/Plugins/Process/Utility/RegisterInfoInterface.h
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
  source/Plugins/Process/elf-core/ThreadElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.h

Index: source/Plugins/Process/elf-core/ThreadElfCore.h
===
--- source/Plugins/Process/elf-core/ThreadElfCore.h
+++ source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -66,6 +66,17 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS()) {
+  std::string abi = arch.GetTargetABI();
+  assert(!abi.empty() && "ABI is not set");
+  if (!abi.compare("n64"))
+return sizeof(ELFLinuxPrStatus);
+  else if (!abi.compare("o32"))
+return 96;
+  // N32 ABI
+  return 72;
+}
+
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_s390x_generic:
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
@@ -98,6 +109,8 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(const lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS())
+return sizeof(ELFLinuxSigInfo);
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
   return sizeof(ELFLinuxSigInfo);
@@ -144,6 +157,13 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS()) {
+  uint8_t address_byte_size = arch.GetAddressByteSize();
+  if (address_byte_size == 8)
+return sizeof(ELFLinuxPrPsInfo);
+  return 128;
+}
+
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_s390x_generic:
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -18,6 +18,8 @@
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@@ -118,6 +120,12 @@
   case llvm::Triple::aarch64:
 reg_interface = new RegisterInfoPOSIX_arm64(arch);
 break;
+  case llvm::Triple::mipsel:
+reg_interface = new RegisterContextLinux_mips(arch);
+break;
+  case llvm::Triple::mips64el:
+reg_interface = new RegisterContextLinux_mips64(arch);
+break;
   case llvm::Triple::systemz:
 reg_interface = new RegisterContextLinux_s390x(arch);
 break;
@@ -153,7 +161,13 @@
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
+case llvm::Triple::mipsel:
+case llvm::Triple::mips:
+  m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+  break;
 case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
===
--- source/Plugins/Process/elf-core/RegisterContextPOS

[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Fix typo in MatchesModuleSpec()

2017-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

The issue was observed while parsing "vdso module" for the core file. When the 
DynamicLoader::LoadModuleAtAddress is called to load "vdso" module. Since 
"vdso" doesn't match with any of the module in the target.GetImages(), the 
check_alternative_file_name becomes true. This cause MatchesModuleSpec to 
return true and application binary to reload again at vdso base 
address(AT_SYSINFO_EHDR) thus all load addresses of application elf's sections 
becomes incorrect. Please find attach log file.
DynamicLoader::LoadModuleAtAddress(...)
{

  ...
  ...
  ...
  if (check_alternative_file_name) {
  ...
  ...
  ...
  **FileSpec(memory_info.GetName().AsCString(), false),**  ** // 
memory_info.GetName().AsCString() is empty here**
  target.GetArchitecture());
  
  if ((module_sp = modules.FindFirstModule(new_module_spec))) {  // 
FindFirstModule returns application elf's module
UpdateLoadedSections(module_sp, link_map_addr, base_addr, false); // 
load addresses of application elf's sections gets updated to vdso's address 
(which is incorrect)
return module_sp;
  }

...
 ...
 ...
}


https://reviews.llvm.org/D30454



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


[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Fix typo in MatchesModuleSpec()

2017-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

Attach log file F3122646: module.log 


https://reviews.llvm.org/D30454



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


[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 90328.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D30457

Files:
  source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
  source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
  source/Plugins/Process/elf-core/ThreadElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.h

Index: source/Plugins/Process/elf-core/ThreadElfCore.h
===
--- source/Plugins/Process/elf-core/ThreadElfCore.h
+++ source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -19,6 +19,10 @@
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Target/Thread.h"
 
+#define MIPS_LINUX_PR_STATUS_SIZE_O32 96
+#define MIPS_LINUX_PR_STATUS_SIZE_N32 72
+#define MIPS_LINUX_PR_PSINFO_SIZE_O32_N32 128
+
 struct compat_timeval {
   alignas(8) uint64_t tv_sec;
   alignas(8) uint64_t tv_usec;
@@ -66,6 +70,17 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS()) {
+  std::string abi = arch.GetTargetABI();
+  assert(!abi.empty() && "ABI is not set");
+  if (!abi.compare("n64"))
+return sizeof(ELFLinuxPrStatus);
+  else if (!abi.compare("o32"))
+return MIPS_LINUX_PR_STATUS_SIZE_O32;
+  // N32 ABI
+  return MIPS_LINUX_PR_STATUS_SIZE_N32;
+}
+
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_s390x_generic:
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
@@ -98,6 +113,8 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(const lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS())
+return sizeof(ELFLinuxSigInfo);
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
   return sizeof(ELFLinuxSigInfo);
@@ -144,6 +161,13 @@
   // members are smaller -
   // so the layout is not the same
   static size_t GetSize(lldb_private::ArchSpec &arch) {
+if (arch.IsMIPS()) {
+  uint8_t address_byte_size = arch.GetAddressByteSize();
+  if (address_byte_size == 8)
+return sizeof(ELFLinuxPrPsInfo);
+  return MIPS_LINUX_PR_PSINFO_SIZE_O32_N32;
+}
+
 switch (arch.GetCore()) {
 case lldb_private::ArchSpec::eCore_s390x_generic:
 case lldb_private::ArchSpec::eCore_x86_64_x86_64:
Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -18,6 +18,8 @@
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@@ -118,6 +120,14 @@
   case llvm::Triple::aarch64:
 reg_interface = new RegisterInfoPOSIX_arm64(arch);
 break;
+  case llvm::Triple::mipsel:
+  case llvm::Triple::mips:
+reg_interface = new RegisterContextLinux_mips(arch);
+break;
+  case llvm::Triple::mips64el:
+  case llvm::Triple::mips64:
+reg_interface = new RegisterContextLinux_mips64(arch);
+break;
   case llvm::Triple::systemz:
 reg_interface = new RegisterContextLinux_s390x(arch);
 break;
@@ -153,7 +163,13 @@
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
+case llvm::Triple::mipsel:
+case llvm::Triple::mips:
+  m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+  break;
 case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
Index: so

[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain marked an inline comment as done.
nitesh.jain added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterInfoInterface.h:32
 
+  virtual const lldb_private::RegisterSet *
+  GetRegisterSet(size_t set) const {return nullptr;}

labath wrote:
> While I don't see anything obviously wrong about adding this interface, I am 
> wondering why the other subclasses have not needed this.
> 
> I'd defer to @clayborg judgement on the appropriateness of the interface. 
> What I don't like however, is that the default implementation will blatantly 
> lie about the number of register sets for the non-mips case.
> 
> What I can suggest is to avoid putting these functions in the generic class 
> -- you seem to be calling them from mips code only, so I don't see any 
> immediate need to have them here. (e.g. have GetRegisterInfoInterface() cast 
> to the appropriate type).
In case of MIPS, the register set is different for FreeBSD and Linux. In other 
platform, the register set may be same.  


https://reviews.llvm.org/D30457



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


[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain marked an inline comment as done.
nitesh.jain added a comment.

The  .note.ABI-tag is missing in the  ELF file, generated by 
test/testcases/functionalities/postmortem/elf-core/make-core.sh. Need to look 
into it.

-Thanks


https://reviews.llvm.org/D30457



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


[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Fix typo in MatchesModuleSpec()

2017-03-07 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D30454#693614, @clayborg wrote:

> So a ModuleSpec allows you to specify a module by path, UUID and many other 
> things. This is falling down for a magic file that doesn't actually exist 
> right?




  Yes.

> "vsdo" is just a made up name for the table of loaded shared libraries? Is 
> that correct? I need to understand what is going on before I can offer 
> correct guidance.

I am not sure about that. From Man page, the "vDSO" (virtual dynamic shared 
object) is a small shared library that the kernel automatically maps into the 
address space of all user-space applications.

Thanks


https://reviews.llvm.org/D30454



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


[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Regain Module Name if memory_info.GetName() is empty

2017-03-15 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 91833.
nitesh.jain retitled this revision from "[LLDB][MIPS] Fix typo in 
MatchesModuleSpec()" to "[LLDB][MIPS] Regain Module Name if 
memory_info.GetName()  is empty".
nitesh.jain added a comment.

In case of debugging normal process, the memory_info.GetName() is not empty and 
hence module is read from memory (m_process->ReadModuleFromMemory) and the 
corresponding sections are updated. In case of core file , the 
memory_info.GetName() is empty which causes FindFirstModule to matches with the 
first module in ModuleSpecList and result in loading wrong module at incorrect 
sections addresses. This patch regain "vdso" module name if  
memory_info.GetName() is empty.


https://reviews.llvm.org/D30454

Files:
  source/Core/DynamicLoader.cpp


Index: source/Core/DynamicLoader.cpp
===
--- source/Core/DynamicLoader.cpp
+++ source/Core/DynamicLoader.cpp
@@ -190,6 +190,10 @@
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
 memory_info.GetRange().GetRangeBase() == base_addr) {
+  // Regain name if memory_info.GetName is empty
+  if (memory_info.GetName().IsEmpty())
+memory_info.SetName(file.GetFilename().AsCString());
+   
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());


Index: source/Core/DynamicLoader.cpp
===
--- source/Core/DynamicLoader.cpp
+++ source/Core/DynamicLoader.cpp
@@ -190,6 +190,10 @@
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
 memory_info.GetRange().GetRangeBase() == base_addr) {
+  // Regain name if memory_info.GetName is empty
+  if (memory_info.GetName().IsEmpty())
+memory_info.SetName(file.GetFilename().AsCString());
+   
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Check if memory_info.GetName() is empty before finding corresponding module.

2017-03-15 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 91855.
nitesh.jain retitled this revision from "[LLDB][MIPS] Regain Module Name if 
memory_info.GetName()  is empty" to "[LLDB][MIPS] Check if 
memory_info.GetName() is empty before finding corresponding module.".
nitesh.jain edited the summary of this revision.

https://reviews.llvm.org/D30454

Files:
  source/Core/DynamicLoader.cpp


Index: source/Core/DynamicLoader.cpp
===
--- source/Core/DynamicLoader.cpp
+++ source/Core/DynamicLoader.cpp
@@ -189,7 +189,8 @@
 MemoryRegionInfo memory_info;
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
-memory_info.GetRange().GetRangeBase() == base_addr) {
+memory_info.GetRange().GetRangeBase() == base_addr && 
+!(memory_info.GetName().IsEmpty())) {
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());


Index: source/Core/DynamicLoader.cpp
===
--- source/Core/DynamicLoader.cpp
+++ source/Core/DynamicLoader.cpp
@@ -189,7 +189,8 @@
 MemoryRegionInfo memory_info;
 Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
 if (error.Success() && memory_info.GetMapped() &&
-memory_info.GetRange().GetRangeBase() == base_addr) {
+memory_info.GetRange().GetRangeBase() == base_addr && 
+!(memory_info.GetName().IsEmpty())) {
   ModuleSpec new_module_spec(
   FileSpec(memory_info.GetName().AsCString(), false),
   target.GetArchitecture());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-15 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 91881.
nitesh.jain added a comment.

Update Diff as per suggestion


https://reviews.llvm.org/D30457

Files:
  source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
  source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips.h
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
  source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
  source/Plugins/Process/elf-core/ThreadElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.h

Index: source/Plugins/Process/elf-core/ThreadElfCore.h
===
--- source/Plugins/Process/elf-core/ThreadElfCore.h
+++ source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -65,18 +65,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxPrStatus);
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 72;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
@@ -97,18 +86,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(const lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxSigInfo);
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 12;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(const lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxSigInfo) == 12,
@@ -143,18 +121,7 @@
   // 32 bit - hardcoded because we are reusing the struct, but some of the
   // members are smaller -
   // so the layout is not the same
-  static size_t GetSize(lldb_private::ArchSpec &arch) {
-switch (arch.GetCore()) {
-case lldb_private::ArchSpec::eCore_s390x_generic:
-case lldb_private::ArchSpec::eCore_x86_64_x86_64:
-  return sizeof(ELFLinuxPrPsInfo);
-case lldb_private::ArchSpec::eCore_x86_32_i386:
-case lldb_private::ArchSpec::eCore_x86_32_i486:
-  return 124;
-default:
-  return 0;
-}
-  }
+  static size_t GetSize(lldb_private::ArchSpec &arch);
 };
 
 static_assert(sizeof(ELFLinuxPrPsInfo) == 136,
Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -18,6 +18,8 @@
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@@ -118,6 +120,14 @@
   case llvm::Triple::aarch64:
 reg_interface = new RegisterInfoPOSIX_arm64(arch);
 break;
+  case llvm::Triple::mipsel:
+  case llvm::Triple::mips:
+reg_interface = new RegisterContextLinux_mips(arch);
+break;
+  case llvm::Triple::mips64el:
+  case llvm::Triple::mips64:
+reg_interface = new RegisterContextLinux_mips64(arch);
+break;
   case llvm::Triple::systemz:
 reg_interface = new RegisterContextLinux_s390x(arch);
 break;
@@ -153,7 +163,13 @@
   m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
   *this, reg_interface, m_gpregset_data, m_fpregset_data));
   break;
+case llvm::Triple::mipsel:
+case llvm::Triple::mips:
+  m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data

[Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support

2017-03-15 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In https://reviews.llvm.org/D30457#694306, @labath wrote:

>   Thank you for updating that. Let me know what the make_core investigation 
> uncovers.


In case of MIPS, the core file doesn't contain Arch and OS information. Hence 
we shared information from executable.  The make_core use "-nostdlib" flag 
because of which .note.ABI-tag is missing in the ELF file.  Hence OS is set to 
unknown. I will look into it and submit a separate patch for that.

Thanks


https://reviews.llvm.org/D30457



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


[Lldb-commits] [PATCH] D96766: [lldb] [Process/FreeBSD] Introduce mips64 FPU reg support

2021-03-02 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain added a comment.

In D96766#2596701 , @labath wrote:

> Hm I'm very tempted to delete the linux mips implementation -- it uses 
> several techniques which are getting in the way of this patch (and also some 
> others in the past), for a lot of those, we now have different/better ways of 
> doing it. On top of that, it's completely unmaintained (last non-nfc change 
> to the file was in 2017, and the author (@nitesh.jain) does not appear to be 
> active anymore.

Hi Labath,

As you notice, we no longer work for MIPS and not sure who is the current 
maintainer for the same.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96766/new/

https://reviews.llvm.org/D96766

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