Commit graph

849 commits

Author SHA1 Message Date
B. Scott Michel
191b2131e9 CMake: Make generate.py reusable
Make generate.py resuable outside of open-simh, as suggested and
motivated by Richard Cornwell's simulator repository.

- Make the "experimental" rule optional. Do not generate a Python
  "KeyError" if the rule is missing.

- Add documentation on how to use the CMake infrastructure outside
  of open-simh: Customize the packaging.py script, season to taste.

- Update the KA10 simulator customization, moving it to its own
  Python script, simgen/pdp10_simulator.py. Preparatory move that
  anticipates additional frontpanel and display options.

- generate.py option "--skip-orphans": Skip the orphaned simulator
  check (i.e., don't cross-reference the simulators in packaging.py
  with what was scraped from the makefile.)

- Add "TEST_ARGS" argument to CMake's add_simulator function so that the
  IBM 1130 simulator can pass to "-g" on the command line to disable the
  GUI when running RegisterSanityCheck, i.e.:

    ibm1130 RegisterSanityCheck -g

  This fixes an edge case Heisenbug encountered during Github CI/CD
  tests where ibm1130 appears to hang indefinitely on the Windows
  runners.

  The cause is the GUI's Pump() thread function being prematurely
  terminated before all GUI resources are acquired. The net result is an
  infinite loop in the MS C runtime trying to exit the process with
  unstable internal state. (Separate patch: synchronization across main
  and Pump() threads to ensure resource acquisition completes.)

  This issue never shows up on non-Windows platforms or the SIMH makefile.

- cmake/generator.py, cmake/simgen: Add a "test_args" keyword argument
  to the BasicSimulator constructor that holds the tests argument
  parameter emitted as the "TEST_ARGS" argument to a simulator's
  add_simulator(). Ensure that the IBM 1130 emits 'TEST_ARG "-g"' in its
  add_simulator().

- scp.c: reset_all_p() adds 'P' to the existing switches, versus saving
  sim_switches and ONLY setting the 'P' power-up reset switch. Net effect
  is that the IBM 1130 simulator actually sees the 'G' flag that inhibits
  the GUI during the console device reset.
2024-05-21 15:57:21 -04:00
B. Scott Michel
ae9e57f659 SCP: sprint_val comma bug, GH: Remnant symlinks
- Fix comma separator code segmentation fault: "ndigit - 3" can become a
  very large unsigned number for ndigit < 3.

- dir_cmd: Allocate WildName from heap to reduce stack pressure.

- Github CI/CD: Remnant symlink issue reappeared, afflicting the
  makefile-based build. For better or worse, the workaround is now
  dependent on specific Python versions that must be removed, unlinked
  and any remnant symlinks that HomeBrew decided it needed to install in
  /usr/local/bin. The Python upgrade is triggered by the sdl2_ttf
  package.

  According to the Github image maintainers, this is an old, known issue
  in macOS images that originates inside of Homebrew.
2024-03-12 11:51:19 -07:00
Mark Pizzolato
7a6a325580 ETHER: Make sure SET NOASYNC is effective for Ethernet devices
- Make sure that asynchronous mode can't be changed if devices using
   sim_ether are already attached.
- Add missing DEV_ETHER type flag for the only sim_ether using device
   that didn't already have it.
2024-02-01 12:54:53 -05:00
B. Scott Michel
a275c71170 SCP: Reduce compiler warnings on LP64 platforms
(Note: Reducing compiler warnings across all, but primarily LP64
platforms, is a long term objective.)

Reduce compiler warnings on LP64 platforms (macOS, Windows) and 32-bit
builds (Win32). Prefer 'size_t' for pointer arithmetic, array indexing
and extents; 'int' hasn't been used for these purposes for many years
and across many ANSI standards. N.B. that conversions from int or int32
to size_t cause the compiler to zero-extend the value, which is
inefficient.

Refactor printf() format modifiers into sim_printf_fmts.h. Add the
SIZE_T_FMT modifier for better portability, especially on LP64 platforms
where size_t is unsigned long and sizeof(size_t) > sizeof(int).

3B2: Fix known size_t printf() format.
2024-02-01 12:51:32 -05:00
B. Scott Michel
f4c39a325c SCP: Add'l memory sanitization fixes
Initialize de-dup'ed debug line buffer:

  realloc(NULL, size) == malloc(size), which is uninitialized space.
  This causes the Clang memory sanitizer to detect an attempt to read
  uninitialized memory when debug_line_buf and debug_line_buf_last are
  different lengths. While the uninitialized space may never actually be
  compared, the memory sanitizer emits a strong hint to not do stupid.

  The sanitizer trips in the i650 simulator on the first memcmp(),
  debug_line_buf has 108 characters, debug_line_buf_last has 56
  characters (uninitialized space follows the 56 characters, tripping
  the sanitizer.)

  - memset() debug_line_buf and debug_line_buf_last to zero so that
    memcmp() will always gracefully return non-zero if somehow memcmp()
    ends up going past the end of either buffer.  Should never happen in
    practice, but theory always gets mugged by reality.

  - Keep track of debug_line_buf_last's comparison length (i.e., up to
    the '\r') and only execute memcmp() when this length equals the
    current debug_line_buf comparison length (end - endprefix + 1).

  - Added a log deduplication test to "testlib" command to ensure that
    nothing broke as a result of this fix.

Network ACL check in sim_addr_acl_check:

  The memory sanitizer found an off-by-one bug in sim_addr_acl_check
  while executing "testlib". This makes CIDR network ACLs functional,
  e.g., "127.0.0.1/32" is interpreted properly and the associated
  "testlib" test passes.
2024-02-01 12:50:52 -05:00
B. Scott Michel
c57f925256 SCP: Move .git-commit-id.h to where used
Move .git-commit-id.h include to where it's actually referenced in
scp.c to reduce the recompile overhead for build systems that track
build dependencies.

Ensure that headers that reference SIM_MAJOR include sim_rev.h as a
defensive coding practice.

Net effect: Reduces recompiled source to a minimum when .git-commit-id.h
is updated and removes the sim_defs.h > sim_rev.h > .git-commit-id.h
dependency subgraph. Everything includes sim_defs.h, so a change to
.git-commit-id.h causes a large recompile, vice what should just be a
scp.c recompile and simulator suite relink.

Does not impact makefile builds, since makefile builds will recompile
everything; dependency tracking is superfluous.
2023-10-24 12:48:38 -04:00
Tony Lawrence
c3f55fc692 SCP: Fix correctly loading simh.ini when user HOME not defined 2023-10-09 20:18:05 -04:00
B. Scott Michel
1e371e7c98 Memory sanitizer fixes
Fixes suggested by running the Clang memory santizer on the Github CI/CD
pipeline:

- sim_exp_check: Use calloc() to allocate and initialize the PCRE
  captured string offset vector. Also check the offsets to ensure they
  are captured substrings:

  -- If a substring wasn't captured, the offset pair is { -1, -1 }.
     (Of course, this would never happen in SIMH. :-)

  -- Remove the corresponding "_EXPECT_MATCH_GROUP_{pat}" variable
     from the environment when its substring isn't captured.  unsetenv()
     is locally implemented in scp.c, which sets the environment
     variable to an empty string; it isn't actually removed.

  Failure occurs in multiple tests.

- _sim_debug_write_flush: Ensure that debug_line_buf_last's underlying
  buffer is initialized when realloc-ed. (i650 failure.)

- vid_version: Initialize local variables "compiled" and "running". MSan
  claims that these aren't initialized. Reading the SDL  source, the
  patch level might not be initialized on some platforms. (multiple
  sim_video tests.)

NOTE: Do not attempt to run interactive memory-santized simulators on
Linux platforms where ncurses <= 6.2+20201114-2. MSan detects
uninitialized variables within ncurses; newer versions of ncurses fix
them.
2023-07-16 16:35:58 -04:00
Seth Morabito
96de0748d4 SCP: Don't malloc ep->match_pattern twice 2023-06-18 13:09:00 -04:00
Peter Schorn
e4ad37eccc SCP: Fix possible memory corruption issue 2023-04-07 09:17:46 +02:00
Mark Pizzolato
374e3b8e71 SCP: Change declaration of get_yn() to have boolean argument and return value
- Fix improper get_yn() use in test library logic

Reported by Peter Schorn
2023-04-06 13:00:52 -10:00
Mark Pizzolato
decbe5b76b Various simulators: Set line endings to CRLF for consistency, remove stray tabs
Project standard source code has tabs converted to spaces and CRLF line
endings.

Other text files have CRLF line endings.
2023-03-19 16:51:27 -04:00
Timothe Litt
949359fd42
Update version to identify Open SIMH builds
This is to prevent confusion when questions come in.

Plus, a little advertising never hurts.

