Skip to content

Commit fd59589

Browse files
committed
deploy: 1eee597
1 parent 068d493 commit fd59589

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4211
-397
lines changed
Binary file not shown.

.doctrees/environment.pickle

39.2 KB
Binary file not shown.
903 KB
Loading
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
tags: c, dependency, objects, nm, clanguru, cytoscape
3+
category: learning
4+
date: 2025-09-26
5+
title: What you did not want to know about your code
6+
---
7+
8+
# What you did not want to know about your code
9+
10+
As any other engineer, I also like to hack around in the weekends at six o’clock in the morning when the family is still asleep.
11+
This time I wanted to play around with the new Matter smart home connectivity standard and add some temperature and humidity sensors to my smart home setup.
12+
13+
I bought some `esp32-h2` development boards (they support WiFi, Thread and BLE), some `SHT31-D` sensors and started the old fashioned read the docs to get started to get started.
14+
I must say the [espressif docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) are well written and the community is very active.
15+
16+
I am using a WSL Ubuntu on Windows 11 and getting the build environment to work was not as straightforward as I hoped:
17+
18+
- the `idf.py` build system comes in a separate repository and needs to be set up to work
19+
- the esp-matter repo is huge and takes a while to clone
20+
- getting the esp32 device visible as `/dev/ttyUSB0` was tricky
21+
22+
After a while I got the first example compiled and flashed to the device.
23+
24+
What I have noticed though was that the resulting binary was quite large (over 1.5MB) and I wondered what is actually in there.
25+
26+
Instead of just looking at the final binary and the object files, I thought it would be more interesting to see it as a dependency graph between the object files.
27+
For this I added a new command in a Python app I use to parse and analyze C/C++ sources, called [clanguru](https://github.com/cuinixam/clanguru).
28+
29+
The new `analyze` command does the following:
30+
31+
* parse the `compile_commands.json` file to find all the object files
32+
* run `nm` on each object file to get the global symbols and determine their type:
33+
* `extern` for undefined globals - these are the `required` symbols
34+
* `local` for local globals - these are the `provided` symbols
35+
* create an html report using [cytoscape.js](https://cytoscape.org/) to visualize the dependencies between the object files.
36+
I also added an option to group the object files in named containers based on their path.
37+
38+
The result is a nice interactive graph where you can zoom in and out, drag the nodes around and enjoy the complexity of the code base.
39+
40+
For my project it looks like this:
41+
42+
![dependency graph](images/objects_dependencies_graph.png)
43+
44+
You can find the actual report [here](https://maxiniuc.com/objects_deps/index.html).
45+
46+
### Use clanguru to analyze your C/C++ code
47+
48+
Install clanguru using `pipx` for isolated installation:
49+
50+
```
51+
pipx install clanguru
52+
```
53+
54+
Check the help for the `analyze` command:
55+
56+
```
57+
clanguru analyze --help
58+
```
59+
60+
You need to build your project and provide the compilation database (`compile_commands.json`).
61+
Also, ensure that the `nm` command-line tool is available in your user PATH.
62+
63+
To generate an html dynamic dependency report, run the following command:
64+
65+
```shell
66+
clanguru analyze --compilation-database compile_commands.json --output-file dependencies.html --use-parent-deps
67+
```
68+
69+
The `--use-parent-deps` option will group the object files based on their parent directory.
70+
71+
If the output file extension is `.xlsx`, an Excel report will be generated instead of an HTML one.
72+
73+
If you have any questions or feedback, feel free to create an issue in the clanguru GitHub repository.
74+
75+
Have fun exploring your code dependencies! 😎

about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5858
<meta name="docsearch:language" content="en"/>
5959
<meta name="docsearch:version" content="" />
60-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
60+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
6161
<link
6262
rel="alternate"
6363
type="application/atom+xml"

blogs.html

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5757
<meta name="docsearch:language" content="en"/>
5858
<meta name="docsearch:version" content="" />
59-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
59+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
6060
<link
6161
rel="alternate"
6262
type="application/atom+xml"
@@ -387,7 +387,7 @@ <h3>
387387
</li>
388388

389389
<li>
390-
<a href="blogs/category/learning.html">learning (5)</a>
390+
<a href="blogs/category/learning.html">learning (6)</a>
391391
</li>
392392

393393
</ul>
@@ -411,10 +411,14 @@ <h3><a href="blogs/tag.html">Tags</a></h3>
411411
<a href="blogs/tag/build.html">build</a>
412412
</li>
413413

414-
<li class="ablog-cloud ablog-cloud-1">
414+
<li class="ablog-cloud ablog-cloud-5">
415415
<a href="blogs/tag/c.html">c</a>
416416
</li>
417417

418+
<li class="ablog-cloud ablog-cloud-1">
419+
<a href="blogs/tag/clanguru.html">clanguru</a>
420+
</li>
421+
418422
<li class="ablog-cloud ablog-cloud-1">
419423
<a href="blogs/tag/cmake.html">cmake</a>
420424
</li>
@@ -428,6 +432,10 @@ <h3><a href="blogs/tag.html">Tags</a></h3>
428432
</li>
429433

430434
<li class="ablog-cloud ablog-cloud-1">
435+
<a href="blogs/tag/cytoscape.html">cytoscape</a>
436+
</li>
437+
438+
<li class="ablog-cloud ablog-cloud-5">
431439
<a href="blogs/tag/dependency.html">dependency</a>
432440
</li>
433441

@@ -467,6 +475,14 @@ <h3><a href="blogs/tag.html">Tags</a></h3>
467475
<a href="blogs/tag/memory.html">memory</a>
468476
</li>
469477

478+
<li class="ablog-cloud ablog-cloud-1">
479+
<a href="blogs/tag/nm.html">nm</a>
480+
</li>
481+
482+
<li class="ablog-cloud ablog-cloud-1">
483+
<a href="blogs/tag/objects.html">objects</a>
484+
</li>
485+
470486
<li class="ablog-cloud ablog-cloud-1">
471487
<a href="blogs/tag/optimization.html">optimization</a>
472488
</li>
@@ -542,7 +558,7 @@ <h3>
542558
<ul>
543559

544560
<li>
545-
<a href="blogs/2025.html">2025 (4)</a>
561+
<a href="blogs/2025.html">2025 (5)</a>
546562
</li>
547563

548564
<li>
@@ -614,6 +630,66 @@ <h1>
614630
</span>
615631
</h1>
616632

633+
<div class="section ablog-post">
634+
<h2 class="ablog-post-title">
635+
<a href="blogs/2025/what_you_did_not_want_to_know_about_your_code.html">What you did not want to know about your code</a>
636+
</h2>
637+
<ul class="ablog-archive">
638+
<li>
639+
640+
<i class="fa fa-calendar"></i>
641+
642+
<span>26 September 2025</span>
643+
644+
</li>
645+
<div class="ablog-sidebar-item ablog__postcard2">
646+
647+
<li id="ablog-sidebar-item category ablog__category">
648+
<span>
649+
650+
<i class="fa-fw fa fa-folder-open"></i>
651+
652+
</span>
653+
654+
<a href="blogs/category/learning.html">learning</a>
655+
656+
</li>
657+
658+
<li id="ablog-sidebar-item tags ablog__tags">
659+
<span>
660+
661+
<i class="fa-fw fa fa-tags"></i>
662+
663+
</span>
664+
665+
<a href="blogs/tag/c.html">c</a>
666+
667+
<a href="blogs/tag/dependency.html">dependency</a>
668+
669+
<a href="blogs/tag/objects.html">objects</a>
670+
671+
<a href="blogs/tag/nm.html">nm</a>
672+
673+
<a href="blogs/tag/clanguru.html">clanguru</a>
674+
675+
<a href="blogs/tag/cytoscape.html">cytoscape</a>
676+
677+
</li>
678+
679+
</div>
680+
</ul>
681+
<p class="ablog-post-excerpt"><p>As any other engineer, I also like to hack around in the weekends at six o’clock in the morning when the family is still asleep.
682+
This time I wanted to play around with the new Matter smart home connectivity standard and add some temperature and humidity sensors to my smart home setup.</p>
683+
<p>I bought some <code class="docutils literal notranslate"><span class="pre">esp32-h2</span></code> development boards (they support WiFi, Thread and BLE), some <code class="docutils literal notranslate"><span class="pre">SHT31-D</span></code> sensors and started the old fashioned read the docs to get started to get started.
684+
I must say the <a class="reference external" href="https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html">espressif docs</a> are well written and the community is very active.</p>
685+
<img alt="dependency graph" src="_images/objects_dependencies_graph.png" /></p>
686+
687+
<p class="ablog-post-expand">
688+
<a href="blogs/2025/what_you_did_not_want_to_know_about_your_code.html"><em>Read more ...</em></a>
689+
</p>
690+
<hr />
691+
</div>
692+
617693
<div class="section ablog-post">
618694
<h2 class="ablog-post-title">
619695
<a href="blogs/2025/c_portable_pointer_size.html">Why unit tests crashed on windows but worked on the microcontroller</a>

blogs/2024.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5757
<meta name="docsearch:language" content="en"/>
5858
<meta name="docsearch:version" content="" />
59-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
59+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
6060
<link
6161
rel="alternate"
6262
type="application/atom+xml"
@@ -380,6 +380,12 @@ <h3>
380380
</h3>
381381
<ul>
382382

383+
<li>
384+
<a href="2025/what_you_did_not_want_to_know_about_your_code.html">
385+
26 September - What you did not want to know about your code
386+
</a>
387+
</li>
388+
383389
<li>
384390
<a href="2025/c_portable_pointer_size.html">
385391
24 September - Why unit tests crashed on windows but worked on the microcontroller
@@ -404,12 +410,6 @@ <h3>
404410
</a>
405411
</li>
406412

407-
<li>
408-
<a href="2024/homelab_setup_main_machine.html">
409-
17 November - Homelab - setup main machine
410-
</a>
411-
</li>
412-
413413
</ul>
414414
</div>
415415
</div>
@@ -421,7 +421,7 @@ <h3>
421421
<ul>
422422

423423
<li>
424-
<a href="2025.html">2025 (4)</a>
424+
<a href="2025.html">2025 (5)</a>
425425
</li>
426426

427427
<li>

blogs/2024/efficiently_embedding_git_information_in_c_projects.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5858
<meta name="docsearch:language" content="en"/>
5959
<meta name="docsearch:version" content="" />
60-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
60+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
6161
<link
6262
rel="alternate"
6363
type="application/atom+xml"
@@ -424,6 +424,12 @@ <h3>
424424
</h3>
425425
<ul>
426426

427+
<li>
428+
<a href="../2025/what_you_did_not_want_to_know_about_your_code.html">
429+
26 September - What you did not want to know about your code
430+
</a>
431+
</li>
432+
427433
<li>
428434
<a href="../2025/c_portable_pointer_size.html">
429435
24 September - Why unit tests crashed on windows but worked on the microcontroller
@@ -448,12 +454,6 @@ <h3>
448454
</a>
449455
</li>
450456

451-
<li>
452-
<a href="homelab_setup_main_machine.html">
453-
17 November - Homelab - setup main machine
454-
</a>
455-
</li>
456-
457457
</ul>
458458
</div>
459459
</div>
@@ -465,7 +465,7 @@ <h3>
465465
<ul>
466466

467467
<li>
468-
<a href="../2025.html">2025 (4)</a>
468+
<a href="../2025.html">2025 (5)</a>
469469
</li>
470470

471471
<li>

blogs/2024/homelab_setup_main_machine.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5656
<meta name="docsearch:language" content="en"/>
5757
<meta name="docsearch:version" content="" />
58-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
58+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
5959
<link
6060
rel="alternate"
6161
type="application/atom+xml"
@@ -432,6 +432,12 @@ <h3>
432432
</h3>
433433
<ul>
434434

435+
<li>
436+
<a href="../2025/what_you_did_not_want_to_know_about_your_code.html">
437+
26 September - What you did not want to know about your code
438+
</a>
439+
</li>
440+
435441
<li>
436442
<a href="../2025/c_portable_pointer_size.html">
437443
24 September - Why unit tests crashed on windows but worked on the microcontroller
@@ -456,12 +462,6 @@ <h3>
456462
</a>
457463
</li>
458464

459-
<li>
460-
<a href="optimizing_tool_installation_in_spl_build_environments.html">
461-
26 October - Optimizing Tool Installation in SPL Build Environments
462-
</a>
463-
</li>
464-
465465
</ul>
466466
</div>
467467
</div>
@@ -473,7 +473,7 @@ <h3>
473473
<ul>
474474

475475
<li>
476-
<a href="../2025.html">2025 (4)</a>
476+
<a href="../2025.html">2025 (5)</a>
477477
</li>
478478

479479
<li>

blogs/2024/optimizing_tool_installation_in_spl_build_environments.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<meta name="viewport" content="width=device-width, initial-scale=1"/>
5656
<meta name="docsearch:language" content="en"/>
5757
<meta name="docsearch:version" content="" />
58-
<meta name="docbuild:last-update" content="Sep 24, 2025"/>
58+
<meta name="docbuild:last-update" content="Sep 26, 2025"/>
5959
<link
6060
rel="alternate"
6161
type="application/atom+xml"
@@ -432,6 +432,12 @@ <h3>
432432
</h3>
433433
<ul>
434434

435+
<li>
436+
<a href="../2025/what_you_did_not_want_to_know_about_your_code.html">
437+
26 September - What you did not want to know about your code
438+
</a>
439+
</li>
440+
435441
<li>
436442
<a href="../2025/c_portable_pointer_size.html">
437443
24 September - Why unit tests crashed on windows but worked on the microcontroller
@@ -456,12 +462,6 @@ <h3>
456462
</a>
457463
</li>
458464

459-
<li>
460-
<a href="homelab_setup_main_machine.html">
461-
17 November - Homelab - setup main machine
462-
</a>
463-
</li>
464-
465465
</ul>
466466
</div>
467467
</div>
@@ -473,7 +473,7 @@ <h3>
473473
<ul>
474474

475475
<li>
476-
<a href="../2025.html">2025 (4)</a>
476+
<a href="../2025.html">2025 (5)</a>
477477
</li>
478478

479479
<li>

0 commit comments

Comments
 (0)