Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64
@ 2021-07-07  7:10 Mikhail Shishatskiy via Tarantool-patches
  2021-07-07 18:35 ` Igor Munkin via Tarantool-patches
  2021-07-22 13:35 ` Igor Munkin via Tarantool-patches
  0 siblings, 2 replies; 3+ messages in thread
From: Mikhail Shishatskiy via Tarantool-patches @ 2021-07-07  7:10 UTC (permalink / raw)
  To: tarantool-patches, imun, skaplun

Since commit 58790750b9c4bd4c21d883f109ab552a2e202a15 ('gdb: introduce
luajit-gdb extension') when luajit-gdb.py is introduced, Lua stack
slots printed by lj-stack command are misaligned, when LJ_GC64 is
enabled. The issue is that PADDING variable used for aligning single
slots in the output is initialized before LuaJIT build mode is
defined in <init> function, so the result was the following:

| 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
| 0x7ffff7fb0d88            [   M]
| 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
| 0x7ffff7fb0cb8            [  T ]
| ...

In scope of this patch, PADDING initialization is also moved to
<init> function right after all commands are loaded. As a result, the
output looks as expected:

| 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
| 0x7ffff7fb0d88                [   M]
| 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
| 0x7ffff7fb0cb8                [  T ]
| ...

Fixes tarantool/tarantool#5876
---

Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5876

To test changes do the following:

| $ gdb -q --args ./luajit -e 'print("QQ")'
| Reading symbols from ./luajit...
| lj-arch command initialized
| lj-tv command initialized
| lj-str command initialized
| lj-tab command initialized
| lj-stack command initialized
| lj-state command initialized
| lj-gc command initialized
| luajit-gdb.py is successfully loaded
| (gdb) lj-arch
| LJ_64: True, LJ_GC64: True
| (gdb) b lj_cf_print
| Breakpoint 1 at 0x298b0: file /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c, line 485.
| (gdb) r
| Starting program: /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/luajit -e print\(\"QQ\"\)
|
| Breakpoint 1, lj_cf_print (L=0x0)
|     at /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c:485
| 485	{
| (gdb) s
| 486	  ptrdiff_t i, nargs = L->top - L->base;
| (gdb) lj-stack L
| 0x7ffff7fa8d90:0x7ffff7fa8dc0 [    ] 7 slots: Red zone
| 0x7ffff7fa8d88                [   M]
| 0x7ffff7fa8cc0:0x7ffff7fa8d80 [    ] 25 slots: Free stack slots
| 0x7ffff7fa8cb8                [  T ]
| 0x7ffff7fa8cb0                [ B  ] VALUE: string "QQ" @ 0x7ffff7fb1178
| 0x7ffff7fa8ca0:0x7ffff7fa8ca8 [    ] FRAME: [L] delta=2, fast function #29
| 0x7ffff7fa8c90:0x7ffff7fa8c98 [    ] FRAME: [V] delta=2, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
| 0x7ffff7fa8c80:0x7ffff7fa8c88 [    ] FRAME: [CP] delta=4, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
| 0x7ffff7fa8c78                [    ] VALUE: C function @ 0x55555555c962
| 0x7ffff7fa8c70                [    ] VALUE: light userdata @ 0x0
| 0x7ffff7fa8c60:0x7ffff7fa8c68 [    ] FRAME: [CP] delta=2, C function @ 0x55555555df1c
| 0x7ffff7fa8c58:0x7ffff7fa8c60 [S   ] FRAME: dummy L


 src/luajit-gdb.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index f1fd6230..720d989a 100644
--- a/src/luajit-gdb.py
+++ b/src/luajit-gdb.py
@@ -160,7 +160,7 @@ LJ_FR2 = None
 
 LJ_GCVMASK = ((1 << 47) - 1)
 
-PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1))
+PADDING = None
 
 # }}}
 
@@ -665,7 +665,7 @@ The command requires no args and dumps current GC stats:
         ))
 
 def init(commands):
-    global LJ_64, LJ_GC64, LJ_FR2
+    global LJ_64, LJ_GC64, LJ_FR2, PADDING
 
     # XXX Fragile: though connecting the callback looks like a crap but it
     # respects both Python 2 and Python 3 (see #4828).
@@ -714,6 +714,8 @@ def init(commands):
     for name, command in commands.items():
         command(name)
 
+    PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1))
+
     gdb.write('luajit-gdb.py is successfully loaded\n')
 
 def load(event=None):
