Introducing LLDB for Linux on Arm and AArch64. Omair Javaid

Similar documents
Porting LLDB. Hafiz Abid Qadeer. mentor.com/embedded

LLDB for your hardware: Remote Debugging the Hexagon DSP

Using a debugger. Segmentation fault? GDB to the rescue!

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

BUD Introduction to LLVM Projects, Components, Integration, Internals Renato Golin, Diana Picus Peter Smith, Omair Javaid Adhemerval Zanella

Red Hat Developer Tools

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args>

System Debug. This material exempt per Department of Commerce license exception TSU Xilinx, Inc. All Rights Reserved

Chapter 2. Operating-System Structures

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Red Hat Developer Tools

CSE 351. GDB Introduction

CSE 4/521 Introduction to Operating Systems

What s New in Platform Builder 7

SE350: Operating Systems

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

swiftenv Documentation

Lecture 4 Processes. Dynamic Analysis. GDB

Lab 3-2: Exploring the Heap

Source level debugging. October 18, 2016

18-600: Recitation #3

C03c: Linkers and Loaders

Visual Studio 2008 Load Symbols Manually

Operating System Services. User Services. System Operation Services. User Operating System Interface - CLI. A View of Operating System Services

Kai Nacke DConf 2016

Exercise Session 6 Computer Architecture and Systems Programming

Download, Install and Setup the Linux Development Workload Create a New Linux Project Configure a Linux Project Configure a Linux CMake Project

ECE 471 Embedded Systems Lecture 8

NADK Reflector Application Debug

What are some common categories of system calls? What are common ways of structuring an OS? What are the principles behind OS design and

How to cross compile with LLVM based tools. Peter Smith, Linaro

KOTLIN/NATIVE + CLANG, TRAVEL NOTES NIKOLAY IGOTTI, JETBRAINS

GDB, so where are we now?

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni

2012 LLVM Euro - Michael Spencer. lld. Friday, April 13, The LLVM Linker

Programming Studio #9 ECE 190

Debugging of CPython processes with gdb

ECE 471 Embedded Systems Lecture 4

Xcode Tricks. ios App Development Fall 2010 Lecture 13

Laboratorio di Tecnologie dell'informazione

Debugging for production systems

21. This is a screenshot of the Android Studio Debugger. It shows the current thread and the object tree for a certain variable.

Debugging uclinux on Coldfire

U-Boot and Linux Kernel Debug using CCSv5

Intermediate Python 3.x

Embedded Systems Programming

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Intel Parallel Studio XE 2017 Composer Edition BETA C++ - Debug Solutions Release Notes

Notes of the course - Advanced Programming. Barbara Russo

Chapter 2: System Structures

CSE 410: Systems Programming

Reverse Engineering Malware Dynamic Analysis of Binary Malware II

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Chapter 2: System Structures. Operating System Concepts 9 th Edition

GPU Computing Master Clss. Development Tools

ECE 471 Embedded Systems Lecture 5

Building graphic-rich and better performing native applications. Pro. Android C++ with the NDK. Onur Cinar

WRITING CONSOLE APPLICATIONS IN C

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

CS201 Lecture 2 GDB, The C Library

Bash command shell language interpreter

What s New in the LLVM Compiler. Chris Lattner LLVM Chief Architect

What's New in CDT 7.0? dominique dot toupin at ericsson dot com

HiKey in AOSP - Update. John Stultz

Introduction to Mobile Development

LDC: The LLVM-based D Compiler

IBM Case Manager Mobile Version SDK for ios Developers' Guide IBM SC

PTN-202: Advanced Python Programming Course Description. Course Outline

Embest IDE Pro for ARM 2005

Eclipse Debug Find Current Instruction Pointer

ART JIT in Android N. Xueliang ZHONG Linaro ART Team

LLVM An Introduction. Linux Collaboration Summit, April 7, 2011 David Kipping, Qualcomm Incorporated

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

NSIGHT ECLIPSE EDITION

manifold Documentation

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

GDB cheatsheet - page 1

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

TRACE32 as GDB Back-End

Implementation of Breakpoints in GDB for Sim-nML based Architectures

Chapter 2: Operating-System

syscall_intercept A user space library for intercepting system calls Author Name, Company Krzysztof Czuryło, Intel

State of the Port to x86_64 July 2017

Mesos on ARM. Feng Li( 李枫 ),

Improve your C++! John Richardson. Lab Study Meeting 2013

Blue Gene/Q User Workshop. Debugging

LLVM and IR Construction

a translator to convert your AST representation to a TAC intermediate representation; and

Advanced Debugging and the Address Sanitizer

Eclipse-Based CodeWarrior Debugger

Checkpointing using DMTCP, Condor, Matlab and FReD

Chapter 2 Operating System Structures

An Introduction to Komodo

Before you start with this tutorial, you need to know basic Java programming.

DS-5 ARM. Getting Started with DS-5. Version 5.6. Copyright 2010, 2011 ARM. All rights reserved. ARM DUI 0478F (ID071411)

ELEC 377 Operating Systems. Week 1 Class 2

Profilers and Debuggers. Introductory Material. One-Slide Summary

Transcription:

Introducing LLDB for Linux on Arm and AArch64 Omair Javaid

Agenda ENGINEERS AND DEVICES WORKING TOGETHER Brief introduction and history behind LLDB Status of LLDB on Linux and Android Linaro s contributions in LLDB An overview of LLDB Architecture More detail on working and architecture Overview of basic functionality and commands Overview of expressions and data formatters.

LLDB - Introduction Debugger component of LLVM project. A modular, high-performance source-level debugger written in C++ Re-uses LLVM/Clang code JIT/IR for expression parsing, disassembly etc. Provides a C++ Debugger API which can be used by various clients Very permissive BSD-like license.

LLDB - Introduction (cont ) Supported Host Platforms Supported Target Architectures OS X, Linux/Android, FreeBSD, NetBSD, and Windows i386/x86_64, Arm/AArch64, MIPS/MIPS64, IBM s390 Supported Languages Fully support C, C++ and Objective-C while SWIFT and GoLang (under development)

LLDB - History Apple stopped shipping GDB after version 6.3.5 Last GPLv2 based GDB release. Announced LLDB at WWDC2010. Extensively under development for various use-cases. Active code contributors are Apple and Google. Default debugger for OSX, Xcode IDE, Android Studio. Also adopted by FreeBSD as their default debugger.

LLDB - Linaro s contributions LLDB port for ARMv7 architecture. Register Context and Basic Debugging support. Support for SysV ARM/Linux ABI. Support for Arm Hardware Watchpoints Support for Arm Single Byte-Selection Watchpoints. Various bug fixes and improvements. Support for Arm Hardware Breakpoints (NEW)

LLDB - Linaro s contributions (cont ) LLDB port for ARMv8 architecture. Support for SysV AArch64/Linux ABI. Support for AArch64 Hardware Watchpoints Various bug fixes and improvements. Support for AArch64 Hardware Breakpoints (NEW) Maintenance and Testing Buildbot development and maintenance Tester bring up and validation Buildbot Failure Triage

LLDB - Features Status ARM/AArch64 LLDB features stable on ARM and AArch64 For more details visit: http://lldb.llvm.org/status.html Process control -- attach -- continue -- exec -- fork -- launch -- status Thread Control -- step-in -- step-out -- step-over -- inspection -- Breakpoints -- HW Breakpoints -- HW Watchpoints -- DWARF Symbols -- ELF Obj File -- C++11 Support -- Backtracing -- Register Inspection -- Memory Inspection -- Expression Evaluation -- JIT Expressions -- Disassembly -- Remote Debugging ARM OK OK OK OK AArch64 OK OK OK OK

LLDB - Arm/AArch64 Test Devices Buildbots contributed by google test various Android devices Link: lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-android Linaro keeps track of LLDB on Linux platform for ARM and AArch64 targets. Buildbot is still not public but we plan to do so. Platform/Architecture ARMv7 ARMv8 - AArch64 ARMv8 - AArch32 Android M Nexus 5 Nexus 5x Nexus 5x Ubuntu Linux - Xenial Raspberry Pi2 Pine64 Pine64

