From: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: David Gibson
<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>,
Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
Subject: Re: [PATCH 3/3 v2] annotations: add the annotation functionality
Date: Tue, 16 Jan 2018 20:13:45 -0800 [thread overview]
Message-ID: <4f3eda57-e50b-922b-0b02-d5859aedda71@gmail.com> (raw)
In-Reply-To: <20180117011322.GW30352-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
On 01/16/18 17:13, David Gibson wrote:
> On Mon, Jan 15, 2018 at 07:24:10PM +0100, Julia Lawall wrote:
>> This commit provides two new command-line options:
>>
>> --annotate (abbreviated -T)
>> --annotate-full (abbreviated -F)
>
> What's the rationale for having two different versions of the
> annotations?
I'll put an example to try to explain, at the end of this email.
>>
>> --annotate provides one or more filenames and line numbers indicating
>> the origin of a given line. The filename is expressed relative the the
>> filename provided on the command line. Nothing is printed for overlays,
>> etc.
>>
>> --annotate-full provides one or more tuples of: filename, starting line,
>> starting column, ending line ending column. The full path is given for
>> the file name. Overlays, etc are annotated with <no-file>:<no-line>.
>>
>> There are numerous changes in srcpos to provide the relative filenames
>> (variables initial_path, initial_pathlen and initial_cpp, new functions
>> set_initial_path and shorten_to_initial_path, and changes in
>> srcfile_push and srcpos_set_line). The change in srcpos_set_line takes
>> care of the case where cpp is used as a preprocessor. In that case the
>> initial file name is not the one provided on the command line but the
>> one found at the beginnning of the cpp output.
>>
>> The new functions srcpos_string_comment, srcpos_string_first, and
>> srcpos_string_last print the annotations. srcpos_string_comment is
>> recursive to print a list of source file positions.
>>
>> Note that the column numbers in the --annotate-full case may be of
>> limited use when cpp is first used, because the columns are those in the
>> output generated by cpp, which are not the same as the ones in the
>> source code. It may be that cpp simply replaces tabs by spaces.
>>
>> Various changes are sprinkled throughout treesource.c to print the
>> annotations.
>>
>> Signed-off-by: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
>> Signed-off-by: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
< snip >
For a real world Linux devicetree source file, I often use
arch/arm/boot/dts/qcom-apq8074-dragonboard.dts
In these examples, I am using the version in Linux v4.15-rc7.
My basic premise is that --annotate-full provides a lot of useful
information, but that information is usually not needed. But the
extra information makes the output very dense and much harder for
a human eye to scan or read.
In the Linux sources (an argument _against_ my case :-)), the
full path of the source files normally provides no value. Part
of this the way our source tree is structured.
I will use the Linux script scripts/dtc/dtx_diff to generate my
examples of annotated files. This script takes care of all of
the include paths, invoking cpp, and other details of the linux
use of dtc. When provided a single argument, dtx_diff simply does
the compile with '-O dts'. I have modified the normal dtx_diff
to pass on --annotate and --annotate-full to dtc.
First, I create two annotated files, one with --annotate, the other
with --annotate-full:
$ scripts/dtc/dtx_diff --annotate arch/arm/boot/dts/qcom-apq8074-dragonboard.dts >qcom-apq8074-dragonboard--annotate.dts
$ scripts/dtc/dtx_diff --annotate-full arch/arm/boot/dts/qcom-apq8074-dragonboard.dts >qcom-apq8074-dragonboard--annotate-full.dts
Then just look at the first few lines of each of the two examples:
$ head qcom-apq8074-dragonboard--annotate.dts
/dts-v1/;
/ { /* qcom-apq8074-dragonboard.dts:6, qcom-msm8974.dtsi:11, skeleton.dtsi:12 */
#address-cells = <0x1>; /* skeleton.dtsi:13 */
#size-cells = <0x1>; /* skeleton.dtsi:14 */
compatible = "qcom,apq8074-dragonboard", "qcom,apq8074"; /* qcom-apq8074-dragonboard.dts:8 */
interrupt-parent = <0x1>; /* qcom-msm8974.dtsi:14 */
model = "Qualcomm APQ8074 Dragonboard"; /* qcom-apq8074-dragonboard.dts:7 */
adsp-pil { /* qcom-msm8974.dtsi:243 */
$ head qcom-apq8074-dragonboard--annotate-full.dts
/dts-v1/;
/ { /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:6:0-346:2, arch/arm/boot/dts/qcom-msm8974.dtsi:11:0-1148:2, arch/arm/boot/dts/skeleton.dtsi:12:0-18:2 */
#address-cells = <0x1>; /* arch/arm/boot/dts/skeleton.dtsi:13:1-13:22 */
#size-cells = <0x1>; /* arch/arm/boot/dts/skeleton.dtsi:14:1-14:19 */
compatible = "qcom,apq8074-dragonboard", "qcom,apq8074"; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:8:1-8:57 */
interrupt-parent = <0x1>; /* arch/arm/boot/dts/qcom-msm8974.dtsi:14:1-14:28 */
model = "Qualcomm APQ8074 Dragonboard"; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:7:1-7:40 */
adsp-pil { /* arch/arm/boot/dts/qcom-msm8974.dtsi:243:1-262:3 */
The --annotate-full version is harder for _me_ to scan.
The --annotate-full version results in a much longer line (and this effect gets even
worse when there are nodes nested several levels).
One can make the argument that the long path is the fault of the way that
Linux is structured, and it should be my problem to resolve that. And to
a certain extent I can. I could package a simple sed command in a script.
The simplistic hard coded version of the sed command (since I know the base
path of the devicetree source file that I am compiling) is:
$ sed -e 's|arch/arm/boot/dts/||g' -e 's|:[0-9]*-[0-9]*:[0-9]*||g' -e 's| /\* <no-file>:<no-line> \*/||' qcom-apq8074-dragonboard--annotate-full.dts > qcom-apq8074-dragonboard--annotate-full--then-sed.dts
The second "-e" substitution is not needed to strip the path off, but I was
going for the full simplification. Looking at the first few lines of that
transformation, I see that it is basically the same as using --annotate.
Looking deeper into the file, which I don't show here, some of the row
numbers are different, due to my simplistic sed regular expression.
$ head qcom-apq8074-dragonboard--annotate-full--then-sed.dts
/dts-v1/;
/ { /* qcom-apq8074-dragonboard.dts:6, qcom-msm8974.dtsi:11, skeleton.dtsi:12 */
#address-cells = <0x1>; /* skeleton.dtsi:13 */
#size-cells = <0x1>; /* skeleton.dtsi:14 */
compatible = "qcom,apq8074-dragonboard", "qcom,apq8074"; /* qcom-apq8074-dragonboard.dts:8 */
interrupt-parent = <0x1>; /* qcom-msm8974.dtsi:14 */
model = "Qualcomm APQ8074 Dragonboard"; /* qcom-apq8074-dragonboard.dts:7 */
adsp-pil { /* qcom-msm8974.dtsi:243 */
So I could achieve the equivalent of --annotate by post-processing, possible
with the result of slightly different line numbers if I'm sloppy. But if
dtc can do the simplification, I don't need to add the additional external processing.
The question of whether to include just the starting line number, or the
starting line/column and ending line/column was the trade off between
more information vs less dense information being easier to scan and
read.
Having both --annotate and --annotate-full lets the user make the trade
off as needed in any particular case.
-Frank
next prev parent reply other threads:[~2018-01-17 4:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 18:24 [PATCH 0/3 v2] annotations Julia Lawall
[not found] ` <1516040650-9848-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-15 18:24 ` [PATCH 1/3 v2] annotations: check for NULL position Julia Lawall
[not found] ` <1516040650-9848-2-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17 1:10 ` David Gibson
2018-01-15 18:24 ` [PATCH 2/3 v2] annotations: add positions Julia Lawall
[not found] ` <1516040650-9848-3-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17 0:50 ` David Gibson
2018-01-15 18:24 ` [PATCH 3/3 v2] annotations: add the annotation functionality Julia Lawall
[not found] ` <1516040650-9848-4-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17 1:13 ` David Gibson
[not found] ` <20180117011322.GW30352-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2018-01-17 4:13 ` Frank Rowand [this message]
[not found] ` <4f3eda57-e50b-922b-0b02-d5859aedda71-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17 4:17 ` Frank Rowand
[not found] ` <3ba34256-9442-5177-90db-0a180728e05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17 5:50 ` Julia Lawall
2018-01-17 6:11 ` Frank Rowand
[not found] ` <5fefdac4-87f7-de50-ff39-1911337a2a2e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17 6:13 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f3eda57-e50b-922b-0b02-d5859aedda71@gmail.com \
--to=frowand.list-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=Julia.Lawall-L2FTfq7BK8M@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=frank.rowand-7U/KSKJipcs@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).