Skip to contentSkip to conversation

plugins: add a drcov plugin

PATCH Applied NDNF 3 participants 8 messages Oct 22, 2021 – Jan 19, 2022

lore
Share & tools
lore

NDNF

author
#0 lore raw

v3 cover plugins: add a drcov plugin

These patches adds the ability to generate files in drcov format. Primary goal this scripts is to have coverage
logfiles thatwork in Lighthouse.

Changelog:
v3:
* Increased speed of the plugin.
* Added documentation to the helper functions.
* Sorted qemu-plugins.symbols.

v2:
* Added path to executable binary file.
* base, end, entry have correct values now.
* Added option: "filename" for output file.
* Install an actual tracer when the TB gets executed.

---

Ivanov Arkady (3):
src/plugins: sorted list
This patch adds helper functions to the drcov plugin. contrib/plugins: add a drcov plugin

 contrib/plugins/Makefile     |    1 
 contrib/plugins/drcov.c      |  152 ++++++++++++++++++++++++++++++++++++++++++
 include/qemu/qemu-plugin.h   |   17 +++++
 plugins/api.c                |   44 ++++++++++++
 plugins/qemu-plugins.symbols |   56 ++++++++-------
 5 files changed, 244 insertions(+), 26 deletions(-)
 create mode 100644 contrib/plugins/drcov.c

--
Ivanov Arkady

author
#1 lore raw

PATCH v3 1/3 src/plugins: sorted list

The list is sorted to make it easier to find missing characters

---
 plugins/qemu-plugins.symbols |   52 +++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
plugins/qemu-plugins.symbols +26 -26
index 4bdb381f48..688db92773 100644
@@ -1,40 +1,40 @@
 {
-  qemu_plugin_uninstall;
-  qemu_plugin_reset;
-  qemu_plugin_register_vcpu_init_cb;
+  qemu_plugin_get_hwaddr;
+  qemu_plugin_hwaddr_is_io;
+  qemu_plugin_hwaddr_to_raddr;
+  qemu_plugin_insn_data;
+  qemu_plugin_insn_disas;
+  qemu_plugin_insn_haddr;
+  qemu_plugin_insn_size;
+  qemu_plugin_insn_vaddr;
+  qemu_plugin_mem_is_big_endian;
+  qemu_plugin_mem_is_sign_extended;
+  qemu_plugin_mem_is_store;
+  qemu_plugin_mem_size_shift;
+  qemu_plugin_n_max_vcpus;
+  qemu_plugin_n_vcpus;
+  qemu_plugin_outs;
+  qemu_plugin_ram_addr_from_host;
+  qemu_plugin_register_atexit_cb;
+  qemu_plugin_register_flush_cb;
   qemu_plugin_register_vcpu_exit_cb;
   qemu_plugin_register_vcpu_idle_cb;
-  qemu_plugin_register_vcpu_resume_cb;
+  qemu_plugin_register_vcpu_init_cb;
   qemu_plugin_register_vcpu_insn_exec_cb;
   qemu_plugin_register_vcpu_insn_exec_inline;
   qemu_plugin_register_vcpu_mem_cb;
   qemu_plugin_register_vcpu_mem_haddr_cb;
   qemu_plugin_register_vcpu_mem_inline;
-  qemu_plugin_ram_addr_from_host;
-  qemu_plugin_register_vcpu_tb_trans_cb;
-  qemu_plugin_register_vcpu_tb_exec_cb;
-  qemu_plugin_register_vcpu_tb_exec_inline;
-  qemu_plugin_register_flush_cb;
+  qemu_plugin_register_vcpu_resume_cb;
   qemu_plugin_register_vcpu_syscall_cb;
   qemu_plugin_register_vcpu_syscall_ret_cb;
-  qemu_plugin_register_atexit_cb;
-  qemu_plugin_tb_n_insns;
+  qemu_plugin_register_vcpu_tb_exec_cb;
+  qemu_plugin_register_vcpu_tb_exec_inline;
+  qemu_plugin_register_vcpu_tb_trans_cb;
+  qemu_plugin_reset;
   qemu_plugin_tb_get_insn;
+  qemu_plugin_tb_n_insns;
   qemu_plugin_tb_vaddr;
-  qemu_plugin_insn_data;
-  qemu_plugin_insn_size;
-  qemu_plugin_insn_vaddr;
-  qemu_plugin_insn_haddr;
-  qemu_plugin_insn_disas;
-  qemu_plugin_mem_size_shift;
-  qemu_plugin_mem_is_sign_extended;
-  qemu_plugin_mem_is_big_endian;
-  qemu_plugin_mem_is_store;
-  qemu_plugin_get_hwaddr;
-  qemu_plugin_hwaddr_is_io;
-  qemu_plugin_hwaddr_to_raddr;
+  qemu_plugin_uninstall;
   qemu_plugin_vcpu_for_each;
-  qemu_plugin_n_vcpus;
-  qemu_plugin_n_max_vcpus;
-  qemu_plugin_outs;
 };