The version output will now include "Open SIMH", and the version
number will be '4.1.*' rather than '4.0.*'.
2023-02-02 16:09:22 -05:00
Bob Supnik
4562408a5f Common code: various bugfixes; Mac "Classic" and OS/2 support has been removed 2023-01-31 14:49:35 -05:00
Peter Schorn
ce791138b5 SCP: Remove dead code in sim_sanity_check_register_declarations 2022-12-05 12:16:52 -05:00
Patrick Linstruth
92e40cb1c8 SCP: Add VM-specific messages to %TSTATUS% expansion
Clean up variable expansion help
2022-11-30 12:27:19 -05:00
Patrick Linstruth
3ec3e3aa8f AltairZ80: Fix HALT stop code conflict with ON ERROR
AltairZ80 uses 0 for the VM-specific HLT instruction stop code.
SCP defines SCPE_OK as 0.
SCP uses 0 to mean all errors ("ON ERROR").

The command "ON 0" will generate "%SIM-ERROR: Invalid argument: 0".

This PR changes the HALT stop code from 0 to 5.
2022-11-27 17:14:57 -05:00
Tony Lawrence
57837528ae SCP: Word order in "set def" error 2022-11-27 14:39:58 -05:00
Mark Pizzolato
5250eb866d SCP: Update HELP SET ON to also describe INHERIT and NOINHERIT options
Add missing help information reported in #130
2022-11-27 14:39:12 -05:00
Paul Koning
110183e258 simh ui: replace "readline" by "editline".
This avoids infecting SIMH with the GPL license, since readline,
very surprisingly, is GPL rather than LGPL.

The replacement package is "editline", which has a useable license.
2022-10-01 16:38:55 -04:00
Ken Rector
bef5b821f0 SCP: Fix parenthesis to avoid potential compiler warnings 2022-07-01 07:23:35 -10:00
Ken Rector
755cb9ccff SCP: Add parenthesis to avoid potential compiler warnings 2022-07-01 07:13:22 -10:00
J. David Bryan
4dde5a69a4 SCP: Updated REG macros and manipulation APIs
- Rewrote get_rval, put_rval to support fields within arrays of structures
- REG "size" field now determines access size
- REG "maxval" field now determines maximum allowed value

Merge from v3.12
2022-06-24 15:39:45 -07:00
Bob Supnik
cc6f8ee8ee SCP: Fixed bug in byte deposits if aincr > 1
The PDP11 and VAX have length switches - B, W, and (VAX) L - to
override the default parsing of numberic display or input as words
(PDP11) or longwords (VAX CPU) or bytes (VAX byte devices).
This worked fine if every value is filled in. On the PDP11:

sim> ideposit -b 0-3
0:    1
1:    2
2:    3
3:    4
sim>

But if the user skips an input, IDEPOSIT advances by 2, not 1:

sim> ideposit -b 0-3
0:    1
1:    (cr)
3:    4
sim>

This change now produces the correct behavior.

PDP-11 simulator V3.12-2
sim> id -b 0-3
0:      1
1:
2:      3
3:      4
sim>
2022-06-17 08:23:29 -07:00
Anthony Lawrence
bcaed7d0b0 SCP: Fix incorrect disk size reporting when t_addr is 32 bits 2022-06-14 20:21:21 -07:00
Mark Pizzolato
b2dd269d7a SCP: Expand sprint_val target buffers with one extra byte 2022-03-13 20:08:54 -07:00
Mark Pizzolato
ee545a4828 SCP: Assure that all formatted numbers have sufficient buffer space 2022-03-13 13:23:05 -07:00
Mark Pizzolato
e3dbe93e35 SCP: Coverity fixes 2022-03-09 15:53:10 -08:00
Mark Pizzolato
857f725470 SCP: Avoid a Coverity complaint about getenv() 2022-03-08 00:02:07 -08:00
Mark Pizzolato
a50dca0ff0 SCP: Normalize writelock/read only behavior
Setting a unit to write locked specifically allows only read access.
- If this is done while a unit is attached, it is up to device logic to
  limit write activity until it is detached.
- If this is done while a unit is not attached, a subsequent attach
  opens the container read only.
2022-03-04 21:13:37 -08:00
Mark Pizzolato
abd756ebad SCP: Allow unattached errors to halt with a specific unattached message 2022-03-03 17:40:27 -08:00
Mark Pizzolato
4a45fda672 SCP: assure that t_stat is returned in sim_call_argv() 2022-02-28 10:12:33 -08:00
Mark Pizzolato
9bd945679d SCP: Add new sim_call_argv() API.
call a routine with C style argc, argv parsed arguments
2022-02-28 07:44:39 -08:00
Mark Pizzolato
d960c96f56 SCP: UNIT_BUFABLE isn't always set with UNIT_MUSTBUF
UNIT_BUFABLE without UNIT_MUSTBUF means that uptr->filebuf is managed
outside of attach_unit's authority.  The buffer copy must always be allocated
if UNIT_BUFABLE is set so that there is space to store the initial loaded copy.

