summary refs log tree commit diff stats
path: root/tools/nim-gdb.py
Commit message (Collapse)AuthorAgeFilesLines
* [nim-gdb] Fixed enums and flag output [ci skip] (#17634)Saem Ghani2021-04-051-75/+175
| | | | | | | Debugger works for enums again. Additionally, flags work better than before. Reworked object printer as well, but the approach needs much more work or has to be replaced all together. This is mostly to save the work and myself or someone else can revisit it.
* nim-gdb.py fixes mostly for nimsuggest debugging (#16479)Saem Ghani2020-12-301-57/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These fixes were primarily developed to assist in nimsuggest debugging. There is nothing intentionally specific done for nimsuggest, but beyond the automated tests all practical testing was done with nimsuggest. Undoubltedly these will also assist in other debugging scenarios. The current nim-dbg.py script was broken in a few ways: - failed to provide detailed value information for common types (see below) - was not passing existing tests - could not produce type summary information Broken types now working somewhat better: - sequences with ref types like strings - sequences with value types like ints - arrays with ref types like strings - tables with int or string keys Other improvements: - slightly more test coverage Future considerations: - this, data used by it, should be something the compiler can generates - account for different memory layouts ([arc/orc differ](https://github.com/nim-lang/Nim/pull/16479#issuecomment-751469536)) Attempts at improving nim-gdb.py More tests, few fixes for seq and type printing Tables debugging fixed added further tests Fixed type printing
* add $nimeq for gdb (#12909)Arne Döring2019-12-171-0/+29
|
* Refactor json macro (#12391)Arne Döring2019-10-171-4/+4
| | | | | | | | * closes #12316 * make tjsonmacro work at js target * closes #12289 * closes #11988 * also fixed gdb related stuff
* rename cast opcodes, fix for 32bit cast, fix python pretty printer (#12207)Arne Döring2019-09-181-4/+4
|
* $ command in gdb now works (#10956)Arne Döring2019-04-151-10/+37
|
* add NimFrameFilter to nim-gdb.py (#10873)Arne Döring2019-03-261-0/+16
|
* add gdb commands: koch, nim, nimble (#10741)Arne Döring2019-02-261-0/+54
| | | | | * add gdb commands: koch, nim, nimble * make commands path independent
* precise printer injectionArne Döring2019-01-211-5/+14
|
* gdb pretty printer survive reloadArne Döring2019-01-211-8/+8
|
* fixes #9276 (#9317)Arne Döring2018-10-241-0/+19
|
* Gdb pretty printers (#8263)Arne Döring2018-07-161-0/+513
me.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# http://rosettacode.org/wiki/N-queens_problem
# port of the Arc solution at http://arclanguage.org/item?id=19743

container square [
  rank:number
  file:number
]

def nqueens n:number, queens:address:list:square -> result:number [
  local-scope
  load-ingredients
  # if 'queens' is already long enough, print it and return
  added-so-far:number <- length queens
  {
    done?:boolean <- greater-or-equal added-so-far, n
    break-unless done?
    stash queens
    return 1
  }
  # still work to do
  next-rank:number <- copy 0
  {
    break-unless queens
    first:square <- first queens
    existing-rank:number <- get first, rank:offset
    next-rank <- add existing-rank, 1
  }
  result <- copy 0
  next-file:number <- copy 0
  {
    done?:boolean <- greater-or-equal next-file, n
    break-if done?
    curr:square <- merge next-rank, next-file
    {
      curr-conflicts?:boolean <- conflict? curr, queens
      break-if curr-conflicts?
      new-queens:address:list:square <- push curr, queens
      sub-result:number <- nqueens n, new-queens
      result <- add result, sub-result
    }
    next-file <- add next-file, 1
    loop
  }
]

def conflict? curr:square, queens:address:list:square -> result:boolean [
  local-scope
  load-ingredients
  result1:boolean <- conflicting-file? curr, queens
  reply-if result1, result1
  result2:boolean <- conflicting-diagonal? curr, queens
  reply result2
]

def conflicting-file? curr:square, queens:address:list:square -> result:boolean [
  local-scope
  load-ingredients
  curr-file:number <- get curr, file:offset
  {
    break-unless queens
    q:square <- first queens
    qfile:number <- get q, file:offset
    file-match?:boolean <- equal curr-file, qfile
    reply-if file-match?, 1/conflict-found
    queens <- rest queens
    loop
  }
  reply 0/no-conflict-found
]

def conflicting-diagonal? curr:square, queens:address:list:square -> result:boolean [
  local-scope
  load-ingredients
  curr-rank:number <- get curr, rank:offset
  curr-file:number <- get curr, file:offset
  {
    break-unless queens
    q:square <- first queens
    qrank:number <- get q, rank:offset
    qfile:number <- get q, file:offset
    rank-delta:number <- subtract qrank, curr-rank
    file-delta:number <- subtract qfile, curr-file
    rank-delta <- abs rank-delta
    file-delta <- abs file-delta
    diagonal-match?:boolean <- equal rank-delta, file-delta
    reply-if diagonal-match?, 1/conflict-found
    queens <- rest queens
    loop
  }
  reply 0/no-conflict-found
]