Tarantool development patches archive
 help / color / mirror / Atom feed
From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: Maxim Kokryashkin <max.kokryashkin@gmail.com>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v2 6/6] profilers: print user-friendly errors
Date: Tue, 9 Jan 2024 16:54:32 +0300	[thread overview]
Message-ID: <jqaodkrlo3vvvn52qdpf235ev44yc46zt63al4m5owhzsr6dly@hm7szssdyzvs> (raw)
In-Reply-To: <e793113c-7463-425a-bf7c-1c9e56cba282@tarantool.org>

Hi, Sergey!
Thanks for the review!
Fixed your minor, branch is force-pushed. Here is the diff:
===
diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua
index cc66a23e..11a79a1d 100644
--- a/tools/memprof/parse.lua
+++ b/tools/memprof/parse.lua
@@ -206,12 +206,13 @@ function M.parse(reader, symbols)
   local _ = reader:read_octets(3)

   if magic ~= LJM_MAGIC then
-    error("Bad LJM format prologue: "..magic)
+    error("Bad memprof event format prologue: "..magic)
   end

   if string.byte(version) ~= LJM_CURRENT_VERSION then
     error(string_format(
-      "LJM format version mismatch: the tool expects %d, but your data is %d",
+      "Memprof event format version mismatch:"..
+      " the tool expects %d, but your data is %d",
       LJM_CURRENT_VERSION,
       string.byte(version)
     ))
diff --git a/tools/sysprof/parse.lua b/tools/sysprof/parse.lua
index 749f70db..0e416d37 100755
--- a/tools/sysprof/parse.lua
+++ b/tools/sysprof/parse.lua
@@ -237,12 +237,13 @@ function M.parse(reader, symbols)
   local _ = reader:read_octets(3)

   if magic ~= LJP_MAGIC then
-    error("Bad LJP format prologue: " .. tostring(magic))
+    error("Bad sysprof event format prologue: " .. tostring(magic))
   end

   if string.byte(version) ~= LJP_CURRENT_VERSION then
     error(string_format(
-      "LJP format version mismatch: the tool expects %d, but your data is %d",
+      "Sysprof event format version mismatch:"..
+      " the tool expects %d, but your data is %d",
       LJP_CURRENT_VERSION,
       string.byte(version)
     ))
diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua
index c4aefef7..e80b9f33 100644
--- a/tools/utils/symtab.lua
+++ b/tools/utils/symtab.lua
@@ -95,13 +95,13 @@ function M.parse(reader)
   local _ = reader:read_octets(3)

   if magic ~= LJS_MAGIC then
-    error("Bad LJS format prologue: " .. tostring(magic))
+    error("Bad LuaJIT symbol table format prologue: " .. tostring(magic))
   end

   if string.byte(version) ~= LJS_CURRENT_VERSION then
     error(string_format(
-         "LJS format version mismatch:"..
-         "the tool expects %d, but your data is %d",
+         "LuaJIT symbol table format version mismatch:"..
+         " the tool expects %d, but your data is %d",
          LJS_CURRENT_VERSION,
          string.byte(version)
     ))
===