LLDB Architecture LLDB Command line LLDB-MI Driver IDEs (e.g, Xcode ) LLDB Python Module LLDB Debugger API LLDB SERVER Remote Platform System APIs Native Target Native Process Native Thread Register Context Debug APIs Host Abstraction Layer Platform Linux, Android, MacOSX,NetBSD, Windows, etc... G D B R S P Utility Classes Commands Data Formatters Expressions Parser - Clang, Go Expressions Target Interpreter Unwinder Core Breakpoints Instruction Emulation ABI - SysV and MacOSX (Arm, AArch64, i386, etc...) Process Thread Registers Run-Control Disassembler - LLVM Memory Stack Frame Symbols - DWARF, PDB Breakpoints Variables Dynamic Loader Object File- ELF, JIT, MACH-O, PECOFF

LLDB Debugger API LLDB Command line LLDB-MI Driver IDEs (e.g, Xcode ) LLDB Python Module LLDB Debugger API A C++ shared library with object-oriented interface. LLDB.framework on MacOS X and lldb.so on linux. Used by lldb - The LLDB Debugger command line lldb-mi and lldbmi2 - Machine Interface (MI) drivers XCode and Android Studio - IDEs with graphical front-ends. lldb Python module - LLDB API exposed through python script bindings using SWIG.

lldb-server - Platform Mode File transfer to remote target. Spawns gdbserver on target. Runs shell commands on target. List remote processes. Allows single or multiple parallel debug sessions. LLDB SERVER Remote Platform System APIs Native Target Native Process Native Thread Register Context Debug APIs Platform Linux, Android, MacOSX,NetBSD, Windows, etc... G D B R S P Target Process Thread Registers Run-Control Memory Stack Frame Breakpoints Variables

lldb-server - Platform Mode (Single Session) Spawn lldb-server on remote-android target in platform mode for single session. Select remote-android platform and connect. Try connecting another lldb remote-android platform session.

lldb-server - Platform Mode (Multiple Sessions) Select remote-android platform and connect. Connect another remote-android platform session. lldb-server platform -- server mode lldb-server multiple sessions connected

lldb-server - GDB Server Mode Run as a gdb-remote-stub. Communicates with LLDB over RSP protocol. On Mac OSX and ios, the remote-gdb functionality is in debugserver binary. LLDB SERVER Remote Platform System APIs Native Target Native Process Native Thread Register Context Debug APIs Platform Linux, Android, MacOSX,NetBSD, Windows, etc... G D B R S P Target Process Thread Registers Run-Control Memory Stack Frame Breakpoints Variables

lldb-server - GDB Server Mode Start lldb-server in gdbserver mode Connect to gdb remote stub and start a debugging session

lldb - Debuggee (or inferior) context on host system Platform Process GDB Remote Client Local or remote platform functions. Let lldb host talks to lldb-server running in gdb remote mode. Performs debug operations via GDB Remote Serial Protocol (RSP) Implements debugee (inferior) management functions like Remote Platform System APIs Native Target Target LLDB SERVER Process Control Thread Control Registers and Memory Stack Frames and Variables Breakpoints and Watchpoints Module loading Native Process Native Thread Register Context Debug APIs Platform Linux, Android, MacOSX,NetBSD, Windows, etc... G D B R S P Target Process Thread Registers Run-Control Memory Stack Frame Breakpoints Variables

lldb - target create and process launch # Select target platform platform select <name> # Connect to platform platform connect <url> # Load file and symbols target create <file-name> # Set breakpoint at main breakpoint set -b main # Start remote inferior process launch

lldb - Target and Process commands Target Create / Delete List and Select Symbols Variables Process Connect - to remote debug. Launch - current target executable Attach/Detach - to a process Continue/Interrupt/Kill - current target process. Load/Unload - shared library

lldb - Thread, Frame, Memory & Registers commands Thread Stepping Frame, Memory and Registers Step-in, step-out and step-over step-inst and step-inst-over Select - Select current thread. Backtrace - Thread call stacks. Continue - Continue one or all threads. info/list - Information about threads in current process. Frame Memory Variable Select Read Write Registers register read <reg-name> register write <reg-name> <data>

lldb - Break/Watchpoints & Disassembly commands breakpoint/watchpoint set <options> All or specified breakpoint. read/write Read from or write breakpoints to file. (-f) --frame around the current pc. (-a) --address <address> entire contents of the given function. (-p) --pc mixed source and assembly display. (-n) --name <function-name> from the start of the current frame (-m) --mixed All or specified breakpoint is deleted. enable/disable Run command or script when breakpoint is hit. delete Set a breakpoint based on options. clear <line-no or filename> command <add, delete or list> disassemble function containing address. --start-address / --end-address

lldb - command alias <alias> <command> <args> Some Built-in Aliases File <file> - target create <file> b main - breakpoint set -b main run - process launch

lldb - Using.lldbinit file.lldbinit file on top right of this slide is running at startup: Platform select and connect Load object file and symbols Set breakpoint at main Start inferior process Run to main. Spawn lldb with.lldbinit file in your home directory. Sample output with.lldbinit file on left. LLDB command-line output on bottom right shows lldb state after we start it with.lldbinit file in user s home directory.

LLDB - Brief description of components ABI Unwinder Implements stack unwinding features. Instruction Emulation Executes JITTed function calls in process being debugged. Call frame calculation based on target calling convention. Helps with stack frame constructions. Helps single step by emulating execution paths. Host Abstraction Layer Utility Classes Commands Data Formatters Expressions Parser - Clang, Go Expressions Unwinder Interpreter Core Breakpoints ABI - SysV and MacOSX (Arm, AArch64, i386, etc...) Disassembler - LLVM Instruction Emulation Symbols - DWARF, PDB Dynamic Loader Object File- ELF, JIT, MACH-O, PECOFF Expression Parser A modified DWARF expression parser Clang front-end latest c++ support

LLDB - Brief description of components Disassembler Dynamic Loader Handles object files management. Symbols Helps detect dynamically loaded modules Object File LLVM disassembler Handles debug symbols mangement Host Abstraction Layer Core and Utility Classes Interpreter and Commands Data Formatters Breakpoint Utilities Host Abstraction Layer Utility Classes Commands Data Formatters Expressions Parser - Clang, Go Expressions Unwinder Interpreter Core Breakpoints ABI - SysV and MacOSX (Arm, AArch64, i386, etc...) Disassembler - LLVM Instruction Emulation Symbols - DWARF, PDB Dynamic Loader Object File- ELF, JIT, MACH-O, PECOFF

LLDB - unique_ptr variables with data formatters Without deleter frame variable nup frame variable iup frame variable sup With deleter frame variable ndp frame variable idp frame variable sdp

LLDB - shared_ptr & weak_ptr with data formatters --ptr-depth 1 Dereference pointer once std::shared_ptr frame variable nsp frame variable isp frame variable ssp std::weak_ptr frame variable nwp frame variable iwp frame variable swp

LLDB - std::map variables with data formatters std::map<std::string, int> frame variable si std::map<int, std::string> frame variable is std::map<std::string, std::string> frame variable ss

LLDB - Evaluate expressions using clang parser Compile hello world code Launch it using LLDB. Stop in main before return. Now our expressions will have a context to work with. Let's try some example expressions.

LLDB - Evaluate expressions using clang parser Let's try evaluating a few simple expressions. Create integer type local variables i and j Let see if we can call getpid Evaluate getpid() + i + j Evaluate getpid() + i & j Evaluate getpid() + i ^ j Evaluate getpid() + i << j

LLDB - Evaluate expressions using clang parser Create context as we did in previous slide. Try evaluating a for loop expression.

LLDB - Evaluate expressions using clang parser Create a c++ lambda expression named add. Specify return value auto Evaluate lambda expression on our dummy context. Cool we have them working. Lets try a more complex lambda with auto arguments

Conclusion Start using LLDB. Its more stable than ever before. Wanna go an extra mile? Feel free to contribute. Topics for future ENGINEERS AND DEVICES WORKING TOGETHER Using LLDB Python API and built-in Python interpreter How-To on more advanced expressions How to use more advanced and Python based data formatters

Questions Email: omair.javaid@linaro.org IRC: omjavaid @ freenode and oftc ENGINEERS AND DEVICES WORKING TOGETHER

References LLDB (Architecture, GDB to LLDB commands, Doxygen) LLVM LAB - LLDB Android Buildbot Linaro LAB - LLDB Linux Buildbot (Under Development) LLDB on FreeBSD

Thank You #BUD17 For further information: www.linaro.org BUD17 keynotes and videos on: connect.linaro.org