From: Mikhail Elhimov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
Sergey Bronnikov <sergeyb@tarantool.org>,
Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit v2 2/7] dbg: cleanup and unify `dbg.eval`
Date: Fri, 4 Dec 2026 23:03:03 +0300 [thread overview]
Message-ID: <77f932c9d36b9b0851c8ee5b0bca2d40bd7ab193.1796410322.git.m.elhimov@vk.team> (raw)
In-Reply-To: <cover.1796410322.git.m.elhimov@vk.team>
* unified error handling (`lldv.eval` now throws an exception in case of
evaluation failure)
* in `gdb.eval` dropped check of the value returned by
`gdb.parse_and_eval` as it would also fail for an expression like '0'
(looks like a kind of experimental code that had been left by mistake)
* `lldb.eval` is adjusted to return object of the same type as
`lldb.cast` (this improves consistency as `gdb.eval` also returns the
same type as `gdb.cast`)
* renamed `dbg.eval` argument to reflect its meaning (it's an expression
rather than a command)
---
src/luajit_dbg.py | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index f498ef3d..cfc3961c 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -150,8 +150,8 @@ class Debugger(object):
pass
@abc.abstractmethod
- def eval(self, command):
- '''Parse and evaluate the given debugger command.'''
+ def eval(self, expr):
+ '''Parse and evaluate the given debugger expression.'''
pass
@abc.abstractmethod
@@ -272,14 +272,11 @@ class _GDBDebugger(Debugger):
else:
return None
- def eval(self, command):
- if not command:
+ def eval(self, expr):
+ if not expr:
return None
- ret = gdb.parse_and_eval(command)
- if not ret:
- raise gdb.GdbError('table argument empty')
- return ret
+ return gdb.parse_and_eval(expr)
def detect_arch(self):
if hasattr(self, 'arch'):
@@ -674,15 +671,29 @@ class _LLDBDebugger(Debugger):
else:
return None
- def eval(self, command):
- if not command:
+ def eval(self, expr):
+ if not expr:
return None
process = self.target.GetProcess()
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
- ret = frame.EvaluateExpression(command)
- return ret
+ val = frame.EvaluateExpression(expr)
+ # LLDB doesn't throw an exception if it fails to
+ # evaluate an expression. In order to simplify handling
+ # of `Debugger.eval()` it is convenient to make it work
+ # similar to GDB, i.e. throw an exception in case of
+ # failure.
+ # Be aware that SBValue.IsValid() is necessary, but not
+ # sufficient as it only indicates that the value object
+ # does contain the relevant data (including the potential
+ # error), so it is necessary to check the `error` property
+ # as well.
+ if not val.IsValid():
+ raise self.error('{}: invalid expression'.format(expr))
+ if val.error.fail:
+ raise self.error(val.error)
+ return lldb.value(val)
def detect_arch(self):
if hasattr(self, 'arch'):
--
2.55.0
next prev parent reply other threads:[~2026-12-04 20:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:03 [Tarantool-patches] [PATCH luajit v2 0/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 1/7] dbg: simplify composing of all commands output Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` Mikhail Elhimov via Tarantool-patches [this message]
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 3/7] dbg: handle missing cmd arg in a dbg-agnostic way Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 4/7] dbg: add tests of deferred extension loading Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 5/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 6/7] dbg: display fast function name along with ffid Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 7/7] dbg: remove wrong GC state Mikhail Elhimov via Tarantool-patches
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=77f932c9d36b9b0851c8ee5b0bca2d40bd7ab193.1796410322.git.m.elhimov@vk.team \
--to=tarantool-patches@dev.tarantool.org \
--cc=e.temirgaleev@tarantool.org \
--cc=m.elhimov@vk.team \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit v2 2/7] dbg: cleanup and unify `dbg.eval`' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox