Development Toolchain

Introduction

The development toolchain subsystem provides debugging commands and tools for performance monitoring and tracing.

This subsystem provides the following tools:

  • bytrace: a tool for you to trace processes and monitor performance. It encapsulates and extends the ftrace inside the kernel and supports tracing in the user space.
  • hdc: a command line tool for debugging. With hdc, you can interact with real devices or simulators from Windows, Linux, or macOS.
  • profiler: a performance profiling platform for you to analyze memory and performance issues.

Architecture

The figure below shows the architecture of the development toolchain subsystem.

Figure 1 Architecture of the development toolchain subsystem

Directory Structure

/developtools             # Development toolchain subsystem
├── bytrace_standard      # bytrace code
│   └── bin               # bytrace function implementation
│   └── innerkits         # Header files for internal subsystems
├── hdc_standard          # hdc code
│   └── src               # hdc function implementation
│   └── prebuilt          # Prebuilt code
├── profiler              # Profiler code
│   └── device            # Device code
│   └── host              # Host code
│   └── interfaces        # APIs between modules and external APIs
│   └── trace_analyzer    # bytrace analyzer code
│   └── protos            # proto files

Usage

bytrace

The table below lists the commands supported by bytrace.

Table 1 Commands supported by bytrace

Option

Description

-h, --help

Displays help information.

-b n, --buffer_size n

Sets n KB of memory for storing trace logs. The default value is 2 MB.

-t n, --time n

Sets the trace uptime, in seconds. The value varies depending on the time required for analysis.

--trace_clock clock

Sets the type of the clock for adding a timestamp to a trace. The value can be boot (default), global, mono, uptime, or perf.

--trace_begin

Starts trace.

--trace_dump

Dumps traced data to a specified position (console by default).

--trace_finish

Stops trace and outputs data to the specified position (console by default).

-l, --list_categories

Lists the bytrace categories supported by the device.

--overwrite

Overwrites the latest information when the buffer is full. By default, the earliest data is overwritten.

-o filename, --output filename

Outputs traced data to a specified file.

-z

Compresses the traced data.

Examples:

  • Query supported labels.

    bytrace -l 
    Or
    bytrace --list_categories
    
  • Trace ability information for 10 seconds and store the traced data in a buffer of 4 MB.

    bytrace -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
    
  • Set the clock type for traces to mono.

    bytrace --trace_clock mono  -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
    
  • Compress the traced data.

    bytrace -z  -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
    

hdc

The table below lists the commands supported by hdc.

Table 2 Commands supported by hdc

The

Option

Description

-t key

Specifies the identifier of the device to connect.

-s socket

Specifies the listening socket.

-h/help -v/version

Displays the hdc help and version information.

list targets[-v]

Displays all connected devices.

target mount

Mounts the system partition in read/write mode.

target boot [bootloader|recovery]

Restarts a target device. The system is started by default. The bootloader and recover modes are supported.

smode [off]

Grants the root permission to the background hdc service. You can use the off option to revoke the granted permissions.

kill

Terminates the hdc service.

tconn host[:port][-remove]

Connects to the device with the specified IP address and port number.

tmode usb

Restarts the daemon process of the device and connects to the device through USB preferentially.

tmode port port-number

Restarts the daemon process of the device and connects to the device over TCP preferentially. If the TCP connection fails, try a USB connection.

fport local remote -b

Adds a port relay connection.

fport list

Lists all relay connections.

fport rm local

Deletes the relayed local connection. If no parameter is specified, all connections will be deleted.

file send local remote

Sends a file to a remote device.

file recv [-a] remote local

Sends a file from a remote device to the local device.

app install [-r/-d/-g] package

Installs an OpenHarmony app.

app install-multiple [-rdg] --hap path

Installs all OpenHarmony apps in the specified directory.

app uninstall [-k] package

Uninstalls the specified OpenHarmony app.

hilog

Obtains log information.

bugreport [PATH]

Captures bug report information.

shell [command]

Runs a command remotely or enters the interactive command environment.

Examples:

  • Send a file to a remote device.

    hdc file send  E:\c.txt  /sdcard
    
  • Restart a device.

    hdc target boot
    
  • Obtain log information.

    hdc hilog
    
  • Enter the interactive command mode:

    hdc shell
    
  • Set the listening socket.

    hdc -s 192.168.1.100:1234 
    
  • Restart the device in bootloader mode.

    hdc target boot bootloader
    
  • Connect to the device with a specified IP address and port number.

    hdc tconn 192.168.0.100:8710
    

profiler

The profiler module consists of the system and application profiler frameworks. It provides a performance profiler platform for you to analyze system issues related to the memory and performance.

The profiler module provides the following capabilities:

  • Capabilities for the PC: The capabilities are released as a DevEco Studio plug-in, which contains UI drawing, device management, process management, plug-in management, data import, data storage, data analysis, session management, and configuration management.
  • Capabilities for the device: The capabilities include the command line tool, service processes, plug-ins, and application components. The device-side profiler provides APIs for extending plug-ins. With these APIs, you can define capabilities and integrate them into the framework. Currently, the real-time memory analysis and trace plug-ins are available. For details, see the profiler readme.

Repositories Involved

Development Toolchain Subsystem

developtools_hdc_standard

developtools_bytrace_standard

developtools_profiler