#2 lore raw

Re: [PATCH v3 1/3] src/plugins: sorted list

Quoted 6 lines · NDNF

The list is sorted to make it easier to find missing characters

---
 plugins/qemu-plugins.symbols |   52 +++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

Your baseline must be old because we already have a sorted list since:

1156a03372 (plugins: sort exported symbol list)

Signature · 1 line
Alex Bennée
author
#3 lore raw

PATCH v3 2/3 This patch adds helper functions to the drcov plugin.

In reply to NDNF

Which provide information about:
- start_code.
- end_code.
- entry.
- path to the executable binary.

---
 include/qemu/qemu-plugin.h   |   17 ++++++++++++++++
 plugins/api.c                |   44 ++++++++++++++++++++++++++++++++++++++++++
 plugins/qemu-plugins.symbols |    4 ++++
 3 files changed, 65 insertions(+)
include/qemu/qemu-plugin.h +17 -0
index 5775e82c4e..68af67acf2 100644
@@ -405,4 +405,21 @@ int qemu_plugin_n_max_vcpus(void);
  */
 void qemu_plugin_outs(const char *string);
 
+/**
+ * qemu_plugin_path_to_binary() - returns path to binary file being executed
+ */
+QEMU_PLUGIN_EXPORT const char *qemu_plugin_path_to_binary(void);
+/**
+ * qemu_plugin_start_code() - returns start of text segment
+ */
+QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_start_code(void);
+/**
+ * qemu_plugin_end_code() - returns end of text segment
+ */
+QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_end_code(void);
+/**
+ * qemu_plugin_entry_code() - returns start address for module
+ */
+QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_entry_code(void);
+
 #endif /* QEMU_PLUGIN_API_H */
plugins/api.c +44 -0

53 lines not on this page · raw message

plugins/qemu-plugins.symbols +4 -0
index 688db92773..d956888f67 100644
@@ -1,4 +1,6 @@
 {
+  qemu_plugin_end_code;
+  qemu_plugin_entry_code;
   qemu_plugin_get_hwaddr;
   qemu_plugin_hwaddr_is_io;
   qemu_plugin_hwaddr_to_raddr;
@@ -14,6 +16,7 @@
   qemu_plugin_n_max_vcpus;
   qemu_plugin_n_vcpus;
   qemu_plugin_outs;
+  qemu_plugin_path_to_binary;
   qemu_plugin_ram_addr_from_host;
   qemu_plugin_register_atexit_cb;
   qemu_plugin_register_flush_cb;
@@ -32,6 +35,7 @@
   qemu_plugin_register_vcpu_tb_exec_inline;
   qemu_plugin_register_vcpu_tb_trans_cb;
   qemu_plugin_reset;
+  qemu_plugin_start_code;
   qemu_plugin_tb_get_insn;
   qemu_plugin_tb_n_insns;
   qemu_plugin_tb_vaddr;
author
#4 lore raw

PATCH v3 3/3 contrib/plugins: add a drcov plugin

In reply to NDNF

This patch adds the ability to generate files in drcov format. Primary goal this script is to have coverage logfiles thatwork in Lighthouse.

---
 contrib/plugins/Makefile |    1 
 contrib/plugins/drcov.c  |  152 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 contrib/plugins/drcov.c
contrib/plugins/Makefile +1 -0
index 7801b08b0d..0a681efeec 100644
@@ -17,6 +17,7 @@ NAMES += hotblocks
 NAMES += hotpages
 NAMES += howvec
 NAMES += lockstep
+NAMES += drcov
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
contrib/plugins/drcov.c new file +152 -0

152 lines not on this page · raw message

Applied
#5 lore raw
In reply to NDNF
Quoted 3 lines · NDNF

These patches adds the ability to generate files in drcov format. Primary goal this scripts is to have coverage
logfiles thatwork in Lighthouse.

Queued with some fixes to plugins/next, thanks.

Signature · 1 line
Alex Bennée
#6 lore raw
Quoted 9 lines · Alex Bennée
Quoted 3 lines · NDNF

These patches adds the ability to generate files in drcov format. Primary goal this scripts is to have coverage
logfiles thatwork in Lighthouse.

Queued with some fixes to plugins/next, thanks.

ping

#7 lore raw
Quoted 10 lines · Pavel Dovgalyuk
Quoted 7 lines · Alex Bennée
Quoted 3 lines · NDNF

These patches adds the ability to generate files in drcov format. Primary goal this scripts is to have coverage
logfiles thatwork in Lighthouse.

Queued with some fixes to plugins/next, thanks.

ping

I would still like to find a decent way of testing these coverage files. I looked at a number of FLOSS tools and I think radare2 can handle the drcov format but I couldn't get anything out of it.

I'll be posting the state of my plugins/next tree soon and we can get some final reviews before submitting the PR.

Signature · 1 line
Alex Bennée