summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-18 10:47:51 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-18 10:47:51 -0600
commit987cdabc9fe2d5a56d3e7cf86e2716cbbc893df7 (patch)
treeb83b64f2a93d4440a2afa3a612940df2ebd185a6
parentc321bd509b37bc180a5292e8ad142c3df9e2d28c (diff)
downloadzash-987cdabc9fe2d5a56d3e7cf86e2716cbbc893df7.tar.gz
z/OS: dbx, an AMBLIST map and heap-checked test runs
lldb is not on z/OS, so the debug story there is dbx, which needs -g and an unoptimised load: make zos-debug builds ./zash-dbg, zos-dbx runs it, zos-attach attaches to a running shell and zos-dump reads a dump (SVC and SYSMDUMP only: dbx does not read SYSUDUMP or CEEDUMP). AMBLIST maps CSECTs, AMODE/RMODE and entry points of a program object, which is the one question a debugger cannot answer from source: make zos-amblist lists ./zash and the HLASM routine's object module. The docs catch up with C17 and the new targets.
-rw-r--r--DESIGN.md4
-rw-r--r--Makefile53
-rw-r--r--README.md21
3 files changed, 67 insertions, 11 deletions
diff --git a/DESIGN.md b/DESIGN.md
index 1fd68bd..9bd3110 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -49,11 +49,11 @@ creation and character encoding.
## Language level
-- **C11**, compiled with `-std=c11` and no compiler extensions beyond a
+- **C17**, compiled with `-std=c17` and no compiler extensions beyond a
few attributes that are wrapped in macros. C23 was tried first and
dropped: it cannot be relied on for the z/OS toolchain.
- **Clang on Linux, IBM Open XL C/C++ (Clang-based) on z/OS.** The tree
- also builds cleanly with GCC (`-std=c11 -pedantic -Wall -Wextra`),
+ also builds cleanly with GCC (`-std=c17 -pedantic -Wall -Wextra`),
which is checked from time to time to keep the code honest. The legacy
z/OS XL C/C++ (`xlc`) is not a target.
- What the code uses from C11 and C99: `_Noreturn`, `_Static_assert`,
diff --git a/Makefile b/Makefile
index 201c1f4..ec2b974 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,9 @@
# make zos-ebcdic z/OS build, EBCDIC program
# make zos-check z/OS: run the functional tests (no sanitizers)
# make zos-heapcheck z/OS: the same tests under LE heap checking
+# make zos-debug z/OS debug build ./zash-dbg (dbx wants -g)
+# make zos-dbx z/OS: run ./zash-dbg under dbx
+# make zos-amblist z/OS: map the program object's CSECTs with AMBLIST
# make format / tidy
CC = clang
@@ -50,8 +53,15 @@ CLANG_TIDY = clang-tidy
LLDB = lldb
DBGFLAGS = -O0 -g3 -fno-omit-frame-pointer
+# dbx is what z/OS has; lldb and gdb are not there.
+DBX ?= dbx
+# dbx needs -g and read/write load; no optimisation or inlining.
+ZDBGFLAGS ?= -O0 -g3 -m64 -fno-omit-frame-pointer
ARGS =
PID =
+DUMP ?=
+# LISTLOAD|LISTIDR|LISTOBJ, see mvs-diagnosis-tools-and-aids for the syntax
+AMBLIST_STMT ?= LISTLOAD OUTPUT=BOTH
EDIT = builtin
@@ -92,6 +102,39 @@ attach:
$(LLDB) -p $(PID)
+# z/OS debug build: same sources, -O0 -g3, no inlining.
+zash-dbg: $(COMMON) src/sys_zos.c src/zos_csi.o $(HDRS)
+ $(ZCC) $(ZCPPFLAGS) $(CSTD) $(WARN) $(ZDBGFLAGS) -fzos-le-char-mode=ascii \
+ -o $@ $(COMMON) src/sys_zos.c src/zos_csi.o $(LDLIBS)
+
+# make zos-dbx ARGS='-c "echo hi"'
+#
+# Subcommands worth knowing: stop at file:line, where, print, dump,
+# catch SIGNAL, and multproc on|parent|child to follow a fork or spawn.
+# A dump taken by the system is read with `make zos-dump DUMP=file`
+# (dbx reads SVC and SYSMDUMP dumps, not SYSUDUMP or CEEDUMP).
+zos-dbx: zash-dbg
+ $(DBX) ./zash-dbg $(ARGS)
+
+# make zos-attach PID=12345
+zos-attach: zash-dbg
+ @if [ -z "$(PID)" ]; then echo 'usage: make zos-attach PID=pid' >&2; exit 2; fi
+ $(DBX) -a $(PID) ./zash-dbg
+
+# make zos-dump DUMP=/tmp/sysmdu
+zos-dump: zash-dbg
+ @if [ -z "$(DUMP)" ]; then echo 'usage: make zos-dump DUMP=file' >&2; exit 2; fi
+ $(DBX) -C $(DUMP) ./zash-dbg
+
+# Map the CSECTs, AMODE/RMODE and entry points of the built program object,
+# and of the HLASM routine's object module. amblist reads the control
+# statement on stdin and needs a leading blank; the output is long, so it
+# goes to a file.
+zos-amblist: zos-ascii zos_csi.o
+ echo ' $(AMBLIST_STMT)' | amblist ./zash > zash.amblist
+ echo ' LISTOBJ' | amblist src/zos_csi.o > zos_csi.amblist
+
+
# HLASM reads its source as EBCDIC records split at X'15'; the file in git
# is ASCII (tagged UTF-8), so convert a copy first.
src/zos_csi.o: src/zos_csi.s
@@ -218,9 +261,11 @@ install: zash
cp zash $(DESTDIR)$(BINDIR)/zash
clean:
- rm -f zash zash-asan src/*.o compile_commands.json
+ rm -f zash zash-asan zash-dbg zash-mvslint src/*.o compile_commands.json
+ rm -f zash.amblist zos_csi.amblist
rm -rf doc cov
-.PHONY: fuzz zos-lint mvs-asan all check asan valgrind bench compdb format tidy doc coverage \
- install clean \
- zos-ascii zos-ebcdic zos-check
+.PHONY: fuzz zos-lint mvs-asan all check asan valgrind bench compdb format tidy doc \
+ coverage install clean \
+ zos-ascii zos-ebcdic zos-check zos-heapcheck zos-debug zos-dbx \
+ zos-attach zos-dump zos-amblist
diff --git a/README.md b/README.md
index 201c553..f43eae7 100644
--- a/README.md
+++ b/README.md
@@ -62,8 +62,8 @@ Think "the dash of z/OS", but more usable interactively than dash.
| Platform | Compiler | Standard |
|---|---|---|
-| Linux | Clang (GCC also builds it cleanly) | `-std=c11` |
-| z/OS | IBM Open XL C/C++ (`ibm-clang`) | `-std=c11` |
+| Linux | Clang (GCC also builds it cleanly) | `-std=c17` |
+| z/OS | IBM Open XL C/C++ (`ibm-clang`) | `-std=c17` |
The code is plain C11; the few attributes it uses are behind macros. See
[DESIGN.md](DESIGN.md#language-level) for the language level and the
@@ -76,7 +76,7 @@ version, which remains the reference and is what Linux builds use.
## Building
```sh
-make # Linux, clang, -std=c11
+make # Linux, clang, -std=c17
make EDIT=libedit LDLIBS=-ledit # use libedit, not the built-in editor
make check # run the test suite
make asan # build zash-asan (ASan + UBSan) and run the tests
@@ -88,6 +88,10 @@ make format tidy doc # clang-format, clang-tidy, Doxygen
make zos-ascii # z/OS, ibm-clang, ASCII mode (zopen convention)
make zos-ebcdic # z/OS, ibm-clang, EBCDIC (IBM-1047) mode
make zos-check # z/OS: functional tests only, no sanitizers
+make zos-heapcheck # z/OS: the same tests with LE heap check zones on
+make zos-debug # z/OS: unoptimised ./zash-dbg for dbx
+make zos-dbx # z/OS: run ./zash-dbg under dbx
+make zos-amblist # z/OS: CSECT map of the program object
```
Set `CC`, `CLANG_FORMAT` and `CLANG_TIDY` to pick tool versions. The Makefile is one
@@ -113,8 +117,15 @@ The project is tested at several levels:
need python3 and are skipped without it.
- **On z/OS** `make zos-check` runs the same behavioural and
process-accounting tests, plus a z/OS-only group (`tests/zos/`), in
- either character mode. It checks functionality only: there is no ASan,
- UBSan or Valgrind there. The tests use nothing beyond POSIX utilities
+ either character mode. There is no ASan, UBSan or Valgrind there, but
+ Language Environment can put a check zone after every heap element and
+ validate the heap on every request, which turns an overlay into a
+ U4042 abend: `make zos-heapcheck` runs the whole suite that way, and
+ `tests/zos/fuzz.sh` runs its own cases under it.
+- **A debugger** is `lldb` on Linux (`make debug`, `make attach`) and
+ `dbx` on z/OS (`make zos-debug`, `make zos-dbx`); `make zos-amblist`
+ maps the CSECTs of the program object when a module-level question
+ comes up. The tests use nothing beyond POSIX utilities
(`awk`, `sed`, `tr`, `wc`, `sort`), and the few that depend on ASCII
code points are skipped automatically for an EBCDIC build.