Skip to contentSkip to conversation

scripts/decode_stacktrace.sh: remove trailing space

PATCH Superseded Breno Leitao 4 participants 6 messages Oct 3, 2024 – Oct 10, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/decode_stacktrace.sh: remove trailing space

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---
 scripts/decode_stacktrace.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +6 -1
index 826836d264c6..4b3502a007fd 100755
@@ -311,7 +311,12 @@ handle_line() {
 	parse_symbol # modifies $symbol
 
 	# Add up the line number to the symbol
-	echo "${words[@]}" "$symbol $module"
+	if [ -z ${module} ]
+	then
+		echo "${words[@]}" "$symbol"
+	else
+		echo "${words[@]}" "$symbol $module"
+	fi
 }
 
 while read line; do
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw

Quoting Breno Leitao (2024-10-03 03:30:05)

Quoted 9 lines

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---

Reviewed-by on v1 1/1
#2 lore raw
In reply to Breno Leitao
Quoted 17 lines · Breno Leitao

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---
 scripts/decode_stacktrace.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +0 -0
index 826836d264c6..4b3502a007fd 100755

scripts/decode_stacktrace.sh handle_line() { · line 315

Quoted 6 lines
scripts/decode_stacktrace.sh +2 -1
@@ -311,7 +311,12 @@ handle_line() {
 	parse_symbol # modifies $symbol
 
 	# Add up the line number to the symbol
-	echo "${words[@]}" "$symbol $module"
+	if [ -z ${module} ]
+	then

nit: it seems the convention would have been something like:

	if [[ -z $module ]]; then

scripts/decode_stacktrace.sh handle_line() { · line 318

Quoted 3 lines
scripts/decode_stacktrace.sh +3 -0
+		echo "${words[@]}" "$symbol"
+	else
+		echo "${words[@]}" "$symbol $module"

I guess the space could have also been prepended in module above? e.g
module=" $module"

Quoted 7 lines
scripts/decode_stacktrace.sh +1 -0
+	fi
 }
 
 while read line; do
Signature · 1 line
2.43.5

...either way this looks good to me.

#3 lore raw

Hello Carlos,

Quoted 20 lines · Carlos Llamas
Quoted 19 lines · Breno Leitao

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---
 scripts/decode_stacktrace.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +0 -0
index 826836d264c6..4b3502a007fd 100755
@@ -311,7 +311,12 @@ handle_line() {
 	parse_symbol # modifies $symbol
 
Quoted 7 lines

scripts/decode_stacktrace.sh handle_line() { · line 315

Quoted 4 lines
scripts/decode_stacktrace.sh +2 -1
 	# Add up the line number to the symbol
-	echo "${words[@]}" "$symbol $module"
+	if [ -z ${module} ]
+	then

nit: it seems the convention would have been something like:

	if [[ -z $module ]]; then

That is how I wrote originally, in fact, but, the rest of the code is using the other way. Example:

        if [ -z $release ] ; then
                release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')
        fi
        if [ -n "${release}" ] ; then
                release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release"
        fi

Thanks for the review,
Breno

#4 lore raw
Quoted 31 lines · Breno Leitao

Hello Carlos,

Quoted 20 lines · Carlos Llamas
Quoted 19 lines · Breno Leitao

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---
 scripts/decode_stacktrace.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +0 -0
index 826836d264c6..4b3502a007fd 100755
@@ -311,7 +311,12 @@ handle_line() {
 	parse_symbol # modifies $symbol
 
Quoted 7 lines

scripts/decode_stacktrace.sh handle_line() { · line 315

Quoted 4 lines
scripts/decode_stacktrace.sh +2 -1
 	# Add up the line number to the symbol
-	echo "${words[@]}" "$symbol $module"
+	if [ -z ${module} ]
+	then

nit: it seems the convention would have been something like:

	if [[ -z $module ]]; then
Quoted 4 lines

That is how I wrote originally, in fact, but, the rest of the code is using the other way. Example:

if [ -z $release ] ; then

This is actually problematic if $release can have any spaces but I suspect it's not possible here. I'd still either quote "$release" or use double brackets e.g. [[ -z $release ]] to be safe.

BTW, I assume $module can't have any spaces either?

Quoted 3 lines
                release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')
        fi
        if [ -n "${release}" ] ; then

Yeah, there is no need for the curly braces here, they are not doing anything.

Quoted 5 lines

release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release"
fi

Thanks for the review,
Breno

Note that I was initally referring to the 'then' being on a new line but these are all minor nits.

Cheers,
Carlos Llamas

Reviewed-by on v1 1/1
#5 lore raw
In reply to Breno Leitao
Quoted 17 lines · Breno Leitao

decode_stacktrace.sh adds a trailing space at the end of the decoded stack if the module is not set (in most of the lines), which makes the some lines of the stack having trailing space and some others not.

Do not add an extra space at the end of the line if module is not set, adding consistency in output formatting.

---
 scripts/decode_stacktrace.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +0 -0
index 826836d264c6..4b3502a007fd 100755

scripts/decode_stacktrace.sh handle_line() { · line 314

Quoted 5 lines
scripts/decode_stacktrace.sh +1 -1
@@ -311,7 +311,12 @@ handle_line() {
 	parse_symbol # modifies $symbol
 
 	# Add up the line number to the symbol
-	echo "${words[@]}" "$symbol $module"
+	if [ -z ${module} ]

After adding the quoting as mentioned by Carlos,

Quoted 11 lines
scripts/decode_stacktrace.sh +5 -0
+	then
+		echo "${words[@]}" "$symbol"
+	else
+		echo "${words[@]}" "$symbol $module"
+	fi
 }
 
 while read line; do
Signature · 1 line
2.43.5