Project

General

Profile

Actions

Feature #10941

closed

mdb deserves a modulus operator

Added by Robert Mustacchi over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Category:
mdb - modular debugger
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

mdb does not at this time have a modulus operator, but it should. This is likely a hold over from adb. While there is a '%' operator, it is for integer division as the normal division operator '/' was taken due to dereferencing. As such, I've decided to co-opt '%%' to allow someone to have a modulus operator. This is currently invalid syntax.

To test this I put together a new mdb build and tested the following:

  • We correctly calculated positive and negative modulus values in a way consistent with a C program or node.js.
  • We correctly handled the modulus by zero case and errored
  • We did not hit the division error that the division case special cases around LONG_MIN and -1.
  • That we get a syntax error if missing either argument to the modulus operator or both
  • Ran the mdb_v8 test suite as an additional sanity test

I also verified that on an older mdb, using the %% would always generate a syntax error, so it should not be possible to confuse it for something else.

Actions #1

Updated by Electric Monk over 4 years ago

  • Status changed from New to Closed

git commit 7a2abfc9b29ea1ccc055443876ab57455e3e8f71

commit  7a2abfc9b29ea1ccc055443876ab57455e3e8f71
Author: Robert Mustacchi <rm@joyent.com>
Date:   2019-06-04T13:14:28.000Z

    10941 mdb deserves a modulus operator
    Reviewed by: John Levon <john.levon@joyent.com>
    Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
    Reviewed by: Toomas Soome <toomas@me.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Gordon Ross <gwr@nexenta.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF