Search code examples
intelsimics

Recompiling the Basic Extension (e.g., instrumentation-tracer-tool) from Source Code in Intel Simics


I want to re-compile the basic extension (e.g., instrumentation-tracer-tool) from its source code in Simics 6.0.185. After installing with ispm packages, I can see a Makefile in the instrumentation-tracer-tool directory that references $(MODULE_MAKEFILE). However, I’m unsure how to use it properly because there is no standalone packageinfo for it, and it’s part of the larger Simics-Base package. Simply re-running create-modcache or create-package after changing the source code does not seem to update instrumentation-tracer-tool.so.

My environment: Ubuntu 20.04, Intel I9-12900K.

~/intel-simics-package-manager-1.8.3$  ./ispm packages --install-bundle ../simics-6-packages-2024-05-linux64.ispm --install-dir /home/noyce20/8tb_ssd/intel-simics-package-manager-1.8.3/ --non-interactive --trust-unsigned-packages --trust-insecure-packages   

This creates the following directory structure:

~/intel-simics-package-manager-1.8.3/simics-6.0.185 **<dir structures (simplified)>**
.
├── bin
│   ├── create-modcache         #modcache generator
│   ├── create-packages       #ispm generator
│   ├── simics    #simics binary
...
├── cmake
├── config
├── linux64
│   ├── bin
│   ├── lib
│   │   ├── instrumentation-tracer-tool.so   #**Compiled inst.-tracer-tool.**
...
├── packageinfo     #consumed by ./bin/create-modcache or create-package
│   └── Simics-Base-linux64    #base package includes 'inst.-tracer-tool'
...
├── src
│   ├── extensions
│   │   ├── instrumentation-tracer-tool  #**source code of 'inst. tracer tool'**
│   │   │   ├── instrumentation-tracer-tool.c
│   │   │   ├── instrumentation-tracer-tool.h
│   │   │   ├── Makefile
│   │   │   ├── connection.c  # I slightly changed the print format (only a few character changes) in connection.c
...
│   │   │   ├── connection.h
│   │   │   ├── simics_start.py
│   │   │   ├── module_load.py

cat ~/intel-simics-package-manager-1.8.3/simics-6.0.185/src/extensions/instrumentation-tracer-tool/Makefile

# -*- Makefile -*-

# © 2016 Intel Corporation
#
# This software and the related documents are Intel copyrighted materials, and
# your use of them is governed by the express license under which they were
# provided to you ("License"). Unless the License provides otherwise, you may
# not use, modify, copy, publish, distribute, disclose or transmit this software
# or the related documents without Intel's prior written permission.
#
# This software and the related documents are provided as is, with no express or
# implied warranties, other than those that are expressly stated in the License.

# Simics module makefile

PYTHON_FILES = module_load.py simics_start.py

MODULE_CLASSES = tracer_tool tracer_tool_connection
SRC_FILES += instrumentation-tracer-tool.c connection.c

SIMICS_API := latest
THREAD_SAFE = yes

include $(MODULE_MAKEFILE)

I dont know how to use this makefile...


I don’t know how to use this makefile, especially the MODULE_MAKEFILE. also according to simics documents, it seems it is encourage to use bin/create-modcache or bin/create-package. Because ‘instrumentation-tracer-tool’ is a submodule of the basic tool (Simics-Base-linux64), it doesn’t have a separate packageinfo file…

Furthermore, running create-modcache/create-package for this Simics-Base-linux tool after updating the source code of ‘instrumentation-tracer-tool’ doesn’t trigger an update of linux64/lib/instrumentation-tracer-tool.so.


So for the second trial, I manually compiled the instrumentation-tracer-tool.so and copied it to linux64/lib: :

~/intel-simics-package-manager-1.8.3/simics-6.0.185/src/extensions/instrumentation-tracer-tool$  gcc -shared -fPIC instrumentation-tracer-tool.c connection.c    -o instrumentation-tracer-tool.so    -I/home/my_name/intel-simics-package-manager-1.8.3/simics-6.0.185/src/include    -L/home/my_name/intel-simics-package-manager-1.8.3/simics-6.0.185/linux64/bin    -lsimics-common -lvtutils    -Wl,-z,now

However, after this, Simics displays the following error:

~/intel-simics-package-manager-1.8.3/simics-6.0.185$ ./bin/simics
Intel Simics 6 (build 6275 linux64) © 2025 Intel Corporation

Use of this software is subject to appropriate license.
Type 'copyright' for details on copyright and 'help' for on-line documentation.

simics> load-module instrumentation-tracer-tool
Unexpected error when loading module 'instrumentation-tracer-tool'

I want to re-compile the basic extension (e.g., instrumentation-tracer-tool) from its source code in Simics 6.0.185.

Question:
What is the proper way to re-compile an extension instrumentation-tracer-tool within the Simics environment so that Simics recognizes and loads the updated .so without error?


Solution

  • Here is a session that demonstrates how to create an own version of instrumentation-tracer-tool:

    $ .../INSTALL_DIR/simics-6.0.183/bin/project-setup ~/simics_project_dir  # create a project directory in ~/simics_project_dir (Simics simulator uses project directories)
    Project created successfully
    $ cd ~/simics_project_dir/  # go to the created project directory
    $ bin/project-setup --copy-device instrumentation-tracer-tool  # copy instrumentation-tracer-tool's source to the project directory
    $ ls modules/instrumentation-tracer-tool/  # here are source that one can modify
    connection.c  connection.h  instrumentation-tracer-tool.c  instrumentation-tracer-tool.h  Makefile  module_load.py  simics_start.py
    $ # USER-TODO modify sources in ~/simics_project_dir/modules/instrumentation-tracer-tool
    $ make instrumentation-tracer-tool  # compile module from ~/simics_project_dir/modules/instrumentation-tracer-tool
    ...
    CCLD    instrumentation-tracer-tool.so
    $ ./simics  # run Simics (from the project directory at ~/simics_project_dir)
    Intel Simics 6 (build 6269 linux64) © 2025 Intel Corporation
    
    ...
    
    simics> load-module instrumentation-tracer-tool  # load module containing user changes
    instrumentation-tracer-tool module loaded
    simics> list-modules -l -v instrumentation-tracer-tool  # check that user module was loaded
    ┌───────────────────────────┬──────┬───────┬────┬──────┬───┬──────┬───────┬───────┬────────────────────────────────────────────────────────────────────────────┬─────────┐
    │           Name            │Status│ Build │ABI │Compat│API│Thread│ User  │Package│                                    Path                                    │Shadowing│
    │                           │      │  ID   │    │      │   │ safe │Version│       │                                                                            │         │
    ├───────────────────────────┼──────┼───────┼────┼──────┼───┼──────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────┼─────────┤
    │instrumentation-tracer-tool│Loaded│project│6269│  5000│6  │Yes   │       │       │/user/......../simics_project_dir/linux64/lib/instrumentation-tracer-tool.so│Yes      │
    └───────────────────────────┴──────┴───────┴────┴──────┴───┴──────┴───────┴───────┴────────────────────────────────────────────────────────────────────────────┴─────────┘
    simics>
    

    Good luck!