WBR,
Max
On Fri, Dec 29, 2023 at 03:27:46PM +0300, Sergey Bronnikov wrote:
> Hello, Max
>
>
> thanks for the patch. LGTM with minor comments
>
>
> On 12/6/23 21:55, Maxim Kokryashkin wrote:
>
>
> <snipped>
>
> > diff --git a/tools/sysprof/parse.lua b/tools/sysprof/parse.lua
> > index 64c4a455..749f70db 100755
> > --- a/tools/sysprof/parse.lua
> > +++ b/tools/sysprof/parse.lua
> > @@ -237,7 +237,7 @@ function M.parse(reader, symbols)
> >     local _ = reader:read_octets(3)
> >     if magic ~= LJP_MAGIC then
> > -    error("Bad LJP format prologue: "..magic)
> > +    error("Bad LJP format prologue: " .. tostring(magic))
> >     end
>
> LJP is not a well-known abbreviation. Probably, it is better to write the
> error
>
> message without it. I see that LJP/LJS is used extensively in error message,
> so feel free to
>
> ignore or fix in a separate patch.
>
> >     if string.byte(version) ~= LJP_CURRENT_VERSION then
> > diff --git a/tools/utils/safe_event_reader.lua b/tools/utils/safe_event_reader.lua
> > new file mode 100644
> > index 00000000..39246a9d
> > --- /dev/null
> > +++ b/tools/utils/safe_event_reader.lua
> > @@ -0,0 +1,34 @@
> > +local bufread = require('utils.bufread')
> > +local symtab = require('utils.symtab')
> > +
> > +local function make_error_handler(fmt, inputfile)
> > +  return function(err)
> > +    io.stderr:write(string.format(fmt, inputfile))
> > +    io.stderr:write(string.format('\nOriginal error: %s', err))
> > +    os.exit(1, true)
> > +  end
> > +end
> > +
> > +local function safe_event_reader(parser, inputfile)
> > +  local _, reader = xpcall(
> > +    bufread.new,
> > +    make_error_handler('Failed to open %s.', inputfile),
> > +    inputfile
> > +  )
> > +
> > +  local _, symbols = xpcall(
> > +    symtab.parse,
> > +    make_error_handler('Failed to parse symtab from %s.', inputfile),
> > +    reader
> > +  )
> > +
> > +  local _, events = xpcall(
> > +    parser,
> > +    make_error_handler('Failed to parse profile data from %s.', inputfile),
> > +    reader,
> > +    symbols
> > +  )
> > +  return events, symbols
> > +end
> > +
> > +return safe_event_reader
> > diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua
> > index 0c878e7a..c4aefef7 100644
> > --- a/tools/utils/symtab.lua
> > +++ b/tools/utils/symtab.lua
> > @@ -95,7 +95,7 @@ function M.parse(reader)
> >     local _ = reader:read_octets(3)
> >     if magic ~= LJS_MAGIC then
> > -    error("Bad LJS format prologue: "..magic)
> > +    error("Bad LJS format prologue: " .. tostring(magic))
>
> LJS is not a well-known abbreviation. Probably, it is better to write the
> error
>
> message without it.
>
> >     end
> >     if string.byte(version) ~= LJS_CURRENT_VERSION then

  reply	other threads:[~2024-01-09 13:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 18:55 [Tarantool-patches] [PATCH luajit v2 0/6] profilers: refactor parsers Maxim Kokryashkin via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 1/6] build: purge sysprof.collapse module Maxim Kokryashkin via Tarantool-patches
2023-12-12 10:18   ` Sergey Kaplun via Tarantool-patches
2023-12-19 12:20   ` Sergey Bronnikov via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 2/6] build: fix tool components handling Maxim Kokryashkin via Tarantool-patches
2023-12-12 10:32   ` Sergey Kaplun via Tarantool-patches
2023-12-12 12:53     ` Maxim Kokryashkin via Tarantool-patches
2023-12-12 12:51       ` Sergey Kaplun via Tarantool-patches
2023-12-19 13:56   ` Sergey Bronnikov via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 3/6] memprof: refactor `heap_chunk` data structure Maxim Kokryashkin via Tarantool-patches
2023-12-12 10:34   ` Sergey Kaplun via Tarantool-patches
2023-12-19 14:00   ` Sergey Bronnikov via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 4/6] memprof: remove unused arguments Maxim Kokryashkin via Tarantool-patches
2023-12-12 10:44   ` Sergey Kaplun via Tarantool-patches
2023-12-19 14:01   ` Sergey Bronnikov via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 5/6] memprof: introduce the `--human-readable` option Maxim Kokryashkin via Tarantool-patches
2023-12-12 10:54   ` Sergey Kaplun via Tarantool-patches
2023-12-20 12:24   ` Sergey Bronnikov via Tarantool-patches
2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 6/6] profilers: print user-friendly errors Maxim Kokryashkin via Tarantool-patches
2023-12-12 11:51   ` Sergey Kaplun via Tarantool-patches
2023-12-12 12:54     ` Maxim Kokryashkin via Tarantool-patches
2023-12-12 12:54       ` Sergey Kaplun via Tarantool-patches
2023-12-29 12:27   ` Sergey Bronnikov via Tarantool-patches
2024-01-09 13:54     ` Maxim Kokryashkin via Tarantool-patches [this message]
2024-01-16  9:48       ` Sergey Bronnikov 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=jqaodkrlo3vvvn52qdpf235ev44yc46zt63al4m5owhzsr6dly@hm7szssdyzvs \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=sergeyb@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2 6/6] profilers: print user-friendly errors' \
    /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