[Lldb-commits] [PATCH] D29669: Hardware breakpoints implementation for AArch64 targets

Muhammad Omair Javaid via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 7 12:10:05 PST 2017


omjavaid created this revision.
Herald added subscribers: mgorny, danalbert, rengolin, aemerson.

This patch implements hardware breakpoint functionality in LLDB for AArch64 targets. AArch64 targets supports hardware breakpoints via ptrace interface similar to hardware watchpoints. Hardware breakpoints provide fast way to stop target not requiring any memory read/write like software breakpoints.

This patch fixes areas which required tweaking to put hardware breakpoints implementation in place via process gdb remote. We are able to test these breakpoints via a simple application on Android Nexux5x devices.

I am in process of testing on various other platforms and also writing lldb testsuite test cases.

Still on TODO list:

1. LLDB Testsuite testcases for hardware breakpoints testing.
2. Similar implementation for Arm targets.
3. Improve stepping speed by trying to use hardware in place of software breakpoints which single step is being done via breakpoints.

Looking forward to upstream comments on this.

Test code in case someone wants to test:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

#define THREAD_COUNT 8

void *thread_function( void *ptr )
{

  int *argument = (int *) ptr;
  
  printf("Thread #%i \n", *argument);

}

int main()
{

  int argument[THREAD_COUNT];
  pthread_t thread_handle[THREAD_COUNT];
  
  int i;
  for (i = 0; i < THREAD_COUNT; i++)
  { 
    argument[i] = i;
    if (pthread_create( &thread_handle[i], NULL, thread_function, (void*) &argument[i]))
    {
      printf("Error - pthread_create() failed\n");
      exit(EXIT_FAILURE);
    }
  }
  
  for (i = 0; i < THREAD_COUNT; i++)
    pthread_join( thread_handle[i], NULL);
  
  exit(EXIT_SUCCESS);
  
  return 0;

}


https://reviews.llvm.org/D29669

Files:
  include/lldb/Host/common/HardwareBreakpointList.h
  include/lldb/Host/common/NativeProcessProtocol.h
  include/lldb/Host/common/NativeRegisterContext.h
  include/lldb/Host/common/NativeThreadProtocol.h
  source/Host/CMakeLists.txt
  source/Host/common/HardwareBreakpointList.cpp
  source/Host/common/NativeProcessProtocol.cpp
  source/Host/common/NativeRegisterContext.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.h
  source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  source/Plugins/Process/Linux/NativeThreadLinux.cpp
  source/Plugins/Process/Linux/NativeThreadLinux.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29669.87493.patch
Type: text/x-patch
Size: 28286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170207/34bc64bd/attachment-0001.bin>


More information about the lldb-commits mailing list