-- 
2.32.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64
  2021-07-07  7:10 [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64 Mikhail Shishatskiy via Tarantool-patches
@ 2021-07-07 18:35 ` Igor Munkin via Tarantool-patches
  2021-07-22 13:35 ` Igor Munkin via Tarantool-patches
  1 sibling, 0 replies; 3+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2021-07-07 18:35 UTC (permalink / raw)
  To: Mikhail Shishatskiy; +Cc: tarantool-patches

Misha,

Thanks for the new patch! It LGTM, but I have two side notes for the
further series.

1. This is the second attempt to fix #5876. Hence, as it is mentioned in
our guidelines[1], in addition to 'luajit' prefix, you need to add 'v2'
prefix too for the convenience.
2. Do not forget adding the issue link the same way you do for the
remote branch.

These are not critical nits, but such minor "whistles" make maintainer's
life better!

[1]: https://www.tarantool.io/en/doc/latest/dev_guide/developer_guidelines/

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64
  2021-07-07  7:10 [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64 Mikhail Shishatskiy via Tarantool-patches
  2021-07-07 18:35 ` Igor Munkin via Tarantool-patches
@ 2021-07-22 13:35 ` Igor Munkin via Tarantool-patches
  1 sibling, 0 replies; 3+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2021-07-22 13:35 UTC (permalink / raw)
  To: Mikhail Shishatskiy; +Cc: tarantool-patches

Misha,

I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in 1.10, 2.7, 2.8 and master.

On 07.07.21, Mikhail Shishatskiy wrote:
> Since commit 58790750b9c4bd4c21d883f109ab552a2e202a15 ('gdb: introduce
> luajit-gdb extension') when luajit-gdb.py is introduced, Lua stack
> slots printed by lj-stack command are misaligned, when LJ_GC64 is
> enabled. The issue is that PADDING variable used for aligning single
> slots in the output is initialized before LuaJIT build mode is
> defined in <init> function, so the result was the following:
> 
> | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fb0d88            [   M]
> | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fb0cb8            [  T ]
> | ...
> 
> In scope of this patch, PADDING initialization is also moved to
> <init> function right after all commands are loaded. As a result, the
> output looks as expected:
> 
> | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fb0d88                [   M]
> | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fb0cb8                [  T ]
> | ...
> 
> Fixes tarantool/tarantool#5876
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5876
> 
> To test changes do the following:
> 
> | $ gdb -q --args ./luajit -e 'print("QQ")'
> | Reading symbols from ./luajit...
> | lj-arch command initialized
> | lj-tv command initialized
> | lj-str command initialized
> | lj-tab command initialized
> | lj-stack command initialized
> | lj-state command initialized
> | lj-gc command initialized
> | luajit-gdb.py is successfully loaded
> | (gdb) lj-arch
> | LJ_64: True, LJ_GC64: True
> | (gdb) b lj_cf_print
> | Breakpoint 1 at 0x298b0: file /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c, line 485.
> | (gdb) r
> | Starting program: /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/luajit -e print\(\"QQ\"\)
> |
> | Breakpoint 1, lj_cf_print (L=0x0)
> |     at /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c:485
> | 485	{
> | (gdb) s
> | 486	  ptrdiff_t i, nargs = L->top - L->base;
> | (gdb) lj-stack L
> | 0x7ffff7fa8d90:0x7ffff7fa8dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fa8d88                [   M]
> | 0x7ffff7fa8cc0:0x7ffff7fa8d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fa8cb8                [  T ]
> | 0x7ffff7fa8cb0                [ B  ] VALUE: string "QQ" @ 0x7ffff7fb1178
> | 0x7ffff7fa8ca0:0x7ffff7fa8ca8 [    ] FRAME: [L] delta=2, fast function #29
> | 0x7ffff7fa8c90:0x7ffff7fa8c98 [    ] FRAME: [V] delta=2, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
> | 0x7ffff7fa8c80:0x7ffff7fa8c88 [    ] FRAME: [CP] delta=4, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
> | 0x7ffff7fa8c78                [    ] VALUE: C function @ 0x55555555c962
> | 0x7ffff7fa8c70                [    ] VALUE: light userdata @ 0x0
> | 0x7ffff7fa8c60:0x7ffff7fa8c68 [    ] FRAME: [CP] delta=2, C function @ 0x55555555df1c
> | 0x7ffff7fa8c58:0x7ffff7fa8c60 [S   ] FRAME: dummy L
> 
> 
>  src/luajit-gdb.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

<snipped>

> -- 
> 2.32.0
> 

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-22 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07  7:10 [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64 Mikhail Shishatskiy via Tarantool-patches
2021-07-07 18:35 ` Igor Munkin via Tarantool-patches
2021-07-22 13:35 ` Igor Munkin via Tarantool-patches

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git