Fix #1122
2022-02-14 19:30:30 -08:00
Mark Pizzolato
eac0e5680b DISK: Add SET NOAUTOSIZE - disable autosize when attaching existing containers
This is a global command possibly for folks who have configurations which
always explicitly specify the drive type they want a particular unit to be
before they attach a container to the unit.  The side effect of this will
be to avoid the addition of drive type describing meta data to disk
containers.
2022-02-14 15:06:34 -08:00
Mark Pizzolato
3949f62e89 SCP: Use sim_messagef for all error paths in attach_unit and sim_disk_attach 2022-02-14 04:00:04 -08:00
Mark Pizzolato
315a07cbc7 SCP: Avoid writing out memory buffered devices on detach that haven't changed
As discussed in #1109
2022-02-13 22:50:37 -08:00
Mark Pizzolato
6187b0519a SCP: Support output formatting for long DEVICE and UNIT names
This extends fe4a2a28b to include support for long unit names as well.
2022-02-12 15:19:51 -08:00
Mark Pizzolato
a4054f33b8 SCP: Add command argument passed into library unit test routines 2022-02-07 04:21:16 -08:00
Mark Pizzolato
2209f25086 SCP: Add a success or failure indicator preceeding messages 2022-02-06 11:16:57 -08:00
Mark Pizzolato
54eda7a050 SCP: Extend BITFIELDS to allow alternate descriptions for same fields 2022-02-04 07:56:15 -08:00
Mark Pizzolato
dd92be296c SCP: Add host system processor name to SHOW VERSION output 2022-02-04 07:51:08 -08:00
Mark Pizzolato
370bfe006d SCP: Avoid using strlcpy for overlapping string copy 2022-01-16 07:44:15 -08:00
Mark Pizzolato
b5052c81d6 makefile, SCP: Enrich support for compile time SIM_VERSION_MODE
- Pass make command line SIM_VERSION_MODE argument into the compiler.
- Tolerate quoted and unquoted SIM_VERSION_MODE values.
2022-01-15 10:01:49 -08:00
Mark Pizzolato
b24e3580dc SCP: Add clarifying context to various device/unit error messages 2022-01-12 12:17:21 -08:00
Paul Koning
5cd1e8b7ac TMXR, PDP11, PDP10, VAX: Add DDCMP sync framer support
This adds support for the "framer" device, which is a USB-connected
device built around a Raspberry Pico that connects to a synchronous
line, either RS-232 or DEC "integral modem" coax connection.  It
implements the framing portion of DDCMP: clock recovery for the
integral modem case, byte sync, and DDCMP frame handling including
CRC.  The actual DDCMP protocol state machine, with its handling of
sequencing, timeout and retransmit, etc. is left to the host
software.  All the design files for the framer may be found at
https://github.com/pkoning2/ddcmp .

This commit adds code to drive the framer from the TMXR library,
allowing it to be used either from simulated DMC-11 or simulated
DUP-11 devices.  Both have been tested, using RSTS/E, RSX-11/M+, and
TOPS-20.

Fixed the one-digit limit on eth<n> device names, the limit is now 2.
2022-01-08 14:24:42 -08:00
Mark Pizzolato
fa5e0ed157 SCP: Assure that debug writes that check errno get a correct value
The original solution provided in response to #957 needs to be adjusted
to reflect that errno is only guaranteed to be set by fwrite() if an error
occurred. otherwise a non zero value may have been set by some other
call elsewhere in the program.  All other cases where errno is explicitly
check in simh, it is only done after receiving a return status from a
system call.

Fix problem reported in #1108
2022-01-06 12:18:10 -08:00
Mark Pizzolato
ff4c7b154e SCP: Minor Coverity cleanup 2022-01-02 09:47:33 -08:00
Mark Pizzolato
cea76d59bd SCP: Add newer baseline libreadline support. 2021-12-15 16:52:49 -08:00
Mark Pizzolato
c5cd38afbf SCP, makefile: Rename build conditional HAVE_DLOPEN to SIM_HAVE_DLOPEN
Some dependent packages on some platforms may also define HAVE_DLOPEN
and that definition may have different syntax or semantics.  This change
avoids the potential symbol conflict.

As reported in #1098
2021-12-04 17:44:57 -08:00