Skip to content

Commit

Permalink
Stub out pkgState with non-error, helps with debugging.
Browse files Browse the repository at this point in the history
Summary:
When we use -dppr-debug, we'll sometimes attempt to
hit the pkgState to give more detailed information.  It's pretty
annoying to have this fail because we haven't filled in the
pkgState: we can still get useful debugging information by
printing the raw package key.  To avoid this, we just put
in some empty stub pkgState, to be filled in later.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D817
  • Loading branch information
ezyang committed Apr 17, 2015
1 parent 2b3766b commit ad6d6a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/main/DynFlags.hs
Expand Up @@ -157,7 +157,7 @@ import Module
import PackageConfig
import {-# SOURCE #-} Hooks
import {-# SOURCE #-} PrelNames ( mAIN )
import {-# SOURCE #-} Packages (PackageState)
import {-# SOURCE #-} Packages (PackageState, emptyPackageState)
import DriverPhases ( Phase(..), phaseInputExt )
import Config
import CmdLineParser
Expand Down Expand Up @@ -1480,7 +1480,8 @@ defaultDynFlags mySettings =
packageFlags = [],
packageEnv = Nothing,
pkgDatabase = Nothing,
pkgState = panic "no package state yet: call GHC.setSessionDynFlags",
-- This gets filled in with GHC.setSessionDynFlags
pkgState = emptyPackageState,
ways = defaultWays mySettings,
buildTag = mkBuildTag (defaultWays mySettings),
rtsBuildTag = mkBuildTag (defaultWays mySettings),
Expand Down
9 changes: 9 additions & 0 deletions compiler/main/Packages.hs
Expand Up @@ -8,6 +8,7 @@ module Packages (

-- * Reading the package config, and processing cmdline args
PackageState(preloadPackages),
emptyPackageState,
initPackages,
readPackageConfigs,
getPackageConfRefs,
Expand Down Expand Up @@ -287,6 +288,14 @@ data PackageState = PackageState {
installedPackageIdMap :: InstalledPackageIdMap
}

emptyPackageState :: PackageState
emptyPackageState = PackageState {
pkgIdMap = emptyUFM,
preloadPackages = [],
moduleNameDb = Map.empty,
installedPackageIdMap = Map.empty
}

type InstalledPackageIdMap = Map InstalledPackageId PackageKey
type InstalledPackageIndex = Map InstalledPackageId PackageConfig

Expand Down
1 change: 1 addition & 0 deletions compiler/main/Packages.hs-boot
Expand Up @@ -4,3 +4,4 @@ import {-# SOURCE #-} Module (PackageKey)
import {-# SOURCE #-} DynFlags (DynFlags)
data PackageState
packageKeyPackageIdString :: DynFlags -> PackageKey -> Maybe String
emptyPackageState :: PackageState

0 comments on commit ad6d6a7

Please sign in to comment.